linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Zhaoyang Huang <huangzhaoyang@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Minchan Kim <minchan@kernel.org>,
	Zhaoyang Huang <zhaoyang.huang@unisoc.com>,
	"open list:MEMORY MANAGEMENT" <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	chunyan.zhang@unisoc.com, Baolin Wang <baolin.wang7@gmail.com>
Subject: Re: [PATCH v2] mm : sync ra->ra_pages with bdi->ra_pages
Date: Fri, 21 Aug 2020 12:57:44 +0100	[thread overview]
Message-ID: <20200821115744.GP17456@casper.infradead.org> (raw)
In-Reply-To: <CAGWkznGfc8g3SRd5vBq7sQGFLuc__98c7t21-3j4T1oAViHvgg@mail.gmail.com>

On Fri, Aug 21, 2020 at 05:31:52PM +0800, Zhaoyang Huang wrote:
> This patch has been verified on an android system and reduces 15% of
> UNITERRUPTIBLE_SLEEP_BLOCKIO which was used to be caused by wrong
> ra->ra_pages.

Wait, what?  Readahead doesn't sleep on the pages it's requesting.
Unless ... your file access pattern is random, so you end up submitting
a readahead I/O that's bigger than needed, so takes longer for the page
you actually wanted to be returned.  I know we have the LOTSAMISS
logic, but that's not really enough.

OK, assuming this problem is really about sync mmap (ie executables),
this makes a bit more sense.  I think the real problem is here:

        ra->start = max_t(long, 0, offset - ra->ra_pages / 2);
        ra->size = ra->ra_pages;
        ra->async_size = ra->ra_pages / 4;
        ra_submit(ra, mapping, file);

which actually skips all the logic we have in ondemand_readahead()
for adjusting the readahead size.  Ugh, this is a mess.

I think a quick fix to your problem will be just replacing ra->ra_pages
with bdi->ra_pages in do_sync_mmap_readahead() and leaving ra->ra_pages
alone everywhere else.

We need a smarter readahead algorithm for mmap'ed files, and I don't have
time to work on it right now.  So let's stick to the same dumb algorithm,
but make it responsive to bdi ra_pages being reset.


  reply	other threads:[~2020-08-21 11:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21  9:24 Zhaoyang Huang
2020-08-21  9:31 ` Zhaoyang Huang
2020-08-21 11:57   ` Matthew Wilcox [this message]
2020-08-22  1:46     ` Zhaoyang Huang
2020-08-25  1:25     ` Zhaoyang Huang

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=20200821115744.GP17456@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang7@gmail.com \
    --cc=chunyan.zhang@unisoc.com \
    --cc=huangzhaoyang@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=zhaoyang.huang@unisoc.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