From: Jan Kara <jack@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>,
Fengguang Wu <fengguang.wu@intel.com>,
David Cohen <david.a.cohen@linux.intel.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Damien Ramonda <damien.ramonda@intel.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH RFC] mm readahead: Fix the readahead fail in case of empty numa node
Date: Wed, 11 Dec 2013 23:49:17 +0100 [thread overview]
Message-ID: <20131211224917.GF1163@quack.suse.cz> (raw)
In-Reply-To: <20131204134838.a048880a1db9e9acd14a39e4@linux-foundation.org>
On Wed 04-12-13 13:48:38, Andrew Morton wrote:
> On Wed, 04 Dec 2013 14:38:11 +0530 Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com> wrote:
>
> > On 12/04/2013 02:11 PM, Andrew Morton wrote:
> > > On Wed, 04 Dec 2013 14:00:09 +0530 Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com> wrote:
> > >
> > >> Unfaortunately, from my search, I saw that the code belonged to pre git
> > >> time, so could not get much information on that.
> > >
> > > Here: https://lkml.org/lkml/2004/8/20/242
> > >
> > > It seems it was done as a rather thoughtless performance optimisation.
> > > I'd say it's time to reimplement max_sane_readahead() from scratch.
> > >
> >
> > Ok. Thanks for the link. I think after that,
> > Here it was changed to pernode:
> > https://lkml.org/lkml/2004/8/21/9 to avoid iteration all over.
> >
> > do you think above patch (+comments) with some sanitized nr (thus
> > avoiding iteration over nodes in remote numa readahead case) does look
> > better?
> > or should we iterate all memory.
>
> I dunno, the whole thing smells of arbitrary woolly thinking to me.
> Going back further in time..
>
> : commit f76d03dc9fcff7ac88e2d23c5814fd0f50c59bb6
> : Author: akpm <akpm>
> : AuthorDate: Sun Dec 15 03:18:58 2002 +0000
> : Commit: akpm <akpm>
> : CommitDate: Sun Dec 15 03:18:58 2002 +0000
> :
> : [PATCH] madvise_willneed() maximum readahead checking
> :
> : madvise_willneed() currently has a very strange check on how much readahead
> : it is prepared to do.
> :
> : It is based on the user's rss limit. But this is usually enormous, and
> : the user isn't necessarily going to map all that memory at the same time
> : anyway.
> :
> : And the logic is wrong - it is comparing rss (which is in bytes) with
> : `end - start', which is in pages.
> :
> : And it returns -EIO on error, which is not mentioned in the Open Group
> : spec and doesn't make sense.
> :
> :
> : This patch takes it all out and applies the same upper limit as is used in
> : sys_readahead() - half the inactive list.
> :
> : +/*
> : + * Given a desired number of PAGE_CACHE_SIZE readahead pages, return a
> : + * sensible upper limit.
> : + */
> : +unsigned long max_sane_readahead(unsigned long nr)
> : +{
> : + unsigned long active;
> : + unsigned long inactive;
> : +
> : + get_zone_counts(&active, &inactive);
> : + return min(nr, inactive / 2);
> : +}
>
> And one would need to go back further still to understand the rationale
> for the sys_readahead() decision and that even predates the BK repo.
>
> iirc the thinking was that we need _some_ limit on readahead size so
> the user can't go and do ridiculously large amounts of readahead via
> sys_readahead(). But that doesn't make a lot of sense because the user
> could do the same thing with plain old read().
>
> So for argument's sake I'm thinking we just kill it altogether and
> permit arbitrarily large readahead:
>
> --- a/mm/readahead.c~a
> +++ a/mm/readahead.c
> @@ -238,13 +238,12 @@ int force_page_cache_readahead(struct ad
> }
>
> /*
> - * Given a desired number of PAGE_CACHE_SIZE readahead pages, return a
> - * sensible upper limit.
> + * max_sane_readahead() is disabled. It can later be removed altogether, but
> + * let's keep a skeleton in place for now, in case disabling was the wrong call.
> */
> unsigned long max_sane_readahead(unsigned long nr)
> {
> - return min(nr, (node_page_state(numa_node_id(), NR_INACTIVE_FILE)
> - + node_page_state(numa_node_id(), NR_FREE_PAGES)) / 2);
> + return nr;
> }
>
> /*
>
> Can anyone see a problem with this?
Well, the downside seems to be that if userspace previously issued
MADV/FADV_WILLNEED on a huge file, we trimmed the request to a sensible
size. Now we try to read the whole huge file which is pretty much
guaranteed to be useless (as we'll be pushing out of cache data we just
read a while ago). And guessing the right readahead size from userspace
isn't trivial so it would make WILLNEED advice less useful. What do you
think?
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-12-11 22:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-03 10:36 [PATCH RFC] mm readahead: Fix the readahead fail in case of empty numa node Raghavendra K T
2013-12-03 22:38 ` Andrew Morton
2013-12-04 8:30 ` Raghavendra K T
2013-12-04 8:41 ` Andrew Morton
2013-12-04 9:08 ` Raghavendra K T
2013-12-04 21:48 ` Andrew Morton
2013-12-05 5:57 ` Raghavendra K T
2013-12-11 22:49 ` Jan Kara [this message]
2013-12-11 23:05 ` Andrew Morton
2013-12-12 11:14 ` Jan Kara
2013-12-14 0:39 ` Linus Torvalds
2013-12-31 11:07 ` Raghavendra K T
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=20131211224917.GF1163@quack.suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=damien.ramonda@intel.com \
--cc=david.a.cohen@linux.intel.com \
--cc=fengguang.wu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=raghavendra.kt@linux.vnet.ibm.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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).