Re: [PATCH v3 01/28] mm/cma: export total and free number of pages for CMA areas

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

LGTM,

nit below

Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>

> ---
...  
> @@ -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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux