diff mbox series

[05/13] readahead: set file_ra_state->ra_pages to be at least mapping_min_order

Message ID 20240226094936.2677493-6-kernel@pankajraghav.com (mailing list archive)
State New
Headers show
Series enable bs > ps in XFS | expand

Commit Message

Pankaj Raghav (Samsung) Feb. 26, 2024, 9:49 a.m. UTC
From: Luis Chamberlain <mcgrof@kernel.org>

Set the file_ra_state->ra_pages in file_ra_state_init() to be at least
mapping_min_order of pages if the bdi->ra_pages is less than that.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 mm/readahead.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Matthew Wilcox Feb. 26, 2024, 2:49 p.m. UTC | #1
On Mon, Feb 26, 2024 at 10:49:28AM +0100, Pankaj Raghav (Samsung) wrote:
> From: Luis Chamberlain <mcgrof@kernel.org>
> 
> Set the file_ra_state->ra_pages in file_ra_state_init() to be at least
> mapping_min_order of pages if the bdi->ra_pages is less than that.

Don't we rather want to round up to a multiple of mapping_min_nrpages?

>  file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping)
>  {
> +	unsigned int min_nrpages = mapping_min_folio_nrpages(mapping);
> +
>  	ra->ra_pages = inode_to_bdi(mapping->host)->ra_pages;
> +	if (ra->ra_pages < min_nrpages)
> +		ra->ra_pages = min_nrpages;
>  	ra->prev_pos = -1;
Pankaj Raghav (Samsung) Feb. 27, 2024, 12:42 p.m. UTC | #2
On Mon, Feb 26, 2024 at 02:49:04PM +0000, Matthew Wilcox wrote:
> On Mon, Feb 26, 2024 at 10:49:28AM +0100, Pankaj Raghav (Samsung) wrote:
> > From: Luis Chamberlain <mcgrof@kernel.org>
> > 
> > Set the file_ra_state->ra_pages in file_ra_state_init() to be at least
> > mapping_min_order of pages if the bdi->ra_pages is less than that.
> 
> Don't we rather want to round up to a multiple of mapping_min_nrpages?

Hmm. That will definitely be more explicit. We might be doing
multiple of min_nrpages now anyway, going beyond the ra_pages(if it 
is not a multiple of min_nrpages).

I will do this instead:

diff --git a/mm/readahead.c b/mm/readahead.c
index 73aef3f080ba..4e3a6f763f5c 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -138,11 +138,8 @@
 void
 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping)
 {
-       unsigned int min_nrpages = mapping_min_folio_nrpages(mapping);
-
-       ra->ra_pages = inode_to_bdi(mapping->host)->ra_pages;
-       if (ra->ra_pages < min_nrpages)
-               ra->ra_pages = min_nrpages;
+       ra->ra_pages = round_up(inode_to_bdi(mapping->host)->ra_pages,
+                               mapping_min_folio_nrpages(mapping));
        ra->prev_pos = -1;
 }

> 
> >  file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping)
> >  {
> > +	unsigned int min_nrpages = mapping_min_folio_nrpages(mapping);
> > +
> >  	ra->ra_pages = inode_to_bdi(mapping->host)->ra_pages;
> > +	if (ra->ra_pages < min_nrpages)
> > +		ra->ra_pages = min_nrpages;
> >  	ra->prev_pos = -1;
diff mbox series

Patch

diff --git a/mm/readahead.c b/mm/readahead.c
index 369c70e2be42..8a610b78d94b 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -138,7 +138,11 @@ 
 void
 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping)
 {
+	unsigned int min_nrpages = mapping_min_folio_nrpages(mapping);
+
 	ra->ra_pages = inode_to_bdi(mapping->host)->ra_pages;
+	if (ra->ra_pages < min_nrpages)
+		ra->ra_pages = min_nrpages;
 	ra->prev_pos = -1;
 }
 EXPORT_SYMBOL_GPL(file_ra_state_init);