Linux s390 Architecture development
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: xu.xin@linux.dev
Cc: acme@kernel.org, adrian.hunter@intel.com, agordeev@linux.ibm.com,
	akpm@linux-foundation.org, alexander.shishkin@linux.intel.com,
	apopple@nvidia.com, baohua@kernel.org,
	baolin.wang@linux.alibaba.com, borntraeger@linux.ibm.com,
	byungchul@sk.com, chengming.zhou@linux.dev, dev.jain@arm.com,
	gerald.schaefer@linux.ibm.com, gor@linux.ibm.com,
	gourry@gourry.net, harry@kernel.org, hca@linux.ibm.com,
	irogers@google.com, james.clark@linaro.org, jannh@google.com,
	jolsa@kernel.org, joshua.hahnjy@gmail.com, kas@kernel.org,
	lance.yang@linux.dev, liam@infradead.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-s390@vger.kernel.org, ljs@kernel.org, mark.rutland@arm.com,
	matthew.brost@intel.com, mhiramat@kernel.org, mhocko@suse.com,
	mingo@redhat.com, namhyung@kernel.org, nico.pache@linux.dev,
	oleg@redhat.com, peterz@infradead.org, riel@surriel.com,
	rppt@kernel.org, ryan.roberts@arm.com, surenb@google.com,
	svens@linux.ibm.com, usama.arif@linux.dev, vbabka@kernel.org,
	ying.huang@linux.alibaba.com, ziy@nvidia.com,
	xialonglong2025@163.com
Subject: Re: [PATCH v2 2/4] mm: make folio_walk_start()'s locking asserts scalable
Date: Sun, 22 Nov 2026 17:28:45 +0100	[thread overview]
Message-ID: <aaed2661-8dfe-4b72-84f1-3fe9f4a962e9@kernel.org> (raw)
In-Reply-To: <20261102132927.301921-1-xu.xin@linux.dev>

On 11/2/26 14:29, xu.xin@linux.dev wrote:
> From: Xu Xin <xu.xin@linux.dev>
> 
> Add an additional member 'walk_lock' to folio_walk to indicate
> locking requirements for the walk. Similar to commit 49b0638502da0
> ("mm: enable page walking API to lock vmas during the walk").
> But no change is made on any existing locking behavior,
> all existing folio_walk_start() callers are currently still
> under mmap_read_lock() protection.
> 
> This change is prepared for the later patch to enable VMA locking
> asserts. folio_walk_start now operate under write-locked mmap_lock.
> With introduction of vma locks at the next patch, the vmas have to
> be locked as well during such walks to prevent concurrent page
> faults in these areas.
> 
> No functional change intended.
> 
> Signed-off-by: Xu Xin <xu.xin@linux.dev>
> ---
>  arch/s390/mm/fault.c     |  4 +++-
>  include/linux/pagewalk.h |  1 +
>  kernel/events/uprobes.c  |  4 +++-
>  mm/huge_memory.c         |  4 +++-
>  mm/ksm.c                 |  4 +++-
>  mm/migrate.c             |  8 ++++++--
>  mm/pagewalk.c            | 10 +++++++++-
>  mm/rmap.c                |  4 +++-
>  8 files changed, 31 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
> index 46d828926009..968f128a5232 100644
> --- a/arch/s390/mm/fault.c
> +++ b/arch/s390/mm/fault.c
> @@ -412,7 +412,9 @@ __context_unsafe(/* folio_walk_end() not instrumented */)
>  	unsigned long addr = get_fault_address(regs);
>  	struct mm_struct *mm = current->mm;
>  	struct vm_area_struct *vma;
> -	struct folio_walk fw;
> +	struct folio_walk fw = {
> +		.walk_lock  = PGWALK_RDLOCK,
> +	};
>  	struct folio *folio;
>  	int rc;
>  
> diff --git a/include/linux/pagewalk.h b/include/linux/pagewalk.h
> index 1c397be0d092..455428eaf1fc 100644
> --- a/include/linux/pagewalk.h
> +++ b/include/linux/pagewalk.h
> @@ -184,6 +184,7 @@ struct folio_walk {
>  	};
>  	/* private */
>  	spinlock_t *ptl;

Ah, Sashiko is right here that this belongs into the public part and should get
kerneldoc.

But, "struct folio_walk" is currently filled out exclusively by
folio_walk_start(), and I'd like to keep it like that.

Also, I don't enjoy that we are reusing PGWALK_* stuff here.

Why not add a second function variant that targets the per-vma lock and branches
internally to a common helper?

diff --git a/include/linux/pagewalk.h b/include/linux/pagewalk.h
index b41d7265c01bc..13f911e1db5d2 100644
--- a/include/linux/pagewalk.h
+++ b/include/linux/pagewalk.h
@@ -191,6 +191,10 @@ struct folio *folio_walk_start(struct folio_walk *fw,
                struct vm_area_struct *vma, unsigned long addr,
                folio_walk_flags_t flags);

+struct folio *folio_walk_start_vma_rdlock(struct folio_walk *fw,
+               struct vm_area_struct *vma, unsigned long addr,
+               folio_walk_flags_t flags);
+

Or something like that.

That also means that we don't have to touch any existing helpers and we won't
even have to store that type.


But now I wonder: do we need that *at all* ? It's effectively a parameter just
to do safety checks.

I'd just document locking requirements (mmap lock or per-vma read lock must be
held) and call it a day.

-- 
Cheers,

David

  parent reply	other threads:[~2026-11-22 16:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 13:24 [PATCH v2 0/4] mm/ksm: use per-VMA locking to reduce mmap_lock contention xu.xin
2026-11-02 13:28 ` [PATCH v2 1/4] mm/pagewalk: delete the unused member xu.xin
2026-11-03 13:31   ` sashiko-bot
2026-11-22 16:17   ` David Hildenbrand (Arm)
2026-11-02 13:29 ` [PATCH v2 2/4] mm: make folio_walk_start()'s locking asserts scalable xu.xin
2026-11-03 13:31   ` sashiko-bot
2026-11-22 16:14     ` David Hildenbrand (Arm)
2026-11-22 16:28   ` David Hildenbrand (Arm) [this message]
2026-11-02 13:29 ` [PATCH v2 3/4] mm/ksm: make break_ksm() more scalable xu.xin
2026-11-03 13:31   ` sashiko-bot
2026-11-02 13:31 ` [PATCH v2 4/4] ksm: add find_mergeable_vma_locked() to use per-VMA locking xu.xin
2026-11-03 13:31   ` sashiko-bot

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=aaed2661-8dfe-4b72-84f1-3fe9f4a962e9@kernel.org \
    --to=david@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=apopple@nvidia.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=byungchul@sk.com \
    --cc=chengming.zhou@linux.dev \
    --cc=dev.jain@arm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=gourry@gourry.net \
    --cc=harry@kernel.org \
    --cc=hca@linux.ibm.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jannh@google.com \
    --cc=jolsa@kernel.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kas@kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=matthew.brost@intel.com \
    --cc=mhiramat@kernel.org \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=nico.pache@linux.dev \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=riel@surriel.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.com \
    --cc=svens@linux.ibm.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=xialonglong2025@163.com \
    --cc=xu.xin@linux.dev \
    --cc=ying.huang@linux.alibaba.com \
    --cc=ziy@nvidia.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