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: <Z6nTWhmqkIwFzNMN@localhost.localdomain>
Date: Mon, 10 Feb 2025 11:22:18 +0100
From: Oscar Salvador <osalvador@...e.de>
To: Frank van der Linden <fvdl@...gle.com>
Cc: akpm@...ux-foundation.org, muchun.song@...ux.dev, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org, yuzhao@...gle.com,
	usamaarif642@...il.com, joao.m.martins@...cle.com,
	roman.gushchin@...ux.dev
Subject: Re: [PATCH v3 01/28] mm/cma: export total and free number of pages
 for CMA areas

On Thu, Feb 06, 2025 at 06:50:41PM +0000, Frank van der Linden wrote:
> In addition to the number of allocations and releases, system
> management software may like to be aware of the size of CMA
> areas, and how many pages are available in it. This information
> is currently not available, so export it in total_page and
> available_pages, respectively.
> 
> The name 'available_pages' was picked over 'free_pages' because
> 'free' implies that the pages are unused. But they might not
> be, they just haven't been used by cma_alloc
> 
> The number of available pages is tracked regardless of
> CONFIG_CMA_SYSFS, allowing for a few minor shortcuts in
> the code, avoiding bitmap operations.
> 
> Signed-off-by: Frank van der Linden <fvdl@...gle.com>

LGTM,

nit below

Reviewed-by: Oscar Salvador <osalvador@...e.de>

> ---
...  
> @@ -444,6 +445,14 @@ static struct page *__cma_alloc(struct cma *cma, unsigned long count,
>  
>  	for (;;) {
>  		spin_lock_irq(&cma->lock);
> +		/*
> +		 * If the request is larger than the available number
> +		 * of pages, stop right away.
> +		 */
> +		if (count > cma->available_count) {
> +			spin_unlock_irq(&cma->lock);
> +			break;
> +		}
>  		bitmap_no = bitmap_find_next_zero_area_off(cma->bitmap,
>  				bitmap_maxno, start, bitmap_count, mask,
>  				offset);
> @@ -452,6 +461,7 @@ static struct page *__cma_alloc(struct cma *cma, unsigned long count,
>  			break;
>  		}
>  		bitmap_set(cma->bitmap, bitmap_no, bitmap_count);
> +		cma->available_count -= count;

I wonder whether we should have a cma_bitmat_set, so available_count would be
touched in there.


-- 
Oscar Salvador
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ