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]
Date: Tue, 13 Feb 2024 08:47:02 -0800
From: "Darrick J. Wong" <djwong@...nel.org>
To: "Pankaj Raghav (Samsung)" <kernel@...kajraghav.com>
Cc: linux-xfs@...r.kernel.org, linux-fsdevel@...r.kernel.org,
	mcgrof@...nel.org, gost.dev@...sung.com, akpm@...ux-foundation.org,
	kbusch@...nel.org, chandan.babu@...cle.com, p.raghav@...sung.com,
	linux-kernel@...r.kernel.org, hare@...e.de, willy@...radead.org,
	linux-mm@...ck.org, david@...morbit.com
Subject: Re: [RFC v2 06/14] readahead: rework loop in
 page_cache_ra_unbounded()

On Tue, Feb 13, 2024 at 10:37:05AM +0100, Pankaj Raghav (Samsung) wrote:
> From: Hannes Reinecke <hare@...e.de>
> 
> Rework the loop in page_cache_ra_unbounded() to advance with
> the number of pages in a folio instead of just one page at a time.
> 
> Signed-off-by: Hannes Reinecke <hare@...e.de>
> Co-developed-by: Pankaj Raghav <p.raghav@...sung.com>
> Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>

Acked-by: Darrick J. Wong <djwong@...nel.org>

--D

> ---
>  mm/readahead.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/readahead.c b/mm/readahead.c
> index 5e1ec7705c78..13b62cbd3b79 100644
> --- a/mm/readahead.c
> +++ b/mm/readahead.c
> @@ -213,7 +213,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
>  	struct address_space *mapping = ractl->mapping;
>  	unsigned long index = readahead_index(ractl);
>  	gfp_t gfp_mask = readahead_gfp_mask(mapping);
> -	unsigned long i;
> +	unsigned long i = 0;
>  
>  	/*
>  	 * Partway through the readahead operation, we will have added
> @@ -231,7 +231,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
>  	/*
>  	 * Preallocate as many pages as we will need.
>  	 */
> -	for (i = 0; i < nr_to_read; i++) {
> +	while (i < nr_to_read) {
>  		struct folio *folio = xa_load(&mapping->i_pages, index + i);
>  
>  		if (folio && !xa_is_value(folio)) {
> @@ -244,8 +244,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
>  			 * not worth getting one just for that.
>  			 */
>  			read_pages(ractl);
> -			ractl->_index++;
> -			i = ractl->_index + ractl->_nr_pages - index - 1;
> +			ractl->_index += folio_nr_pages(folio);
> +			i = ractl->_index + ractl->_nr_pages - index;
>  			continue;
>  		}
>  
> @@ -257,13 +257,14 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
>  			folio_put(folio);
>  			read_pages(ractl);
>  			ractl->_index++;
> -			i = ractl->_index + ractl->_nr_pages - index - 1;
> +			i = ractl->_index + ractl->_nr_pages - index;
>  			continue;
>  		}
>  		if (i == nr_to_read - lookahead_size)
>  			folio_set_readahead(folio);
>  		ractl->_workingset |= folio_test_workingset(folio);
> -		ractl->_nr_pages++;
> +		ractl->_nr_pages += folio_nr_pages(folio);
> +		i += folio_nr_pages(folio);
>  	}
>  
>  	/*
> -- 
> 2.43.0
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ