From: Pankaj Raghav <kernel@pankajraghav.com>
To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: p.raghav@samsung.com, david@fromorbit.com, da.gomez@samsung.com,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
willy@infradead.org, djwong@kernel.org, linux-mm@kvack.org,
chandan.babu@oracle.com, mcgrof@kernel.org, gost.dev@samsung.com
Subject: [RFC 17/23] readahead: set the minimum ra size in get_(init|next)_ra
Date: Fri, 15 Sep 2023 20:38:42 +0200 [thread overview]
Message-ID: <20230915183848.1018717-18-kernel@pankajraghav.com> (raw)
In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com>
From: Luis Chamberlain <mcgrof@kernel.org>
Make sure the minimum ra size is based on mapping_min_order in
get_init_ra() and get_next_ra(). If request ra size is greater than
mapping_min_order of pages, align it to mapping_min_order of pages.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
mm/readahead.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/mm/readahead.c b/mm/readahead.c
index fb5ff180c39e..7c2660815a01 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -357,9 +357,17 @@ void force_page_cache_ra(struct readahead_control *ractl,
* for small size, x 4 for medium, and x 2 for large
* for 128k (32 page) max ra
* 1-2 page = 16k, 3-4 page 32k, 5-8 page = 64k, > 8 page = 128k initial
+ *
+ * For higher order address space requirements we ensure no initial reads
+ * are ever less than the min number of pages required.
+ *
+ * We *always* cap the max io size allowed by the device.
*/
-static unsigned long get_init_ra_size(unsigned long size, unsigned long max)
+static unsigned long get_init_ra_size(unsigned long size,
+ unsigned int min_order,
+ unsigned long max)
{
+ unsigned int min_nrpages = 1UL << min_order;
unsigned long newsize = roundup_pow_of_two(size);
if (newsize <= max / 32)
@@ -369,6 +377,15 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max)
else
newsize = max;
+ if (newsize < min_nrpages) {
+ if (min_nrpages <= max)
+ newsize = min_nrpages;
+ else
+ newsize = round_up(max, min_nrpages);
+ }
+
+ VM_BUG_ON(newsize & (min_nrpages - 1));
+
return newsize;
}
@@ -377,14 +394,19 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max)
* return it as the new window size.
*/
static unsigned long get_next_ra_size(struct file_ra_state *ra,
+ unsigned int min_order,
unsigned long max)
{
- unsigned long cur = ra->size;
+ unsigned int min_nrpages = 1UL << min_order;
+ unsigned long cur = max(ra->size, min_nrpages);
+
+ cur = round_down(cur, min_nrpages);
if (cur < max / 16)
return 4 * cur;
if (cur <= max / 2)
return 2 * cur;
+
return max;
}
--
2.40.1
next prev parent reply other threads:[~2023-09-15 18:44 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 18:38 [RFC 00/23] Enable block size > page size in XFS Pankaj Raghav
2023-09-15 18:38 ` [RFC 01/23] fs: Allow fine-grained control of folio sizes Pankaj Raghav
2023-09-15 19:03 ` Matthew Wilcox
2023-09-15 18:38 ` [RFC 02/23] pagemap: use mapping_min_order in fgf_set_order() Pankaj Raghav
2023-09-15 18:55 ` Matthew Wilcox
2023-09-20 7:46 ` Pankaj Raghav
2023-09-15 18:38 ` [RFC 03/23] filemap: add folio with at least mapping_min_order in __filemap_get_folio Pankaj Raghav
2023-09-15 19:00 ` Matthew Wilcox
2023-09-20 8:06 ` Pankaj Raghav
2023-09-15 18:38 ` [RFC 04/23] filemap: set the order of the index in page_cache_delete_batch() Pankaj Raghav
2023-09-15 19:43 ` Matthew Wilcox
2023-09-18 18:20 ` Luis Chamberlain
2023-09-15 18:38 ` [RFC 05/23] filemap: align index to mapping_min_order in filemap_range_has_page() Pankaj Raghav
2023-09-15 19:45 ` Matthew Wilcox
2023-09-18 18:25 ` Luis Chamberlain
2023-09-15 18:38 ` [RFC 06/23] mm: call xas_set_order() in replace_page_cache_folio() Pankaj Raghav
2023-09-15 19:46 ` Matthew Wilcox
2023-09-18 18:27 ` Luis Chamberlain
2023-09-15 18:38 ` [RFC 07/23] filemap: align the index to mapping_min_order in __filemap_add_folio() Pankaj Raghav
2023-09-15 19:48 ` Matthew Wilcox
2023-09-18 18:32 ` Luis Chamberlain
2023-09-15 18:38 ` [RFC 08/23] filemap: align the index to mapping_min_order in filemap_get_folios_tag() Pankaj Raghav
2023-09-15 19:50 ` Matthew Wilcox
2023-09-18 18:36 ` Luis Chamberlain
2023-09-15 18:38 ` [RFC 09/23] filemap: use mapping_min_order while allocating folios Pankaj Raghav
2023-09-15 19:54 ` Matthew Wilcox
2023-09-15 18:38 ` [RFC 10/23] filemap: align the index to mapping_min_order in filemap_get_pages() Pankaj Raghav
2023-09-15 18:38 ` [RFC 11/23] filemap: align the index to mapping_min_order in do_[a]sync_mmap_readahead Pankaj Raghav
2023-09-15 18:38 ` [RFC 12/23] filemap: align index to mapping_min_order in filemap_fault() Pankaj Raghav
2023-09-15 18:38 ` [RFC 13/23] readahead: set file_ra_state->ra_pages to be at least mapping_min_order Pankaj Raghav
2023-09-15 18:38 ` [RFC 14/23] readahead: allocate folios with mapping_min_order in ra_unbounded() Pankaj Raghav
2023-09-15 18:38 ` [RFC 15/23] readahead: align with mapping_min_order in force_page_cache_ra() Pankaj Raghav
2023-09-15 18:38 ` [RFC 16/23] readahead: add folio with at least mapping_min_order in page_cache_ra_order Pankaj Raghav
2023-09-15 18:38 ` Pankaj Raghav [this message]
2023-09-15 18:38 ` [RFC 18/23] readahead: align ra start and size to mapping_min_order in ondemand_ra() Pankaj Raghav
2023-09-15 18:38 ` [RFC 19/23] truncate: align index to mapping_min_order Pankaj Raghav
2023-09-15 18:38 ` [RFC 20/23] mm: round down folio split requirements Pankaj Raghav
2023-09-15 18:38 ` [RFC 21/23] xfs: expose block size in stat Pankaj Raghav
2023-09-15 18:38 ` [RFC 22/23] xfs: enable block size larger than page size support Pankaj Raghav
2023-09-15 18:38 ` [RFC 23/23] xfs: set minimum order folio for page cache based on blocksize Pankaj Raghav
2023-09-15 18:50 ` [RFC 00/23] Enable block size > page size in XFS Matthew Wilcox
2023-09-18 12:35 ` Pankaj Raghav
2023-09-17 22:05 ` Dave Chinner
2023-09-18 2:04 ` Luis Chamberlain
2023-09-18 5:07 ` Dave Chinner
2023-09-18 12:29 ` Pankaj Raghav
2023-09-19 11:56 ` Ritesh Harjani
2023-09-19 21:15 ` Luis Chamberlain
2023-09-21 3:00 ` Luis Chamberlain
2023-09-21 4:57 ` Luis Chamberlain
2023-09-21 6:03 ` Dave Chinner
2023-09-21 7:18 ` Luis Chamberlain
2023-09-21 7:20 ` Luis Chamberlain
2023-09-22 5:03 ` Dave Chinner
2023-09-22 19:38 ` Matthew Wilcox
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=20230915183848.1018717-18-kernel@pankajraghav.com \
--to=kernel@pankajraghav.com \
--cc=akpm@linux-foundation.org \
--cc=chandan.babu@oracle.com \
--cc=da.gomez@samsung.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=gost.dev@samsung.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).