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: <20240724124845.614c03ad39f8af3729cebee6@linux-foundation.org>
Date: Wed, 24 Jul 2024 12:48:45 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Frank van der Linden <fvdl@...gle.com>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/cma: export total and free number of pages for CMA
 areas

On Tue,  9 Jul 2024 16:30:53 +0000 Frank van der Linden <fvdl@...gle.com> 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.
> 
> ...
>
> @@ -382,7 +383,7 @@ static void cma_debug_show_areas(struct cma *cma)
>  {
>  	unsigned long next_zero_bit, next_set_bit, nr_zero;
>  	unsigned long start = 0;
> -	unsigned long nr_part, nr_total = 0;
> +	unsigned long nr_part;
>  	unsigned long nbits = cma_bitmap_maxno(cma);
>  
>  	spin_lock_irq(&cma->lock);
> @@ -394,12 +395,12 @@ static void cma_debug_show_areas(struct cma *cma)
>  		next_set_bit = find_next_bit(cma->bitmap, nbits, next_zero_bit);
>  		nr_zero = next_set_bit - next_zero_bit;
>  		nr_part = nr_zero << cma->order_per_bit;
> -		pr_cont("%s%lu@%lu", nr_total ? "+" : "", nr_part,
> +		pr_cont("%s%lu@%lu", start ? "+" : "", nr_part,
>  			next_zero_bit);
> -		nr_total += nr_part;
>  		start = next_zero_bit + nr_zero;
>  	}

Can you please explain the above change?

> -	pr_cont("=> %lu free of %lu total pages\n", nr_total, cma->count);
> +	pr_cont("=> %lu free of %lu total pages\n", cma->available_count,
> +			cma->count);
>  	spin_unlock_irq(&cma->lock);
>  }
>  
> @@ -446,6 +447,10 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
>  
>  	for (;;) {
>  		spin_lock_irq(&cma->lock);
> +		if (count > cma->available_count) {

Right here would be a nice place for a comment?

> +			spin_unlock_irq(&cma->lock);
> +			break;
> +		}
>  		bitmap_no = bitmap_find_next_zero_area_off(cma->bitmap,
>  				bitmap_maxno, start, bitmap_count, mask,
>  				offset);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ