From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Barry Song <baohua@kernel.org>
Cc: Zicheng Wang <wangzicheng@honor.com>,
Chuanhua Han <hanchuanhua802@gmail.com>,
Suren Baghdasaryan <surenb@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, tao.wangtao@honor.com, zhangji1@honor.com,
Yu Zhao <yuzhao@google.com>,
Kalesh Singh <kaleshsingh@google.com>,
Kairui Song <kasong@tencent.com>, Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
Baoquan He <baoquan.he@linux.dev>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
David Hildenbrand <david@kernel.org>,
liam@infradead.org, Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
Pedro Falcato <pfalcato@suse.de>, Jann Horn <jannh@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
linux-doc@vger.kernel.org, Matthew Wilcox <willy@infradead.org>,
Hugh Dickins <hughd@google.com>,
Ridong Chen <ridong.chen@linux.dev>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 0/5] mm/mglru: walk page tables under per-VMA locks
Date: Fri, 4 Dec 2026 11:21:59 +0000 [thread overview]
Message-ID: <axKhUdzhlqgs4DNY@gremlin> (raw)
In-Reply-To: <CAGsJ_4xbvgmZ-prxJh7ejnPw1CuCpEMNE6FBD6_DV4DJyMRWng@mail.gmail.com>
On Fri, Dec 04, 2026 at 06:43:33PM +0800, Barry Song wrote:
> On Fri, Dec 4, 2026 at 6:39 PM Zicheng Wang <wangzicheng@honor.com> wrote:
> >
> > Hi Suren, Chuanhua, Lorenzo,
> >
> > We hit the same stalls (140-250ms mmap/munmap/mprotect waits on
> > SurfaceFlinger and Launcher) and have a measurement that may be
> > relevant to the try_lock_next_vma() direction.
> >
> > In 3 dogfood user traces we picked for this problem, each with janky
> > frames over 500ms, a direct reclaim task doing the aging walk holds
> > mmap_lock for 140-250ms. Over 99% of that hold is spent runnable,
> > waiting to be scheduled; the aging walk itself runs for less than 1ms.
> > Each trace has thousands of direct reclaim events inside the jank window.
> >
> > A finer lock narrows who waits, but not how long. The walker runs with
> > preemption enabled while holding the lock, so a round can be preempted
> > mid-way and the lock is then held for the whole scheduling delay.
> >
> > Since the aging walk itself is already fast (<1ms), could we simply
> > disable preemption during the walk's lock-hold window instead of
> > changing the lock? We are testing a ~60-line prototype (no new lock or API)
> > and will send the patch and data separately—mainly wondering whether
> > you would prefer bounding that non-preemptible window at PUD or PMD
> > granularity.
>
> Hi Zicheng,
>
> Disabling preemption for 1 ms is unlikely to fly upstream, as
> that's simply too long. Now imagine 200 threads doing direct
> reclaim, each in a different memcg. That could result in a
> cumulative preemption-disabled time of 200 ms.
Yup :) In general we don't disable preemption unless we have to, and in general
I think when you look to a solution like this it's typically indicative that the
abstraction level of the proposed fix is wrong, i.e. you're asking the wrong
question :)
IOW this suggests that holding the VMA lock is the right solution.
Since (as I gather) Suren is looking to provide try_lock_next_vma() and update
the BPF code to reflect this (Suren - let me know if this is accurate), I
suggest you wait for this work.
Another point to be cautious of here is that a pure-VMA lock walk of VMAs is
very fiddly - you control nothing about what the _other_ VMAs are doing
i.e. have no stability on that, so you may observe unexpected things in a
traversal.
Suren has written a lot about this into the VMA lock work around /proc/$pid/maps
(in both comments and commit msgs and what is asserted in self tests) so I
suggest having a look at that code in the meantime to assess what would need to
be taken into account in this approach.
--
Cheers, Lorenzo
next prev parent reply other threads:[~2026-12-04 11:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 13:11 [RFC PATCH 0/5] mm/mglru: walk page tables under per-VMA locks Chuanhua Han
2026-12-01 13:11 ` [RFC PATCH 1/5] mm/mmap_lock: add vma_start_read_rcu() helper Chuanhua Han
2026-12-01 13:24 ` Lorenzo Stoakes (ARM)
2026-12-02 1:24 ` chuanhua han
2026-12-02 2:49 ` Suren Baghdasaryan
2026-12-02 4:20 ` chuanhua han
2026-12-02 9:10 ` Lorenzo Stoakes (ARM)
2026-12-02 13:07 ` chuanhua han
2026-12-01 13:11 ` [RFC PATCH 2/5] mm/mglru: split the VMA flag checks out of should_skip_vma() Chuanhua Han
2026-12-01 13:11 ` [RFC PATCH 3/5] mm/mglru: walk page tables under per-VMA locks Chuanhua Han
2026-12-01 13:11 ` [RFC PATCH 4/5] mm/mglru: hand off VMA locks without dropping the PTE lock Chuanhua Han
2026-12-01 13:11 ` [RFC PATCH 5/5] mm/mglru: update the docs for the per-VMA lock walk Chuanhua Han
2026-12-04 10:38 ` [RFC PATCH 0/5] mm/mglru: walk page tables under per-VMA locks Zicheng Wang
2026-12-04 10:43 ` Barry Song
2026-12-04 11:21 ` Lorenzo Stoakes (ARM) [this message]
2026-12-04 16:55 ` chuanhua han
2026-12-04 18:20 ` Suren Baghdasaryan
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=axKhUdzhlqgs4DNY@gremlin \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=hanchuanhua802@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=jannh@google.com \
--cc=kaleshsingh@google.com \
--cc=kasong@tencent.com \
--cc=liam@infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=pfalcato@suse.de \
--cc=qi.zheng@linux.dev \
--cc=rdunlap@infradead.org \
--cc=ridong.chen@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=skhan@linuxfoundation.org \
--cc=surenb@google.com \
--cc=tao.wangtao@honor.com \
--cc=vbabka@kernel.org \
--cc=wangzicheng@honor.com \
--cc=weixugc@google.com \
--cc=willy@infradead.org \
--cc=yuanchu@google.com \
--cc=yuzhao@google.com \
--cc=zhangji1@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