linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Jann Horn <jannh@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: Re: [PATCH] mm, oom: OOM sysrq should always kill a process
Date: Thu, 6 Jan 2022 09:26:18 +0100	[thread overview]
Message-ID: <Ydanqi1u7OKh56r4@dhcp22.suse.cz> (raw)
In-Reply-To: <20220105175115.605074-1-jannh@google.com>

On Wed 05-01-22 18:51:15, Jann Horn wrote:
> The OOM kill sysrq (alt+sysrq+F) should allow the user to kill the
> process with the highest OOM badness with a single execution.
> 
> However, at the moment, the OOM kill can bail out if an OOM notifier
> (e.g. the i915 one) says that it reclaimed a tiny amount of memory
> from somewhere. That's probably not what the user wants.
> 
> As documented in struct oom_control, order == -1 means the oom kill is
> required by sysrq. So check for that, and if it's true, don't bail out
> no matter what the OOM notifiers say.

I agree that it is suboptimal to disable sysrq+f because of notfiers
because the OOM invocation is not a direct result of the OOM situation
but rather an admin will. We already kill a new task even if an oom
victim is still pending.

> Signed-off-by: Jann Horn <jannh@google.com>

with a minor update as below
Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/oom_kill.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 1ddabefcfb5a..dc645cbc6e0d 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -1051,13 +1051,14 @@ EXPORT_SYMBOL_GPL(unregister_oom_notifier);
>  bool out_of_memory(struct oom_control *oc)
>  {
>  	unsigned long freed = 0;
> +	bool sysrq_forced = oc->order == -1;
>  
>  	if (oom_killer_disabled)
>  		return false;
>  
>  	if (!is_memcg_oom(oc)) {
>  		blocking_notifier_call_chain(&oom_notify_list, 0, &freed);
> -		if (freed > 0)
> +		if (freed > 0 && !sysrq_forced)
>  			/* Got some memory back in the last second. */
>  			return true;
>  	}

is_sysrq_oom(oc) is a more appropriate way to check this.

> 
> base-commit: c9e6606c7fe92b50a02ce51dda82586ebdf99b48
> -- 
> 2.34.1.448.ga2b2bfdf31-goog

-- 
Michal Hocko
SUSE Labs


      reply	other threads:[~2022-01-06  8:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05 17:51 Jann Horn
2022-01-06  8:26 ` 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=Ydanqi1u7OKh56r4@dhcp22.suse.cz \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=schwidefsky@de.ibm.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