linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Pankaj Raghav (Samsung)" <kernel@pankajraghav.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	 linux-fsdevel@vger.kernel.org, mcgrof@kernel.org,
	gost.dev@samsung.com,  Pankaj Raghav <p.raghav@samsung.com>
Subject: Re: Re: Re: [PATCH v14] mm: don't set readahead flag on a folio when lookahead_size > nr_to_read
Date: Wed, 16 Oct 2024 18:36:04 +0530	[thread overview]
Message-ID: <sokq3z55j3xwxjktvsnssxcldnmzbqax5wp4wcturof4f3jqp4@izfk6jzzifjh> (raw)
In-Reply-To: <Zw-qOAOM2je3EHb1@casper.infradead.org>

On Wed, Oct 16, 2024 at 12:57:44PM +0100, Matthew Wilcox wrote:
> On Wed, Oct 16, 2024 at 03:35:27PM +0530, Pankaj Raghav (Samsung) wrote:
> > > > - The current calculation for `mark` with mapping_min_order > 0 gives
> > > >   incorrect results when lookahead_size > nr_to_read due to rounding
> > > >   up operation.
> > > > 
> > > > Explicitly initialize `mark` to be ULONG_MAX and only calculate it
> > > > when lookahead_size is within the readahead window.
> > > 
> > > You haven't really spelled out the consequences of this properly.
> > > Perhaps a worked example would help.
> > 
> > Got it. I saw this while running generic/476 on XFS with 64k block size.
> > 
> > Let's assume the following values:
> > index = 128
> > nr_to_read = 16
> > lookahead_size = 28
> > mapping_min_order = 4 (16 pages)
> > 
> > The lookahead_size is actually lying outside the current readahead
> > window. The calculation without this patch will result in incorrect mark
> > as follows:
> > 
> > ra_folio_index = round_up(128 + 16 - 28, 16) = 128;
> > mark = 128 - 128 = 0;
> > 
> > So we will be marking the folio on 0th index with RA flag, even though

Oops. I shouldn't have said 0th index. I meant at offset 0 from the
index.

> > we shouldn't have. Does that make sense?
> 
> But we don't go back and find the folio for index 0.  We only consider
> the folios we're actually reading for marking.  So if 'mark' lies
> outside the readahead window, we simply won't mark any of them.  So I

`mark` is the offset from index. So we compare `mark` with the 
iterator `i`, which starts at 0. So we will set the RA flag on index
128 in this example, which is not correct.

if (i == mark)
	folio_set_readahead(folio);

With this patch, mark will be ULONG_MAX and not 0.

> don't think your patch changes anything.  Or did I miss something?

Does that make sense?



      reply	other threads:[~2024-10-16 13:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-15 16:41 Pankaj Raghav (Samsung)
2024-10-15 17:29 ` Pankaj Raghav
2024-10-15 17:33 ` Matthew Wilcox
2024-10-16 10:05   ` Pankaj Raghav (Samsung)
2024-10-16 11:57     ` Matthew Wilcox
2024-10-16 13:06       ` Pankaj Raghav (Samsung) [this message]

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=sokq3z55j3xwxjktvsnssxcldnmzbqax5wp4wcturof4f3jqp4@izfk6jzzifjh \
    --to=kernel@pankajraghav.com \
    --cc=akpm@linux-foundation.org \
    --cc=gost.dev@samsung.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.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