From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: zhongjinji@honor.com, linux-mm@kvack.org,
akpm@linux-foundation.org, mhocko@suse.com, rientjes@google.com,
shakeel.butt@linux.dev, npache@redhat.com,
linux-kernel@vger.kernel.org, tglx@linutronix.de,
mingo@redhat.com, peterz@infradead.org, dvhart@infradead.org,
dave@stgolabs.net, andrealmeid@igalia.com, liulu.liu@honor.com,
feng.han@honor.com
Subject: Re: [PATCH v4 3/3] mm/oom_kill: Have the OOM reaper and exit_mmap() traverse the maple tree in opposite orders
Date: Fri, 15 Aug 2025 12:05:44 -0400 [thread overview]
Message-ID: <tnuqbtlwvxem6l26vhdg2dfxuefdyd5a4xth6wjyhm3ea3uwcp@kvimpn576u25> (raw)
In-Reply-To: <26larxehoe3a627s4fxsqghriwctays4opm4hhme3uk7ybjc5r@pmwh4s4yv7lm>
* Liam R. Howlett <Liam.Howlett@oracle.com> [250815 10:41]:
> * zhongjinji@honor.com <zhongjinji@honor.com> [250814 09:56]:
> > From: zhongjinji <zhongjinji@honor.com>
...
> > diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> > index 7ae4001e47c1..602d6836098a 100644
> > --- a/mm/oom_kill.c
> > +++ b/mm/oom_kill.c
> > @@ -517,7 +517,7 @@ static bool __oom_reap_task_mm(struct mm_struct *mm)
> > {
> > struct vm_area_struct *vma;
> > bool ret = true;
> > - VMA_ITERATOR(vmi, mm, 0);
> > + VMA_ITERATOR(vmi, mm, ULONG_MAX);
> >
> > /*
> > * Tell all users of get_user/copy_from_user etc... that the content
> > @@ -527,7 +527,12 @@ static bool __oom_reap_task_mm(struct mm_struct *mm)
> > */
> > set_bit(MMF_UNSTABLE, &mm->flags);
> >
> > - for_each_vma(vmi, vma) {
> > + /*
> > + * When two tasks unmap the same vma at the same time, they may contend for the
> > + * pte spinlock. To avoid traversing the same vma as exit_mmap unmap, traverse
> > + * the vma maple tree in reverse order.
> > + */
> > + for_each_vma_reverse(vmi, vma) {
>
> How is this possible? Both need the same lock..? What part of
> exit_mmap() will race here?
I see, exit_mmap() and the oom both use unmap_page_range() under the
mmap read lock, so they can race but since they'll contend on the pte
lock it doesn't really matter.
This is so rare, I don't think this is worth fixing.
Thanks,
Liam
next prev parent reply other threads:[~2025-08-15 16:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 13:55 [PATCH v4 0/3] mm/oom_kill: Only delay OOM reaper for processes using robust futexes zhongjinji
2025-08-14 13:55 ` [PATCH v4 1/3] futex: Introduce function process_has_robust_futex() zhongjinji
2025-08-14 13:55 ` [PATCH v4 2/3] mm/oom_kill: Only delay OOM reaper for processes using robust futexes zhongjinji
2025-08-15 14:41 ` Lorenzo Stoakes
2025-08-18 14:14 ` zhongjinji
2025-08-17 19:37 ` Michal Hocko
2025-08-18 12:08 ` zhongjinji
2025-08-19 10:49 ` Michal Hocko
2025-08-20 2:53 ` Davidlohr Bueso
2025-08-21 18:13 ` Michal Hocko
2025-08-21 19:45 ` Davidlohr Bueso
2025-08-14 13:55 ` [PATCH v4 3/3] mm/oom_kill: Have the OOM reaper and exit_mmap() traverse the maple tree in opposite orders zhongjinji
2025-08-14 23:09 ` Andrew Morton
2025-08-15 16:32 ` zhongjinji
2025-08-15 17:52 ` gio
2025-08-15 17:53 ` gio
2025-08-15 14:29 ` Lorenzo Stoakes
2025-08-15 15:01 ` Lorenzo Stoakes
2025-08-15 17:37 ` zhongjinji
2025-08-19 15:18 ` zhongjinji
2025-08-21 9:32 ` Lorenzo Stoakes
2025-08-25 14:12 ` zhongjinji
2025-08-15 14:41 ` Liam R. Howlett
2025-08-15 16:05 ` Liam R. Howlett [this message]
2025-08-14 23:13 ` [PATCH v4 0/3] mm/oom_kill: Only delay OOM reaper for processes using robust futexes Andrew Morton
2025-08-15 17:06 ` zhongjinji
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=tnuqbtlwvxem6l26vhdg2dfxuefdyd5a4xth6wjyhm3ea3uwcp@kvimpn576u25 \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=andrealmeid@igalia.com \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=feng.han@honor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liulu.liu@honor.com \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=npache@redhat.com \
--cc=peterz@infradead.org \
--cc=rientjes@google.com \
--cc=shakeel.butt@linux.dev \
--cc=tglx@linutronix.de \
--cc=zhongjinji@honor.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