From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
"hugh.dickins@tiscali.co.uk" <hugh.dickins@tiscali.co.uk>,
"hannes@cmpxchg.org" <hannes@cmpxchg.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Subject: Re: [RFC][PATCH 5/5] (experimental) chase and free cache only swap
Date: Wed, 27 May 2009 15:30:24 +0900 [thread overview]
Message-ID: <20090527153024.bb275962.nishimura@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20090527141442.d191dc2d.kamezawa.hiroyu@jp.fujitsu.com>
On Wed, 27 May 2009 14:14:42 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> On Tue, 26 May 2009 12:18:34 +0900
> KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
>
> >
> > From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> >
> This is a replacement for this. (just an idea, not testd.)
>
> I think this works well. Does anyone has concerns ?
I think so too, except some trivial build errors ;)
I'll test it, but it will take a long time to see the effect of this patch
even if setting the swap space to reasonable size.
Thanks,
Daisuke Nishimura.
> Do I have to modify swap-cluster code to do this in sane way ?
>
> ---
> mm/swapfile.c | 40 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> Index: new-trial-swapcount/mm/swapfile.c
> ===================================================================
> --- new-trial-swapcount.orig/mm/swapfile.c
> +++ new-trial-swapcount/mm/swapfile.c
> @@ -74,6 +74,26 @@ static inline unsigned short make_swap_c
> return ret;
> }
>
> +static int try_to_reuse_swap(struct swap_info_struct *si, unsigned long offset)
> +{
> + int type = si - swap_info;
> + swp_entry_t entry = swp_entry(type, offset);
> + struct page *page;
> +
> + page = find_get_page(page);
> + if (!page)
> + return 0;
> + if (!trylock_page(page)) {
> + page_cache_release(page);
> + return 0;
> + }
> + try_to_free_swap(page);
> + unlock_page(page);
> + page_cache_release(page);
> + return 1;
> +}
> +
> +
> /*
> * We need this because the bdev->unplug_fn can sleep and we cannot
> * hold swap_lock while calling the unplug_fn. And swap_lock
> @@ -295,6 +315,18 @@ checks:
> goto no_page;
> if (offset > si->highest_bit)
> scan_base = offset = si->lowest_bit;
> +
> + /* reuse swap entry of cache-only swap if not busy. */
> + if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) {
> + int ret;
> + spin_unlock(&swap_lock);
> + ret = try_to_reuse_swap(si, offset));
> + spin_lock(&swap_lock);
> + if (ret)
> + goto checks; /* we released swap_lock */
> + goto scan;
> + }
> +
> if (si->swap_map[offset])
> goto scan;
>
> @@ -378,6 +410,10 @@ scan:
> spin_lock(&swap_lock);
> goto checks;
> }
> + if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) {
> + spin_lock(&swap_lock);
> + goto checks;
> + }
> if (unlikely(--latency_ration < 0)) {
> cond_resched();
> latency_ration = LATENCY_LIMIT;
> @@ -389,6 +425,10 @@ scan:
> spin_lock(&swap_lock);
> goto checks;
> }
> + if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) {
> + spin_lock(&swap_lock);
> + goto checks;
> + }
> if (unlikely(--latency_ration < 0)) {
> cond_resched();
> latency_ration = LATENCY_LIMIT;
>
--
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-05-27 6:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-26 3:12 [RFC][PATCH] memcg: fix swap account (26/May)[0/5] KAMEZAWA Hiroyuki
2009-05-26 3:14 ` [RFC][PATCH 1/5] change swap cache interfaces KAMEZAWA Hiroyuki
2009-05-26 3:15 ` [RFC][PATCH 2/5] add SWAP_HAS_CACHE flag to swap_map KAMEZAWA Hiroyuki
2009-05-27 4:02 ` Daisuke Nishimura
2009-05-27 4:36 ` KAMEZAWA Hiroyuki
2009-05-27 5:00 ` Daisuke Nishimura
2009-05-28 0:41 ` Daisuke Nishimura
2009-05-28 1:05 ` KAMEZAWA Hiroyuki
2009-05-28 1:40 ` Daisuke Nishimura
2009-05-28 1:44 ` KAMEZAWA Hiroyuki
2009-05-26 3:16 ` [RFC][PATCH 3/5] count cache-only swaps KAMEZAWA Hiroyuki
2009-05-26 17:37 ` Johannes Weiner
2009-05-26 23:49 ` KAMEZAWA Hiroyuki
2009-05-26 3:17 ` [RFC][PATCH 4/5] memcg: fix swap account KAMEZAWA Hiroyuki
2009-05-26 3:18 ` [RFC][PATCH 5/5] (experimental) chase and free cache only swap KAMEZAWA Hiroyuki
2009-05-26 18:14 ` Johannes Weiner
2009-05-27 0:08 ` KAMEZAWA Hiroyuki
2009-05-27 1:26 ` Johannes Weiner
2009-05-27 1:31 ` KAMEZAWA Hiroyuki
2009-05-27 2:06 ` Johannes Weiner
2009-05-27 5:14 ` KAMEZAWA Hiroyuki
2009-05-27 6:30 ` Daisuke Nishimura [this message]
2009-05-27 6:50 ` KAMEZAWA Hiroyuki
2009-05-27 6:43 ` [RFC][PATCH] memcg: fix swap account (26/May)[0/5] 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=20090527153024.bb275962.nishimura@mxp.nes.nec.co.jp \
--to=nishimura@mxp.nes.nec.co.jp \
--cc=balbir@linux.vnet.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=hugh.dickins@tiscali.co.uk \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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