From owner-freebsd-current@FreeBSD.ORG Mon Aug 13 20:49:58 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BF952106564A for ; Mon, 13 Aug 2012 20:49:58 +0000 (UTC) (envelope-from andy@fud.org.nz) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id 77E498FC0A for ; Mon, 13 Aug 2012 20:49:58 +0000 (UTC) Received: by yhfs35 with SMTP id s35so4433064yhf.13 for ; Mon, 13 Aug 2012 13:49:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=tqORfFH00x0ixpIWRpQHBL+kN8JIAkH+ktL+I2xAmV4=; b=hIbtvqHPz8khA0IAYQL3UThkvfOZ5kP7CBLmwYmmSHqTnbYNy5kR1PJ+j8+jJxjcEi 7Hhy37e/ppPUwo1xkJbT8f2BGhEFfsgeTtmx9qh/SaA2/EoS4nnAopmoUzsaZulfymfa U5lURXLiuPB1pMaGNfQJdXuMtDaz6isaHiQ3zpwcp765KN1wFC/56BX52sWb5Tglb7pU tQ9HGm5wO2OvjdSUKjjqn/iZuG1e3s1caZ3116LOXTxBk5v2zTZbllg5oVWXnZUn2PUY KpN2tW3aFKmUMwviGBX0Xtj9ins1zfNIc1ztxAB0F3JsXx7ydN3v+gAUhTZ5NmP+JU+z paqQ== MIME-Version: 1.0 Received: by 10.66.76.130 with SMTP id k2mr18655331paw.19.1344890996762; Mon, 13 Aug 2012 13:49:56 -0700 (PDT) Sender: andy@fud.org.nz Received: by 10.68.135.130 with HTTP; Mon, 13 Aug 2012 13:49:56 -0700 (PDT) In-Reply-To: <20120813205622.GA85732@onelab2.iet.unipi.it> References: <20120813205622.GA85732@onelab2.iet.unipi.it> Date: Tue, 14 Aug 2012 08:49:56 +1200 X-Google-Sender-Auth: mymbTyhBnQJEoBzk0OYGA0pL6ck Message-ID: From: Andrew Thompson To: Luigi Rizzo Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkzNBiugAe94cdNeqHKsSPF+BbEgm/XOLS3Xkudj/TWjAE9MWrYAv1lmehPFmWgja5q2S0X Cc: current@freebsd.org Subject: Re: rate-limited [kernel] debugging messages ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Aug 2012 20:49:58 -0000 On 14 August 2012 08:56, Luigi Rizzo wrote: > In my kernel stuff i tend to define debugging macros of the form > > #define ND(format, ...) do {} while (0) > #define D(format, ...) do { } while (0) > > so it is convenient to comment them out when not needed anymore. > > I have recently tried the following rate-limited version, where the > first parameter indicates how many lines per second are output at most > > /* rate limited, lps indicates how many per second */ > #define RD(lps, format, ...) \ > do { \ > static int t0, cnt; \ > if (t0 != time_second) { \ > t0 = time_second; \ > cnt = 0; \ > } \ > if (cnt++ < lps) \ > D(format, ##__VA_ARGS__); \ > } while (0) > > I was wondering if people have better suggestions or perhaps there > are already similar macros used by other parts of the kernel. > See ppsratecheck(), it does most of that already. Andrew