linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Chunyan Zhang <zhangchunyan@iscas.ac.cn>,
	linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>, Conor Dooley <conor@kernel.org>,
	Deepak Gupta <debug@rivosinc.com>,
	Ved Shanbhogue <ved@rivosinc.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Xu <peterx@redhat.com>, Arnd Bergmann <arnd@arndb.de>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	"Liam R . Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>, Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>
Subject: Re: [PATCH V13 2/6] mm: userfaultfd: Add pgtable_supports_uffd_wp()
Date: Wed, 17 Sep 2025 09:25:09 +0200	[thread overview]
Message-ID: <bc87f2a8-7a9c-4416-9106-bdf4b98e40a8@redhat.com> (raw)
In-Reply-To: <20250917033703.1695933-3-zhangchunyan@iscas.ac.cn>

On 17.09.25 05:36, Chunyan Zhang wrote:
> Some platforms can customize the PTE/PMD entry uffd-wp bit making
> it unavailable even if the architecture provides the resource.
> This patch adds a macro API that allows architectures to define their
> specific implementations to check if the uffd-wp bit is available
> on which device the kernel is running.
> 
> Also this patch is removing "ifdef CONFIG_HAVE_ARCH_USERFAULTFD_WP" and
> "ifdef CONFIG_PTE_MARKER_UFFD_WP" in favor of pgtable_supports_uffd_wp()
> and uffd_supports_wp_marker() checks respectively that default to
> IS_ENABLED(CONFIG_HAVE_ARCH_USERFAULTFD_WP) and
> "IS_ENABLED(CONFIG_HAVE_ARCH_USERFAULTFD_WP) && IS_ENABLED(CONFIG_PTE_MARKER_UFFD_WP)"
> if not overridden by the architecture, no change in behavior is expected.
> 
> Acked-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn>
> ---

[...]

Taking another look.

>   /* mm helpers */
> @@ -415,68 +475,24 @@ static inline bool vma_has_uffd_without_event_remap(struct vm_area_struct *vma)
>   	return false;
>   }
>   
> -#endif /* CONFIG_USERFAULTFD */
> -
>   static inline bool userfaultfd_wp_use_markers(struct vm_area_struct *vma)
>   {
> -	/* Only wr-protect mode uses pte markers */
> -	if (!userfaultfd_wp(vma))
>   		return false;

Isn't this indented one level too deep?

> -
> -	/* File-based uffd-wp always need markers */
> -	if (!vma_is_anonymous(vma))
> -		return true;
> -
> -	/*
> -	 * Anonymous uffd-wp only needs the markers if WP_UNPOPULATED
> -	 * enabled (to apply markers on zero pages).
> -	 */
> -	return userfaultfd_wp_unpopulated(vma);
>   }
>   
>   static inline bool pte_marker_entry_uffd_wp(swp_entry_t entry)
>   {
> -#ifdef CONFIG_PTE_MARKER_UFFD_WP
> -	return is_pte_marker_entry(entry) &&
> -	    (pte_marker_get(entry) & PTE_MARKER_UFFD_WP);
> -#else
> -	return false;
> -#endif
> +		return false;

Same here.

>   }
>   
>   static inline bool pte_marker_uffd_wp(pte_t pte)
>   {
> -#ifdef CONFIG_PTE_MARKER_UFFD_WP
> -	swp_entry_t entry;
> -
> -	if (!is_swap_pte(pte))
>   		return false;

Same here.

> -
> -	entry = pte_to_swp_entry(pte);
> -
> -	return pte_marker_entry_uffd_wp(entry);
> -#else
> -	return false;
> -#endif
>   }


-- 
Cheers

David / dhildenb


  reply	other threads:[~2025-09-17  7:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-17  3:36 [PATCH V13 0/6] riscv: mm: Add soft-dirty and uffd-wp support Chunyan Zhang
2025-09-17  3:36 ` [PATCH V13 1/6] mm: softdirty: Add pgtable_supports_soft_dirty() Chunyan Zhang
2025-09-17  3:36 ` [PATCH V13 2/6] mm: userfaultfd: Add pgtable_supports_uffd_wp() Chunyan Zhang
2025-09-17  7:25   ` David Hildenbrand [this message]
2025-09-17  9:20     ` Chunyan Zhang
2025-09-17  3:37 ` [PATCH V13 3/6] riscv: Add RISC-V Svrsw60t59b extension support Chunyan Zhang
2025-09-17  3:37 ` [PATCH V13 4/6] riscv: mm: Add soft-dirty page tracking support Chunyan Zhang
2025-09-17  3:37 ` [PATCH V13 5/6] riscv: mm: Add userfaultfd write-protect support Chunyan Zhang
2025-09-17  3:37 ` [PATCH V13 6/6] dt-bindings: riscv: Add Svrsw60t59b extension description Chunyan Zhang
2025-09-18  0:10   ` Krzysztof Kozlowski

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=bc87f2a8-7a9c-4416-9106-bdf4b98e40a8@redhat.com \
    --to=david@redhat.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=axelrasmussen@google.com \
    --cc=brauner@kernel.org \
    --cc=conor@kernel.org \
    --cc=debug@rivosinc.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=ved@rivosinc.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yuanchu@google.com \
    --cc=zhang.lyra@gmail.com \
    --cc=zhangchunyan@iscas.ac.cn \
    /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;
as well as URLs for NNTP newsgroup(s).