public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Khalid Aziz <khalid@fc.hp.com>
To: Eli Carter <eli.carter@inet.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: rate limiting error messages
Date: Thu, 29 Mar 2001 10:15:30 -0700	[thread overview]
Message-ID: <3AC36DB2.64C9A3D1@fc.hp.com> (raw)
In-Reply-To: <3AC3659D.BD56E640@inet.com>

Eli Carter wrote:
> 
> Can someone point me to a "standard way" of doing rate limiting of error
> messages in the kernel?
> 
> TIA,
> 
> Eli
> -----------------------.           Rule of Accuracy: When working toward
> Eli Carter             |            the solution of a problem, it always
> eli.carter(at)inet.com `------------------ helps if you know the answer.

Here is how it is done in IA-64 kernel:

static int
within_logging_rate_limit (void)
{
        static unsigned long count, last_time;

        if (count > 5 && jiffies - last_time > 5*HZ)
                count = 0;
        if (++count < 5) {
                last_time = jiffies;
                return 1;
        }
        return 0;

}

If this fundction returns 0, error messages have been rate limited. This
code is not MP-safe. So, if you need your code to be MP-safe, you may
need to rewrite it somewhat.

-- 
Khalid

====================================================================
Khalid Aziz                             Linux Development Laboratory
(970)898-9214                                        Hewlett-Packard
khalid@fc.hp.com                                    Fort Collins, CO

      reply	other threads:[~2001-03-29 17:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-29 16:41 rate limiting error messages Eli Carter
2001-03-29 17:15 ` Khalid Aziz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3AC36DB2.64C9A3D1@fc.hp.com \
    --to=khalid@fc.hp.com \
    --cc=eli.carter@inet.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox