Re: [PATCH 1/2] random: Omit double-printing ratelimit messages

From: Dmitry Safonov
Date: Thu May 10 2018 - 15:50:15 EST


On Thu, 2018-05-10 at 15:40 -0400, Theodore Y. Ts'o wrote:
> On Thu, May 10, 2018 at 07:37:40PM +0100, Dmitry Safonov wrote:
> >
> > Ok, then what's the purpose of those messages?
> > : pr_notice("random: %d get_random_xx warning(s) missed "
> > : "due to ratelimiting\n",
> > : unseeded_warning.missed);
> > : pr_notice("random: %d urandom warning(s) missed "
> > : "due to ratelimiting\n",
> > : urandom_warning.missed);
> >
> > I thought you want to print the summary after initializing random,
> > not once per second?
>
> Yes, and that's what is happening today. The "output lines
> suppressed
> due to ratelimiting" message is only printed out by
> printk_ratelimit()
> function, which we are *not* using.

random uses __ratelimit() which calls ___ratelimit() with a function
name. Depending on !RATELIMIT_MSG_ON_RELEASE it prints how many
messages were suppressed every ratelimit interval (1 second for random)
and flushes ratelimit_state::missed:

:if (time_is_before_jiffies(rs->begin + rs->interval)) {
: if (rs->missed) {
: if (!(rs->flags & RATELIMIT_MSG_ON_RELEASE)) {
: printk_deferred(KERN_WARNING
: "%s: %d callbacks suppressed\n",
: func, rs->missed);
: rs->missed = 0;
: }
: }
: rs->begin = jiffies;
: rs->printed = 0;
:}

--
Thanks,
Dmitry