linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: "Pankaj Raghav (Samsung)" <kernel@pankajraghav.com>
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: [PATCH v14] mm: don't set readahead flag on a folio when lookahead_size > nr_to_read
Date: Tue, 15 Oct 2024 18:33:11 +0100	[thread overview]
Message-ID: <Zw6nVz-Y6l-4bDbt@casper.infradead.org> (raw)
In-Reply-To: <20241015164106.465253-1-kernel@pankajraghav.com>

On Tue, Oct 15, 2024 at 06:41:06PM +0200, Pankaj Raghav (Samsung) wrote:

v14?  Where are v1..13 of this patch?  It's the first time I've seen it.

> The readahead flag is set on a folio based on the lookahead_size and
> nr_to_read. For example, when the readahead happens from index to index
> + nr_to_read, then the readahead `mark` offset from index is set at
> nr_to_read - lookahead_size.
> 
> There are some scenarios where the lookahead_size > nr_to_read. If this
> happens, readahead flag is not set on any folio on the current
> readahead window.

Please describe those scenarios, as that's the important bit.

> There are two problems at the moment in the way `mark` is calculated
> when lookahead_size > nr_to_read:
> 
> - unsigned long `mark` will be assigned a negative value which can lead
>   to unexpected results in extreme cases due to wrap around.

Can such an extreme case happen?

> - 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.

I think the worst case scenario is that we set the flag on the wrong
folio, causing readahead to occur when it should not.  But maybe I'm
wrong?



  parent reply	other threads:[~2024-10-15 17:33 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 [this message]
2024-10-16 10:05   ` Pankaj Raghav (Samsung)
2024-10-16 11:57     ` Matthew Wilcox
2024-10-16 13:06       ` Pankaj Raghav (Samsung)

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=Zw6nVz-Y6l-4bDbt@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=gost.dev@samsung.com \
    --cc=kernel@pankajraghav.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mcgrof@kernel.org \
    --cc=p.raghav@samsung.com \
    /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