lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 21 Dec 2023 04:40:23 +0000
From: Matthew Wilcox <willy@...radead.org>
To: David Hildenbrand <david@...hat.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Hugh Dickins <hughd@...gle.com>,
	Ryan Roberts <ryan.roberts@....com>,
	Yin Fengwei <fengwei.yin@...el.com>,
	Mike Kravetz <mike.kravetz@...cle.com>,
	Muchun Song <muchun.song@...ux.dev>, Peter Xu <peterx@...hat.com>
Subject: Re: [PATCH v2 04/40] mm/rmap: introduce and use
 hugetlb_try_dup_anon_rmap()

On Wed, Dec 20, 2023 at 11:44:28PM +0100, David Hildenbrand wrote:
> hugetlb rmap handling differs quite a lot from "ordinary" rmap code.
> For example, hugetlb currently only supports entire mappings, and treats
> any mapping as mapped using a single "logical PTE". Let's move it out
> of the way so we can overhaul our "ordinary" rmap.
> implementation/interface.
> 
> So let's introduce and use hugetlb_try_dup_anon_rmap() to make all
> hugetlb handling use dedicated hugetlb_* rmap functions.
> 
> Add sanity checks that we end up with the right folios in the right
> functions.
> 
> Note that is_device_private_page() does not apply to hugetlb.
> 
> Reviewed-by: Yin Fengwei <fengwei.yin@...el.com>
> Reviewed-by: Ryan Roberts <ryan.roberts@....com>
> Signed-off-by: David Hildenbrand <david@...hat.com>

Reviewed-by: Matthew Wilcox (Oracle) <willy@...radead.org>

> +static inline bool folio_needs_cow_for_dma(struct vm_area_struct *vma,
> +					  struct folio *folio)

I particularly like it that you introduced this.

> +static inline int hugetlb_try_dup_anon_rmap(struct folio *folio,
> +		struct vm_area_struct *vma)
> +{
> +	VM_WARN_ON_FOLIO(!folio_test_hugetlb(folio), folio);
> +	VM_WARN_ON_FOLIO(!folio_test_anon(folio), folio);
> +
> +	if (PageAnonExclusive(&folio->page)) {

I wonder if we need a folio_test_hugetlb_anon_exclusive() to make this
a little more ergonomic?

> +		if (unlikely(folio_needs_cow_for_dma(vma, folio)))
> +			return -EBUSY;
> +		ClearPageAnonExclusive(&folio->page);

... and set/clear variants.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ