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: <20250801193537.1149-1-sj@kernel.org>
Date: Fri,  1 Aug 2025 12:35:37 -0700
From: SeongJae Park <sj@...nel.org>
To: Sidhartha Kumar <sidhartha.kumar@...cle.com>
Cc: SeongJae Park <sj@...nel.org>,
	linux-kernel@...r.kernel.org,
	linux-mm@...ck.org,
	akpm@...ux-foundation.org,
	willy@...radead.org,
	vbabka@...e.cz,
	jannh@...gle.com,
	pfalcato@...e.de,
	lorenzo.stoakes@...cle.com,
	Liam.Howlett@...cle.com
Subject: Re: [PATCH] mm/nommu: convert kobjsize() to folios

On Thu, 31 Jul 2025 20:26:29 +0000 Sidhartha Kumar <sidhartha.kumar@...cle.com> wrote:

> Simple folio conversion to remove a user of PageSlab() and
> PageCompound().
> 
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@...cle.com>

I have a trivial comment below, but since it is just a trivial one that I don't
really care,

Reviewed-by: SeongJae Park <sj@...nel.org>

> ---
>  mm/nommu.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/nommu.c b/mm/nommu.c
> index 07504d666d6a..a00f8fc316c1 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -64,7 +64,7 @@ const struct vm_operations_struct generic_file_vm_ops = {
>   */
>  unsigned int kobjsize(const void *objp)
>  {
> -	struct page *page;
> +	struct folio *folio;
>  
>  	/*
>  	 * If the object we have should not have ksize performed on it,
> @@ -73,22 +73,22 @@ unsigned int kobjsize(const void *objp)
>  	if (!objp || !virt_addr_valid(objp))
>  		return 0;
>  
> -	page = virt_to_head_page(objp);
> +	folio = virt_to_folio(objp);
>  
>  	/*
>  	 * If the allocator sets PageSlab, we know the pointer came from
>  	 * kmalloc().
>  	 */
> -	if (PageSlab(page))
> +	if (folio_test_slab(folio))
>  		return ksize(objp);
>  
>  	/*
> -	 * If it's not a compound page, see if we have a matching VMA
> +	 * If it's not a compound folio, see if we have a matching VMA

Nit.  I think "a large folio" rather than "a compound folio" is more consistent
and easier to read/understand.  No strong opinion, though.

>  	 * region. This test is intentionally done in reverse order,
>  	 * so if there's no VMA, we still fall through and hand back
> -	 * PAGE_SIZE for 0-order pages.
> +	 * PAGE_SIZE for 0-order folios.
>  	 */
> -	if (!PageCompound(page)) {
> +	if (!folio_test_large(folio)) {
>  		struct vm_area_struct *vma;
>  
>  		vma = find_vma(current->mm, (unsigned long)objp);
> @@ -100,7 +100,7 @@ unsigned int kobjsize(const void *objp)
>  	 * The ksize() function is only guaranteed to work for pointers
>  	 * returned by kmalloc(). So handle arbitrary pointers here.
>  	 */
> -	return page_size(page);
> +	return folio_size(folio);
>  }
>  
>  void vfree(const void *addr)
> -- 
> 2.43.0


Thanks,
SJ

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ