From: Michal Hocko <mhocko@kernel.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Johannes Weiner <hannes@cmpxchg.org>,
linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, guro@fb.com,
kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org,
rientjes@google.com, yang.s@alibaba-inc.com,
Andrew Morton <akpm@linux-foundation.org>,
Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
syzbot <syzbot+77e6b28a7a7106ad0def@syzkaller.appspotmail.com>
Subject: Re: [PATCH v3] mm: memcontrol: Don't flood OOM messages with no eligible task.
Date: Thu, 18 Oct 2018 13:23:58 +0200 [thread overview]
Message-ID: <20181018112358.GB18839@dhcp22.suse.cz> (raw)
In-Reply-To: <6bbb0449-1f22-4d05-9e2a-636965b7dbc6@i-love.sakura.ne.jp>
On Thu 18-10-18 19:37:18, Tetsuo Handa wrote:
> On 2018/10/18 15:55, Michal Hocko wrote:
> > On Thu 18-10-18 11:46:50, Tetsuo Handa wrote:
> >> This is essentially a ratelimit approach, roughly equivalent with:
> >>
> >> static DEFINE_RATELIMIT_STATE(oom_no_victim_rs, 60 * HZ, 1);
> >> oom_no_victim_rs.flags |= RATELIMIT_MSG_ON_RELEASE;
> >>
> >> if (__ratelimit(&oom_no_victim_rs)) {
> >> dump_header(oc, NULL);
> >> pr_warn("Out of memory and no killable processes...\n");
> >> oom_no_victim_rs.begin = jiffies;
> >> }
> >
> > Then there is no reason to reinvent the wheel. So use the standard
> > ratelimit approach. Or put it in other words, this place is no special
> > to any other that needs some sort of printk throttling. We surely do not
> > want an ad-hoc solutions all over the kernel.
>
> netdev_wait_allrefs() in net/core/dev.c is doing the same thing. Since
> out_of_memory() is serialized by oom_lock mutex, there is no need to use
> "struct ratelimit_state"->lock field. Plain "unsigned long" is enough.
That code probably predates generalized ratelimit api.
> > And once you realize that the ratelimit api is the proper one (put aside
> > any potential improvements in the implementation of this api) then you
> > quickly learn that we already do throttle oom reports and it would be
> > nice to unify that and ... we are back to a naked patch. So please stop
> > being stuborn and try to cooperate finally.
>
> I don't think that ratelimit API is the proper one, for I am touching
> "struct ratelimit_state"->begin field which is not exported by ratelimit API.
> But if you insist on ratelimit API version, I can tolerate with below one.
I just give up. I do not really see why you always have to make the code
more complex than necessary and squash different things together. This
is a complete kernel code development antipattern.
I am not goging to reply to this thread more but let me note that this
is beyond fun in any aspect I can think off (and yeah I have considered
dark sense of humor as well).
>
> mm/oom_kill.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index f10aa53..7c6118e 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -1106,6 +1106,12 @@ bool out_of_memory(struct oom_control *oc)
> select_bad_process(oc);
> /* Found nothing?!?! */
> if (!oc->chosen) {
> + static DEFINE_RATELIMIT_STATE(no_eligible_rs, 60 * HZ, 1);
> +
> + ratelimit_set_flags(&no_eligible_rs, RATELIMIT_MSG_ON_RELEASE);
> + if ((is_sysrq_oom(oc) || is_memcg_oom(oc)) &&
> + !__ratelimit(&no_eligible_rs))
> + return false;
> dump_header(oc, NULL);
> pr_warn("Out of memory and no killable processes...\n");
> /*
> @@ -1115,6 +1121,7 @@ bool out_of_memory(struct oom_control *oc)
> */
> if (!is_sysrq_oom(oc) && !is_memcg_oom(oc))
> panic("System is deadlocked on memory\n");
> + no_eligible_rs.begin = jiffies;
> }
> if (oc->chosen && oc->chosen != (void *)-1UL)
> oom_kill_process(oc, !is_memcg_oom(oc) ? "Out of memory" :
> --
> 1.8.3.1
--
Michal Hocko
SUSE Labs
prev parent reply other threads:[~2018-10-18 11:24 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-17 10:06 [PATCH v3] mm: memcontrol: Don't flood OOM messages with no eligible task Tetsuo Handa
2018-10-17 10:28 ` Michal Hocko
2018-10-17 11:17 ` Sergey Senozhatsky
2018-10-17 11:29 ` Michal Hocko
2018-10-18 2:46 ` Tetsuo Handa
2018-10-18 4:27 ` Sergey Senozhatsky
2018-10-18 5:26 ` Tetsuo Handa
2018-10-18 6:10 ` Sergey Senozhatsky
2018-10-18 7:56 ` Michal Hocko
2018-10-18 8:13 ` Sergey Senozhatsky
2018-10-18 11:58 ` Tetsuo Handa
2018-10-18 23:54 ` Sergey Senozhatsky
2018-10-19 10:35 ` Tetsuo Handa
2018-10-23 0:47 ` Sergey Senozhatsky
2018-10-23 8:37 ` Petr Mladek
2018-10-23 8:54 ` Michal Hocko
2018-10-18 14:30 ` Petr Mladek
2018-10-19 0:18 ` Tetsuo Handa
2018-10-23 8:21 ` Petr Mladek
2018-10-23 10:23 ` Tetsuo Handa
2018-10-18 6:55 ` Michal Hocko
2018-10-18 10:37 ` Tetsuo Handa
2018-10-18 11:23 ` Michal Hocko [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=20181018112358.GB18839@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=pmladek@suse.com \
--cc=rientjes@google.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=syzbot+77e6b28a7a7106ad0def@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=yang.s@alibaba-inc.com \
/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).