All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Michal Hocko <mhocko@suse.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, Jiayuan Chen <jiayuan.chen@shopee.com>,
	Zhou Yingfu <yingfu.zhou@shopee.com>,
	David Hildenbrand <david@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	David Rientjes <rientjes@google.com>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/oom_kill: fix hung tasks queued on mmap_lock behind a long reap
Date: Tue, 15 Sep 2026 16:13:11 +0800	[thread overview]
Message-ID: <3c8d1d8e-0e67-4d1a-b73d-4eadd6266aa6@linux.dev> (raw)
In-Reply-To: <aqjsPW92SgcHONKO@tiehlicka>


On 9/15/26 2:57 PM, Michal Hocko wrote:
> On Mon 14-09-26 20:35:33, Andrew Morton wrote:
>> On Mon, 14 Sep 2026 20:36:16 +0200 Michal Hocko <mhocko@suse.com> wrote:
>>
>>>> Call Trace:
>>>>   <TASK>
>>>>   __schedule+0x487/0x1870
>>>>   schedule+0x28/0xb0
>>>>   schedule_preempt_disabled+0x16/0x30
>>>>   rwsem_down_write_slowpath+0x1d4/0x750
>>>>   down_write+0x60/0x70
>>>>   __ksm_exit+0xb4/0x230
>>>>   __mmput+0x12c/0x150
>>>>   mmput+0x1e/0x30
>>>>   do_exit+0x283/0xa30
>>>>   do_group_exit+0x34/0x90
>>>>   get_signal+0x952/0x960
>>>>   arch_do_signal_or_restart+0x41/0x250
>>>>   exit_to_user_mode_loop+0xd3/0x560
>>>>   do_syscall_64+0x385/0x470
>>>>   </TASK>
>>>>
>>>> KSM is just the one LTP happened to hit: __khugepaged_exit() has the
>>>> same write lock cycle ahead of exit_mmap().
>>> Why is this a practical problem we need to care about? It is kind of
>>> natural that the oom victim exit path might race with the oom reaper. They
>>> share the same lock that is mutualy exclusive. The whole point of the
>>> reaper is to ensure there is a forward progress achieved. So before we
>>> start modifying this let's talk about any practical/real life problems.

Hi Michal, Andrew

Agreed, the hung task warning itself is harmless, especially for a dying
task. The real problems are what sits behind it.

With a 500G swapped-out victim the reap takes ~600s, and for all of it:

1. The victim cannot exit. __ksm_exit() needs mmap_lock for write and
  queues behind the reaper, so the process stays alive in D state for
  10 minutes and whoever waits for it (parent, container runtime)
  waits too.

2. ksmd and khugepaged stall. Once that writer is queued, their
  mmap_read_lock() on this mm queues as well, so both daemons stop
  for the whole system for the same ~600s.

With the patch they wait for one 1G chunk at most, and since exit_mmap()
now frees alongside the reaper, the victim's memory is gone in 264s
instead of ~600s. The reaper still never blocks on mmap_lock and still
makes progress on every pass, so forward progress is not changed.



>> If this situation is expected, unavoidable etc then perhaps the best
>> change is to periodically poke the hung-task detector?
> Right. Reaping 10s of GBs worth of VMAs might take some time indeed and
> that could trigger the hung task detector.
>


  reply	other threads:[~2026-09-15  8:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 11:32 [PATCH] mm/oom_kill: fix hung tasks queued on mmap_lock behind a long reap Jiayuan Chen
2026-09-14 14:32 ` David Hildenbrand (Arm)
2026-09-14 18:36 ` Michal Hocko
2026-09-15  3:35   ` Andrew Morton
2026-09-15  6:57     ` Michal Hocko
2026-09-15  8:13       ` Jiayuan Chen [this message]
2026-09-15  8:23         ` Michal Hocko
2026-09-15  8:44           ` Jiayuan Chen
2026-09-15  9:07             ` 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=3c8d1d8e-0e67-4d1a-b73d-4eadd6266aa6@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=jiayuan.chen@shopee.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.com \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=yingfu.zhou@shopee.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.