From: Michal Hocko <mhocko@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Zhaoyang Huang <huangzhaoyang@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] ringbuffer: Don't choose the process with adj equal OOM_SCORE_ADJ_MIN
Date: Tue, 10 Apr 2018 14:27:06 +0200 [thread overview]
Message-ID: <20180410122706.GH21835@dhcp22.suse.cz> (raw)
In-Reply-To: <20180410082316.263d34ec@gandalf.local.home>
On Tue 10-04-18 08:23:16, Steven Rostedt wrote:
> On Tue, 10 Apr 2018 12:49:02 +0200
> Michal Hocko <mhocko@kernel.org> wrote:
>
> > But you do realize that what you are proposing is by no means any safer,
> > don't you? The memory allocated for the ring buffer is _not_ accounted
> > to any process and as such it is not considered by the oom killer when
> > picking up an oom victim so you are quite likely to pick up an innocent
> > process to be killed. So basically you are risking an allocation runaway
> > completely hidden from the OOM killer. Now, the downside of the patch is
> > that the OOM_SCORE_ADJ_MIN task might get killed which is something that
> > shouldn't happen because it is a contract. I would call this an
> > unsolvable problem and a inherent broken design of the oom disabled
> > task. So far I haven't heard a single _argument_ why supporting such a
> > weird cornercase is desirable when your application can trivial do
> >
> > fork(); set_oom_score_adj(); exec("echo $VAR > $RINGBUFFER_FILE")
>
> We could do this as a compromise:
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index c9cb9767d49b..40c2e0a56c51 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -1185,6 +1185,12 @@ static int __rb_allocate_pages(long nr_pages, struct list_head *pages, int cpu)
> */
> mflags = GFP_KERNEL | __GFP_RETRY_MAYFAIL;
>
> + /* If we can't OOM this task, then only allocate without reclaim */
> + if (unlikely(current->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)) {
> + mflags = GFP_KERNEL | __GFP_NORETRY;
> + user_thread = false; /* do not set oom_origin */
> + }
> +
> /*
> * If a user thread allocates too much, and si_mem_available()
> * reports there's enough memory, even though there is not.
>
> This way, if one sets OOM_SCORE_ADJ_MIN, then we wont set oom_origin
> for the task, but we also wont try hard to allocate memory if there is
> nothing immediately available.
I would rather that the code outside of MM not touch implementation
details like OOM_SCORE_ADJ_MIN. It is really hard to get rid of abusers
whenever you try to change something in MM then. Especially when the
usecase is quite dubious.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2018-04-10 12:27 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-08 2:16 Zhaoyang Huang
2018-04-08 3:48 ` Steven Rostedt
2018-04-08 5:54 ` Zhaoyang Huang
2018-04-08 12:47 ` Steven Rostedt
2018-04-09 0:56 ` Zhaoyang Huang
2018-04-09 13:49 ` Steven Rostedt
2018-04-10 0:32 ` Zhaoyang Huang
2018-04-10 2:32 ` Zhaoyang Huang
2018-04-10 3:12 ` Steven Rostedt
2018-04-10 3:41 ` Zhaoyang Huang
2018-04-10 6:14 ` Michal Hocko
2018-04-10 6:39 ` Zhaoyang Huang
2018-04-10 7:49 ` Michal Hocko
2018-04-10 8:04 ` Zhaoyang Huang
2018-04-10 8:12 ` Michal Hocko
2018-04-10 8:38 ` Zhaoyang Huang
2018-04-10 9:01 ` Michal Hocko
2018-04-10 9:32 ` Zhaoyang Huang
2018-04-10 9:51 ` Zhaoyang Huang
2018-04-10 10:49 ` Michal Hocko
2018-04-10 12:23 ` Steven Rostedt
2018-04-10 12:27 ` Michal Hocko [this message]
2018-04-10 12:36 ` Steven Rostedt
2018-04-10 13:13 ` Steven Rostedt
2018-04-10 13:14 ` Steven Rostedt
2018-04-10 16:45 ` Joel Fernandes
2018-04-10 18:00 ` Steven Rostedt
2018-04-10 18:39 ` Joel Fernandes
2018-04-10 19:05 ` Steven Rostedt
2018-04-11 7:48 ` Zhaoyang Huang
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=20180410122706.GH21835@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=huangzhaoyang@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®