From: Petr Mladek <pmladek@suse.com>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
John Ogness <john.ogness@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-kernel@vger.kernel.org, Michal Hocko <mhocko@kernel.org>
Subject: Re: ratelimit API: was: [RFC PATCH] printk: Introduce "store now but print later" prefix.
Date: Wed, 20 Mar 2019 16:25:16 +0100 [thread overview]
Message-ID: <20190320152516.3gbmaj5xoyxkivyt@pathway.suse.cz> (raw)
In-Reply-To: <0fc95fee-8b6e-5ff0-9a91-9e0ea66028f3@i-love.sakura.ne.jp>
On Thu 2019-03-07 03:24:25, Tetsuo Handa wrote:
> On 2019/03/06 19:04, Petr Mladek wrote:
> > I did not mean serializing. I meant to avoid printing the warnings
> > at all until OOM killer finishes its job.
>
> But your ratelimit_reset() below requires serializing.
>
> >
> >
> >> Also, both nopage_rs in warn_alloc() and oom_rs in oom_kill_process() are not
> >> working well. This is because ___ratelimit() function assumes that operations
> >> to be ratelimited complete fast enough to be able to repeat many times within
> >> a second. If one operation to be ratelimited takes many seconds (or even
> >> minutes), ___ratelimit() becomes always true and can not ratelimit at all.
> >
> > The current ratelimiting is time driven. We might need an event
> > driven variant. It might even be done with the current
> > implementation if we add something like:
> >
> > void ratelimit_reset(struct ratelimit_state *rs)
> > {
> > unsigned long flags;
> >
> > raw_spin_irqsave(&rs->lock, flags);
> >
> > rs->begin = jiffies;
> > rs->printed = 0;
> >
> > raw_spin_unlock_irqrestore(&rs->lock, flags);
> > }
> >
> > We could call this when some event "solved" the problem.
>
> This requires serialization among threads using "rs". I already
> proposed ratelimit_reset() for memcg's OOM problem at
> https://lkml.kernel.org/r/201810180246.w9I2koi3011358@www262.sakura.ne.jp
> but it was not accepted.
IMHO, the main problem was that the patch tried to work around
the ratelimit API weakness by a custom code.
I believe that using an improved/extended ratelimit API with
a sane semantic would be more acceptable.
> > It means that it makes sense to enable the related
> > ratelimited messages again because they would describe
> > another problem.
>
> ___ratelimit() could also check number of not-yet-flushed
> printk() records (e.g. log_next_seq - console_seq <= $some_threshold).
The number is almost useless without more information, for example,
how fast the consoles are, how many lines will get filtered
by a console_loglevel, if the console_sem owner is sleeping,
how many messages are being added by other CPUs.
I believe that we do not really need it. The ratelimit_reset()
user should know when the messages can get skipped because
they describe the same situation again and again.
Best Regards,
Petr
next prev parent reply other threads:[~2019-03-20 15:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-23 4:42 [RFC PATCH] printk: Introduce "store now but print later" prefix Tetsuo Handa
2019-03-04 3:22 ` Sergey Senozhatsky
2019-03-04 11:40 ` Tetsuo Handa
2019-03-04 12:09 ` Sergey Senozhatsky
2019-03-04 14:23 ` Petr Mladek
2019-03-04 14:37 ` Sergey Senozhatsky
2019-03-05 1:23 ` Tetsuo Handa
2019-03-05 7:52 ` Sergey Senozhatsky
2019-03-05 12:57 ` Michal Hocko
2019-03-06 10:04 ` Petr Mladek
2019-03-06 14:27 ` Sergey Senozhatsky
2019-03-06 18:24 ` Tetsuo Handa
2019-03-15 10:49 ` Tetsuo Handa
2019-03-20 15:04 ` Petr Mladek
2019-03-20 15:25 ` Petr Mladek [this message]
2019-03-21 8:13 ` ratelimit API: was: " Tetsuo Handa
2019-03-21 8:49 ` Michal Hocko
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=20190320152516.3gbmaj5xoyxkivyt@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).