All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lance Yang <lance.yang@linux.dev>
To: ljs@kernel.org
Cc: akpm@linux-foundation.org, surenb@google.com, liam@infradead.org,
	vbabka@kernel.org, shakeel.butt@linux.dev, david@kernel.org,
	ziy@nvidia.com, baolin.wang@linux.alibaba.com,
	nico.pache@linux.dev, ryan.roberts@arm.com, dev.jain@arm.com,
	baohua@kernel.org, lance.yang@linux.dev, usama.arif@linux.dev,
	kas@kernel.org, rppt@kernel.org, mhocko@suse.com,
	xu.xin16@zte.com.cn, chengming.zhou@linux.dev, jannh@google.com,
	pfalcato@suse.de, riel@surriel.com, harry@kernel.org,
	chrisl@kernel.org, kasong@tencent.com, shikemeng@huaweicloud.com,
	nphamcs@gmail.com, baoquan.he@linux.dev, youngjun.park@lge.com,
	peterx@redhat.com, muchun.song@linux.dev, osalvador@suse.de,
	matthew.brost@intel.com, joshua.hahnjy@gmail.com,
	rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net,
	ying.huang@linux.alibaba.com, apopple@nvidia.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	trintaeoitogc@gmail.com
Subject: Re: [PATCH v3 2/3] mm: implement and use vma_has_anon_rmap(), silence KCSAN
Date: Sun, 20 Sep 2026 20:25:28 +0800	[thread overview]
Message-ID: <20260920122528.8344-1-lance.yang@linux.dev> (raw)
In-Reply-To: <20260917-vma-is-faulted-v3-2-5c22314a72e7@kernel.org>


On Thu, Sep 17, 2026 at 08:47:42PM +0100, Lorenzo Stoakes (ARM) wrote:
>Provide a function to abstract the common task of checking whether
>a VMA has an anonymous reverse mapping associated with it.
>
>If the VMA is attached, a VMA or mmap lock must be held when calling this
>function.
>
>For an attached, anonymous, VMA:
>
>          Transition          |              VMA/mmap Lock state
> -----------------------------|-------------------------------------------
>   No anon rmap to anon rmap  | Write lock/read lock + mm->page_table_lock
>   Anon rmap to no anon rmap  | Write lock
>
>vma_has_anon_rmap() never provides a false positive (the lock precludes
>it), but if only a read lock is held, a negative result must be re-checked
>with mm->page_table_lock held.
>
>A VMA obtains an anonymous reverse mapping when first faulted or forked
>and it is removed when it is freed.
>
>Detached VMAs cannot be concurrently manipulated as they are removed from
>the maple tree so require no guarantees.
>
>Use data_race() to silence KCSAN about non-existent data races between
>concurrent vma->anon_vma read/write on optimistic fault tests.
>
>Update the core VMA merge/split, rmap, mremap, KSM, fork,
>khugepaged and fault preparation callers which test vma->anon_vma directly
>to use vma_has_anon_rmap() instead.
>
>Finally, update comments that reference anon_vma to reference the anon rmap
>instead.
>
>Since the lockless read in reusable_anon_vma() is doing more than checking
>whether the VMA has anon rmap - it is returning the anon_vma to be used on
>fault - do not alter it.
>
>There is one odd one out - file_backed_vma_is_retractable() - which holds
>neither a VMA nor mmap lock and is stabilised by the file rmap lock only,
>so simply add a comment to explain why it's necessary.
>
>Reported-by: Guilherme Giacomo Simoes <trintaeoitogc@gmail.com>
>Closes: https://lore.kernel.org/all/20260829100034.423064-1-trintaeoitogc@gmail.com/
>Closes: https://lore.kernel.org/all/20260909115723.528501-1-trintaeoitogc@gmail.com/
>Reviewed-by: Pedro Falcato <pfalcato@suse.de>
>Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
>Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
>---

Nothing jumped out at me,

Reviewed-by: Lance Yang <lance.yang@linux.dev>


  parent reply	other threads:[~2026-09-20 12:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 19:47 [PATCH v3 0/3] mm: implement and use vma_has_anon_rmap(), silence KCSAN Lorenzo Stoakes (ARM)
2026-09-17 19:47 ` [PATCH v3 1/3] mm/vma: const-ify vma_assert_stabilised() and associated functions Lorenzo Stoakes (ARM)
2026-09-17 20:28   ` Zi Yan
2026-09-18 10:17   ` Kiryl Shutsemau
2026-09-18 10:59   ` Pedro Falcato
2026-09-18 12:05   ` David Hildenbrand (Arm)
2026-09-20 12:20   ` Lance Yang
2026-09-17 19:47 ` [PATCH v3 2/3] mm: implement and use vma_has_anon_rmap(), silence KCSAN Lorenzo Stoakes (ARM)
2026-09-18 12:06   ` David Hildenbrand (Arm)
2026-09-20 12:25   ` Lance Yang [this message]
2026-09-17 19:47 ` [PATCH v3 3/3] mm: update comments to refer to anon rmap rather than anon_vma Lorenzo Stoakes (ARM)
2026-09-17 20:43   ` Zi Yan
2026-09-18 13:49     ` Lorenzo Stoakes (ARM)
2026-09-18 11:31   ` Pedro Falcato
2026-09-18 13:47     ` Lorenzo Stoakes (ARM)
2026-09-18 12:07   ` David Hildenbrand (Arm)
2026-09-20 12:26   ` Lance Yang

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=20260920122528.8344-1-lance.yang@linux.dev \
    --to=lance.yang@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=byungchul@sk.com \
    --cc=chengming.zhou@linux.dev \
    --cc=chrisl@kernel.org \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=gourry@gourry.net \
    --cc=harry@kernel.org \
    --cc=jannh@google.com \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kas@kernel.org \
    --cc=kasong@tencent.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nico.pache@linux.dev \
    --cc=nphamcs@gmail.com \
    --cc=osalvador@suse.de \
    --cc=peterx@redhat.com \
    --cc=pfalcato@suse.de \
    --cc=rakie.kim@sk.com \
    --cc=riel@surriel.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=shakeel.butt@linux.dev \
    --cc=shikemeng@huaweicloud.com \
    --cc=surenb@google.com \
    --cc=trintaeoitogc@gmail.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=xu.xin16@zte.com.cn \
    --cc=ying.huang@linux.alibaba.com \
    --cc=youngjun.park@lge.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 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.