linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pankaj Raghav (Samsung)" <kernel@pankajraghav.com>
To: Dave Chinner <david@fromorbit.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, djwong@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
Subject: Re: [RFC v2 05/14] readahead: align index to mapping_min_order in ondemand_ra and force_ra
Date: Wed, 14 Feb 2024 16:10:51 +0100	[thread overview]
Message-ID: <dgtdqakqkyqvnjeujt2j5dwkolwlx7cna6ounuask2vrxyj64s@na6tkgwllyoe> (raw)
In-Reply-To: <ZcvtUOecezQD7Mm6@dread.disaster.area>

> > @@ -324,6 +325,13 @@ void force_page_cache_ra(struct readahead_control *ractl,
> >  	 * be up to the optimal hardware IO size
> >  	 */
> >  	index = readahead_index(ractl);
> > +	if (!IS_ALIGNED(index, min_nrpages)) {
> > +		unsigned long old_index = index;
> > +
> > +		index = round_down(index, min_nrpages);
> > +		nr_to_read += (old_index - index);
> > +	}
> 
> 	new_index = mapping_align_start_index(mapping, index);
> 	if (new_index != index) {
> 		nr_to_read += index - new_index;
> 		index = new_index
Looks good.

> 	}
> 
> > +
> >  	max_pages = max_t(unsigned long, bdi->io_pages, ra->ra_pages);
> >  	nr_to_read = min_t(unsigned long, nr_to_read, max_pages);
> 
> This needs to have a size of at least the minimum folio order size
> so readahead can fill entire folios, not get neutered to the maximum
> IO size the underlying storage supports.

So something like:

> >  	max_pages = max_t(unsigned long, bdi->io_pages, ra->ra_pages);
> >  	nr_to_read = min_t(unsigned long, nr_to_read, max_pages);
nr_to_read = max(nr_to_read, min_order);

> 
> > + * 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_nrpages,
> > +				      unsigned long max)
> >  {
> >  	unsigned long newsize = roundup_pow_of_two(size);
> >  
> > +	newsize = max_t(unsigned long, newsize, min_nrpages);
> 
> This really doesn't need to care about min_nrpages. That rounding
> can be done in the caller when the new size is returned.

Sounds good.

> 
> >  	if (newsize <= max / 32)
> >  		newsize = newsize * 4;
> 
> >  
> >  
> > @@ -561,7 +583,11 @@ static void ondemand_readahead(struct readahead_control *ractl,
> >  	unsigned long add_pages;
> >  	pgoff_t index = readahead_index(ractl);
> >  	pgoff_t expected, prev_index;
> > -	unsigned int order = folio ? folio_order(folio) : 0;
> > +	unsigned int min_order = mapping_min_folio_order(ractl->mapping);
> > +	unsigned int min_nrpages = mapping_min_folio_nrpages(ractl->mapping);
> > +	unsigned int order = folio ? folio_order(folio) : min_order;
> 
> Huh? If we have a folio, then the order is whatever that folio is,
> otherwise we use min_order. What if the folio is larger than
> min_order? Doesn't that mean that this:
> 
> > @@ -583,8 +609,8 @@ static void ondemand_readahead(struct readahead_control *ractl,
> >  	expected = round_down(ra->start + ra->size - ra->async_size,
> >  			1UL << order);
> >  	if (index == expected || index == (ra->start + ra->size)) {
> > -		ra->start += ra->size;
> > -		ra->size = get_next_ra_size(ra, max_pages);
> > +		ra->start += round_down(ra->size, min_nrpages);
> > +		ra->size = get_next_ra_size(ra, min_nrpages, max_pages);
> 
> may set up the incorrect readahead range because the folio order is
> larger than min_nrpages?

Hmm... So I think we should just increment ra->start by ra->size, and
make sure to round the new size we get from get_next_ra_size() to
min_nrpages. Then we will not disturb the readahead range and always
increase the range in multiples of min_nrpages:

ra->start += ra->size;
ra->size = round_up(get_next_ra_size(ra, max_pages), min_nrpages);

> 
> >  		ra->async_size = ra->size;
> >  		goto readit;
> >  	}
> > @@ -603,13 +629,18 @@ static void ondemand_readahead(struct readahead_control *ractl,
> >  				max_pages);
> >  		rcu_read_unlock();
> >  
> > +		start = round_down(start, min_nrpages);
> 
> 		start = mapping_align_start_index(mapping, start);
> > +
> > +		VM_BUG_ON(folio->index & (folio_nr_pages(folio) - 1));
> > +
> >  		if (!start || start - index > max_pages)
> >  			return;
> >  
> >  		ra->start = start;
> >  		ra->size = start - index;	/* old async_size */
> > +
> >  		ra->size += req_size;
> > -		ra->size = get_next_ra_size(ra, max_pages);
> > +		ra->size = get_next_ra_size(ra, min_nrpages, max_pages);
> 
> 		ra->size = max(min_nrpages, get_next_ra_size(ra, max_pages));

If this is a round_up of size instead of max operation, we can
always ensure the ra->start from index aligned to min_nrpages. See my
reasoning in the previous comment.

--
Pankaj

  reply	other threads:[~2024-02-14 15:11 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) [this message]
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
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=dgtdqakqkyqvnjeujt2j5dwkolwlx7cna6ounuask2vrxyj64s@na6tkgwllyoe \
    --to=kernel@pankajraghav.com \
    --cc=akpm@linux-foundation.org \
    --cc=chandan.babu@oracle.com \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=gost.dev@samsung.com \
    --cc=hare@suse.de \
    --cc=kbusch@kernel.org \
    --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).