From: "Darrick J. Wong" <djwong@kernel.org>
To: "Pankaj Raghav (Samsung)" <kernel@pankajraghav.com>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
mcgrof@kernel.org, gost.dev@samsung.com,
akpm@linux-foundation.org, kbusch@kernel.org,
chandan.babu@oracle.com, p.raghav@samsung.com,
linux-kernel@vger.kernel.org, hare@suse.de, willy@infradead.org,
linux-mm@kvack.org, david@fromorbit.com
Subject: Re: [RFC v2 07/14] readahead: allocate folios with mapping_min_order in ra_(unbounded|order)
Date: Tue, 13 Feb 2024 08:47:10 -0800 [thread overview]
Message-ID: <20240213164710.GY6184@frogsfrogsfrogs> (raw)
In-Reply-To: <20240213093713.1753368-8-kernel@pankajraghav.com>
On Tue, Feb 13, 2024 at 10:37:06AM +0100, Pankaj Raghav (Samsung) wrote:
> From: Pankaj Raghav <p.raghav@samsung.com>
>
> Allocate folios with at least mapping_min_order in
> page_cache_ra_unbounded() and page_cache_ra_order() as we need to
> guarantee a minimum order in the page cache.
>
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Acked-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
> mm/readahead.c | 30 ++++++++++++++++++++++++++----
> 1 file changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/mm/readahead.c b/mm/readahead.c
> index 13b62cbd3b79..a361fba18674 100644
> --- a/mm/readahead.c
> +++ b/mm/readahead.c
> @@ -214,6 +214,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
> unsigned long index = readahead_index(ractl);
> gfp_t gfp_mask = readahead_gfp_mask(mapping);
> unsigned long i = 0;
> + unsigned int min_nrpages = mapping_min_folio_nrpages(mapping);
>
> /*
> * Partway through the readahead operation, we will have added
> @@ -235,6 +236,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
> struct folio *folio = xa_load(&mapping->i_pages, index + i);
>
> if (folio && !xa_is_value(folio)) {
> + long nr_pages = folio_nr_pages(folio);
> +
> /*
> * Page already present? Kick off the current batch
> * of contiguous pages before continuing with the
> @@ -244,19 +247,31 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
> * not worth getting one just for that.
> */
> read_pages(ractl);
> - ractl->_index += folio_nr_pages(folio);
> +
> + /*
> + * Move the ractl->_index by at least min_pages
> + * if the folio got truncated to respect the
> + * alignment constraint in the page cache.
> + *
> + */
> + if (mapping != folio->mapping)
> + nr_pages = min_nrpages;
> +
> + VM_BUG_ON_FOLIO(nr_pages < min_nrpages, folio);
> + ractl->_index += nr_pages;
> i = ractl->_index + ractl->_nr_pages - index;
> 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,
> gfp_mask) < 0) {
> folio_put(folio);
> read_pages(ractl);
> - ractl->_index++;
> + ractl->_index += min_nrpages;
> i = ractl->_index + ractl->_nr_pages - index;
> continue;
> }
> @@ -516,6 +531,7 @@ void page_cache_ra_order(struct readahead_control *ractl,
> {
> struct address_space *mapping = ractl->mapping;
> pgoff_t index = readahead_index(ractl);
> + unsigned int min_order = mapping_min_folio_order(mapping);
> pgoff_t limit = (i_size_read(mapping->host) - 1) >> PAGE_SHIFT;
> pgoff_t mark = index + ra->size - ra->async_size;
> int err = 0;
> @@ -542,11 +558,17 @@ void page_cache_ra_order(struct readahead_control *ractl,
> if (index & ((1UL << order) - 1))
> order = __ffs(index);
> /* Don't allocate pages past EOF */
> - while (index + (1UL << order) - 1 > limit)
> + while (order > min_order && index + (1UL << order) - 1 > limit)
> order--;
> /* THP machinery does not support order-1 */
> if (order == 1)
> order = 0;
> +
> + if (order < min_order)
> + order = min_order;
> +
> + VM_BUG_ON(index & ((1UL << order) - 1));
> +
> err = ra_alloc_folio(ractl, index, mark, order, gfp);
> if (err)
> break;
> --
> 2.43.0
>
>
next prev parent reply other threads:[~2024-02-13 16:47 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 9:36 [RFC v2 00/14] enable bs > ps in XFS Pankaj Raghav (Samsung)
2024-02-13 9:37 ` [RFC v2 01/14] fs: Allow fine-grained control of folio sizes Pankaj Raghav (Samsung)
2024-02-13 12:03 ` Hannes Reinecke
2024-02-13 16:34 ` Darrick J. Wong
2024-02-13 21:05 ` Pankaj Raghav (Samsung)
2024-02-13 21:29 ` Darrick J. Wong
2024-02-14 19:00 ` Matthew Wilcox
2024-02-15 10:34 ` Pankaj Raghav (Samsung)
2024-02-14 18:49 ` Matthew Wilcox
2024-02-15 10:21 ` Pankaj Raghav (Samsung)
2024-02-13 9:37 ` [RFC v2 02/14] filemap: align the index to mapping_min_order in the page cache Pankaj Raghav (Samsung)
2024-02-13 12:20 ` Hannes Reinecke
2024-02-13 21:13 ` Pankaj Raghav (Samsung)
2024-02-13 22:00 ` Dave Chinner
2024-02-13 9:37 ` [RFC v2 03/14] filemap: use mapping_min_order while allocating folios Pankaj Raghav (Samsung)
2024-02-13 14:58 ` Hannes Reinecke
2024-02-13 16:38 ` Darrick J. Wong
2024-02-13 22:05 ` Dave Chinner
2024-02-14 10:13 ` Pankaj Raghav (Samsung)
2024-02-13 9:37 ` [RFC v2 04/14] readahead: set file_ra_state->ra_pages to be at least mapping_min_order Pankaj Raghav (Samsung)
2024-02-13 14:59 ` Hannes Reinecke
2024-02-13 16:46 ` Darrick J. Wong
2024-02-13 22:09 ` Dave Chinner
2024-02-14 13:32 ` Pankaj Raghav (Samsung)
2024-02-14 13:53 ` Pankaj Raghav (Samsung)
2024-02-13 9:37 ` [RFC v2 05/14] readahead: align index to mapping_min_order in ondemand_ra and force_ra Pankaj Raghav (Samsung)
2024-02-13 15:00 ` Hannes Reinecke
2024-02-13 16:46 ` Darrick J. Wong
2024-02-13 22:29 ` Dave Chinner
2024-02-14 15:10 ` Pankaj Raghav (Samsung)
2024-02-13 9:37 ` [RFC v2 06/14] readahead: rework loop in page_cache_ra_unbounded() Pankaj Raghav (Samsung)
2024-02-13 16:47 ` Darrick J. Wong
2024-02-13 9:37 ` [RFC v2 07/14] readahead: allocate folios with mapping_min_order in ra_(unbounded|order) Pankaj Raghav (Samsung)
2024-02-13 15:01 ` Hannes Reinecke
2024-02-13 16:47 ` Darrick J. Wong [this message]
2024-02-13 9:37 ` [RFC v2 08/14] mm: do not split a folio if it has minimum folio order requirement Pankaj Raghav (Samsung)
2024-02-13 15:02 ` Hannes Reinecke
2024-02-13 9:37 ` [RFC v2 09/14] mm: Support order-1 folios in the page cache Pankaj Raghav (Samsung)
2024-02-13 15:03 ` Hannes Reinecke
2024-02-13 9:37 ` [RFC v2 10/14] iomap: fix iomap_dio_zero() for fs bs > system page size Pankaj Raghav (Samsung)
2024-02-13 15:06 ` Hannes Reinecke
2024-02-13 16:30 ` Darrick J. Wong
2024-02-13 21:27 ` Pankaj Raghav (Samsung)
2024-02-13 21:30 ` Darrick J. Wong
2024-02-14 15:13 ` Pankaj Raghav (Samsung)
2024-02-13 9:37 ` [RFC v2 11/14] xfs: expose block size in stat Pankaj Raghav (Samsung)
2024-02-13 16:27 ` Darrick J. Wong
2024-02-13 21:32 ` Pankaj Raghav (Samsung)
2024-02-13 9:37 ` [RFC v2 12/14] xfs: make the calculation generic in xfs_sb_validate_fsb_count() Pankaj Raghav (Samsung)
2024-02-13 16:26 ` Darrick J. Wong
2024-02-13 21:48 ` Pankaj Raghav (Samsung)
2024-02-13 22:44 ` Dave Chinner
2024-02-14 15:51 ` Pankaj Raghav (Samsung)
2024-02-13 9:37 ` [RFC v2 13/14] xfs: add an experimental CONFIG_XFS_LBS option Pankaj Raghav (Samsung)
2024-02-13 16:39 ` Darrick J. Wong
2024-02-13 21:19 ` Dave Chinner
2024-02-13 21:54 ` Pankaj Raghav (Samsung)
2024-02-13 22:45 ` Dave Chinner
2024-02-13 9:37 ` [RFC v2 14/14] xfs: enable block size larger than page size support Pankaj Raghav (Samsung)
2024-02-13 16:20 ` Darrick J. Wong
2024-02-14 16:40 ` Pankaj Raghav (Samsung)
2024-02-13 21:34 ` Dave Chinner
2024-02-14 16:35 ` Pankaj Raghav (Samsung)
2024-02-15 22:17 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240213164710.GY6184@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chandan.babu@oracle.com \
--cc=david@fromorbit.com \
--cc=gost.dev@samsung.com \
--cc=hare@suse.de \
--cc=kbusch@kernel.org \
--cc=kernel@pankajraghav.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=p.raghav@samsung.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).