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]
Message-ID: <Zoa5nOkaUxmKiEIA@x1n>
Date: Thu, 4 Jul 2024 11:02:52 -0400
From: Peter Xu <peterx@...hat.com>
To: Oscar Salvador <osalvador@...e.de>
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-kernel@...r.kernel.org,
	linux-mm@...ck.org, Muchun Song <muchun.song@...ux.dev>,
	David Hildenbrand <david@...hat.com>, SeongJae Park <sj@...nel.org>,
	Miaohe Lin <linmiaohe@...wei.com>, Michal Hocko <mhocko@...e.com>,
	Matthew Wilcox <willy@...radead.org>,
	Christophe Leroy <christophe.leroy@...roup.eu>
Subject: Re: [PATCH 02/45] mm: Add {pmd,pud}_huge_lock helper

On Thu, Jul 04, 2024 at 06:30:49AM +0200, Oscar Salvador wrote:
> Deep down hugetlb and thp use the same lock for pud and pmd.
> Create two helpers that can be directly used by both of them,
> as they will be used in the generic pagewalkers.
> 
> Signed-off-by: Oscar Salvador <osalvador@...e.de>
> ---
>  include/linux/mm_inline.h | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
> index f4fe593c1400..93e3eb86ef4e 100644
> --- a/include/linux/mm_inline.h
> +++ b/include/linux/mm_inline.h
> @@ -9,6 +9,7 @@
>  #include <linux/string.h>
>  #include <linux/userfaultfd_k.h>
>  #include <linux/swapops.h>
> +#include <linux/hugetlb.h>
>  
>  /**
>   * folio_is_file_lru - Should the folio be on a file LRU or anon LRU?
> @@ -590,4 +591,30 @@ static inline bool vma_has_recency(struct vm_area_struct *vma)
>  	return true;
>  }
>  
> +static inline spinlock_t *pmd_huge_lock(pmd_t *pmd, struct vm_area_struct *vma)
> +{
> +	spinlock_t *ptl;
> +
> +	if (pmd_leaf(*pmd)) {
> +		ptl = pmd_lock(vma->vm_mm, pmd);
> +		if (pmd_leaf(*pmd))
> +			return ptl;
> +		spin_unlock(ptl);
> +	}
> +	return NULL;
> +}
> +
> +static inline spinlock_t *pud_huge_lock(pud_t *pud, struct vm_area_struct *vma)
> +{
> +	spinlock_t *ptl = pud_lock(vma->vm_mm, pud);
> +
> +	if (pud_leaf(*pud)) {
> +		ptl = pud_lock(vma->vm_mm, pud);
> +		if (pud_leaf(*pud))
> +			return ptl;
> +		spin_unlock(ptl);
> +	}
> +	return NULL;
> +}

IIRC I left similar comment before somewhere when we're discussing.. but we
may need to consider swap entries too.

I think it might be easier we stick with pxd_trans_huge_lock(), but some
slight modification on top: (1) rename them, perhaps s/trans_//g? (2) need
to also handle swap entry for puds (hugetlb migration entries, right now
pud_trans_huge_lock() didn't consider that).

Thanks,

-- 
Peter Xu


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ