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: <d0b77326-e93f-c1dc-c46c-1213bfafd7ee@suse.de>
Date:   Wed, 21 Jun 2023 10:59:03 +0200
From:   Hannes Reinecke <hare@...e.de>
To:     Pankaj Raghav <p.raghav@...sung.com>, willy@...radead.org,
        david@...morbit.com
Cc:     gost.dev@...sung.com, mcgrof@...nel.org, hch@....de,
        jwong@...nel.org, linux-fsdevel@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [RFC 2/4] filemap: use minimum order while allocating folios

On 6/21/23 10:38, Pankaj Raghav wrote:
> Add support to filemap and readahead to use the folio order set by
> mapping_min_folio_order().
> 
> Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>
> ---
>   mm/filemap.c   |  9 ++++++---
>   mm/readahead.c | 34 ++++++++++++++++++++++++----------
>   2 files changed, 30 insertions(+), 13 deletions(-)
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 3b73101f9f86..9dc8568e9336 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -1936,7 +1936,8 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
>   			gfp |= GFP_NOWAIT | __GFP_NOWARN;
>   		}
>   
> -		folio = filemap_alloc_folio(gfp, 0);
> +		folio = filemap_alloc_folio(gfp,
> +					    mapping_min_folio_order(mapping));
>   		if (!folio)
>   			return ERR_PTR(-ENOMEM);
>   
> @@ -2495,7 +2496,8 @@ static int filemap_create_folio(struct file *file,
>   	struct folio *folio;
>   	int error;
>   
> -	folio = filemap_alloc_folio(mapping_gfp_mask(mapping), 0);
> +	folio = filemap_alloc_folio(mapping_gfp_mask(mapping),
> +				    mapping_min_folio_order(mapping));
>   	if (!folio)
>   		return -ENOMEM;
>   
> @@ -3663,7 +3665,8 @@ static struct folio *do_read_cache_folio(struct address_space *mapping,
>   repeat:
>   	folio = filemap_get_folio(mapping, index);
>   	if (IS_ERR(folio)) {
> -		folio = filemap_alloc_folio(gfp, 0);
> +		folio = filemap_alloc_folio(gfp,
> +					    mapping_min_folio_order(mapping));
>   		if (!folio)
>   			return ERR_PTR(-ENOMEM);
>   		err = filemap_add_folio(mapping, folio, index, gfp);
> diff --git a/mm/readahead.c b/mm/readahead.c
> index 47afbca1d122..090b810ddeed 100644
> --- a/mm/readahead.c
> +++ b/mm/readahead.c
> @@ -245,7 +245,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
>   			continue;
>   		}
>   
> -		folio = filemap_alloc_folio(gfp_mask, 0);
> +		folio = filemap_alloc_folio(gfp_mask,
> +					    mapping_min_folio_order(mapping));
>   		if (!folio)
>   			break;
>   		if (filemap_add_folio(mapping, folio, index + i,
> @@ -259,7 +260,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
>   		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) - 1;
>   	}
>   
>   	/*
This is incomplete, as the loop above has some exit statements which 
blindly step backwards by one page.

I found it better to rework the 'for' into a 'while' loop; please check 
the attached patch.

Cheers,

Hannes

View attachment "0004-mm-readahead-rework-loop-in-page_cache_ra_unbounded.patch" of type "text/x-patch" (2285 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ