From: Johannes Weiner <hannes@cmpxchg.org>
To: Hugh Dickins <hugh@veritas.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Rik van Riel <riel@redhat.com>
Subject: Re: [patch 2/3][rfc] swap: try to reuse freed slots in the allocation area
Date: Mon, 27 Apr 2009 10:02:13 +0200 [thread overview]
Message-ID: <20090427080213.GB2244@cmpxchg.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0904222020140.18587@blonde.anvils>
On Wed, Apr 22, 2009 at 08:59:06PM +0100, Hugh Dickins wrote:
> On Mon, 20 Apr 2009, Johannes Weiner wrote:
>
> > A swap slot for an anonymous memory page might get freed again just
> > after allocating it when further steps in the eviction process fail.
> >
> > But the clustered slot allocation will go ahead allocating after this
> > now unused slot, leaving a hole at this position. Holes waste space
> > and act as a boundary for optimistic swap-in.
> >
> > To avoid this, check if the next page to be swapped out can sensibly
> > be placed at this just freed position. And if so, point the next
> > cluster offset to it.
> >
> > The acceptable 'look-back' distance is the number of slots swap-in
> > clustering uses as well so that the latter continues to get related
> > context when reading surrounding swap slots optimistically.
> >
> > Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> > Cc: Hugh Dickins <hugh@veritas.com>
> > Cc: Rik van Riel <riel@redhat.com>
>
> I'm glad you're looking into this area, thank you.
> I've a feeling that you're going to come up with something good
> here, but that neither of these patches (2/3 and 3/3) is yet it.
>
> This patch looks plausible, but I'm not persuaded by it.
>
> I wonder what contribution it made to the impressive figures in
> your testing - I suspect none, that it barely exercised this path.
>
> I worry that by jumping back to use the slot in this way, you're
> actually propagating the glitch: by which I mean, if the pages are
> all as nicely linear as you're supposing, then now one of them
> will get placed out of sequence, unlike with the existing code.
>
> And note that swapin's page_cluster is used in a strictly aligned
> way (unlike swap allocation's SWAPFILE_CLUSTER): if you're going
> to use page_cluster to bound this, then perhaps you should be
> aligning too. Perhaps, perhaps not.
Thank you, will think about that.
> If this patch is worthwhile, then don't you want also to be
> removing the " && vm_swap_full()" test from vmscan.c, where
> shrink_page_list() activate_locked does try_to_free_swap(page)?
I fear this swap releasing there can fail quite easily anyway. At
least that is what my testing patches suggest - we hit quite a lot of
already swap cached pages in shrink_page_list() and I think that is
where they come from. It's a different issue, though.
> But bigger And/Or: you remark that "holes act as a boundary for
> optimistic swap-in". Maybe that's more worth attacking? I think
> that behaviour is dictated purely by the convenience of a simple
> offset:length interface between swapfile.c's valid_swaphandles()
> and swap_state.c's swapin_readahead().
>
> If swapin readahead is a good thing (I tend to be pessimistic about
> it: think it's worth reading several pages while the disk head is
> there, but hold no great hopes that the other pages will be useful -
> though when I've experimented with removing, it's certainly proved
> to be of some value), then I think you'd do better to restructure
> that interface, so as not to stop at the holes.
Hm, let's try that. I am thinking of extending valid_swap_handles()
to return exactly those through a bitmap that can represent holes.
I think the read-in makes sense but not when the system is already
thrashing. Then it will just use memory for data we are not sure of
being needed at all. Perhaps it should be throttled or disabled at
some point.
Hugh, thanks a lot for your great feedback.
Hannes
--
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:[~2009-04-27 8:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-20 20:24 [patch 1/3] mm: fix pageref leak in do_swap_page() Johannes Weiner
2009-04-20 20:24 ` [patch 2/3][rfc] swap: try to reuse freed slots in the allocation area Johannes Weiner
2009-04-22 19:59 ` Hugh Dickins
2009-04-27 8:02 ` Johannes Weiner [this message]
2009-04-20 20:24 ` [patch 3/3][rfc] vmscan: batched swap slot allocation Johannes Weiner
2009-04-20 20:31 ` Johannes Weiner
2009-04-20 20:53 ` Andrew Morton
2009-04-20 21:38 ` Johannes Weiner
2009-04-21 0:58 ` KAMEZAWA Hiroyuki
2009-04-21 8:52 ` Johannes Weiner
2009-04-21 9:23 ` KAMEZAWA Hiroyuki
2009-04-21 9:54 ` Johannes Weiner
2009-04-21 9:27 ` KOSAKI Motohiro
2009-04-21 9:38 ` Johannes Weiner
2009-04-21 9:41 ` KOSAKI Motohiro
2009-04-22 20:37 ` Hugh Dickins
2009-04-27 7:46 ` Johannes Weiner
2009-04-20 23:36 ` [patch 1/3] mm: fix pageref leak in do_swap_page() Minchan Kim
2009-04-21 3:14 ` Balbir Singh
2009-04-21 8:19 ` Johannes Weiner
2009-04-21 8:45 ` Balbir Singh
2009-04-21 3:44 ` KAMEZAWA Hiroyuki
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=20090427080213.GB2244@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=hugh@veritas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=riel@redhat.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