Skip to contentSkip to conversation

rate limiting error messages

DISCUSSION Eli Carter 2 participants 2 messages Mar 29, 2001

lore
Share & tools
lore

Eli Carter

author
#0 lore raw

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.

#1 lore raw
Quoted 10 lines · Eli Carter

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.

Signature · 6 lines
Khalid

====================================================================
Khalid Aziz                             Linux Development Laboratory
(970)898-9214                                        Hewlett-Packard
[email protected]                                    Fort Collins, CO