From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
"hugh.dickins@tiscali.co.uk" <hugh.dickins@tiscali.co.uk>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"hannes@cmpxchg.org" <hannes@cmpxchg.org>
Subject: [RFC][PATCH 3/3] count swap caches whose swp_entry can be freed.
Date: Fri, 22 May 2009 17:05:41 +0900 [thread overview]
Message-ID: <20090522170541.ae14df90.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20090522165730.8791c2dd.kamezawa.hiroyu@jp.fujitsu.com>
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Count a swap entry which is just a swapcache.
i.e. swap entry can be freed immediately.
This counter tells us there is a chance to reclaim swap entries.
Maybe good for mem+swap controller.
(Freeing routine itself is a homework...)
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
include/linux/swap.h | 1 +
mm/swapfile.c | 15 ++++++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
Index: mmotm-2.6.30-May17/include/linux/swap.h
===================================================================
--- mmotm-2.6.30-May17.orig/include/linux/swap.h
+++ mmotm-2.6.30-May17/include/linux/swap.h
@@ -156,6 +156,7 @@ struct swap_info_struct {
unsigned int max;
unsigned int inuse_pages;
unsigned int old_block_size;
+ unsigned int orphan_swap_cache;
};
struct swap_list_t {
Index: mmotm-2.6.30-May17/mm/swapfile.c
===================================================================
--- mmotm-2.6.30-May17.orig/mm/swapfile.c
+++ mmotm-2.6.30-May17/mm/swapfile.c
@@ -291,9 +291,10 @@ checks:
si->lowest_bit = si->max;
si->highest_bit = 0;
}
- if (cache)
+ if (cache) {
si->swap_map[offset] = SWAP_HAS_CACHE; /* via get_swap_page() */
- else
+ si->orphan_swap_cache++;
+ } else
si->swap_map[offset] = 1; /* via alloc_swap_block() */
si->cluster_next = offset + 1;
@@ -521,9 +522,14 @@ static int swap_entry_free(struct swap_i
swap_list.next = p - swap_info;
nr_swap_pages++;
p->inuse_pages--;
+ if (cache)
+ p->orphan_swap_cache--;
}
- if (!swap_has_ref(count))
+ if (!swap_has_ref(count)) {
mem_cgroup_uncharge_swap(ent);
+ if (count & SWAP_HAS_CACHE)
+ p->orphan_swap_cache++;
+ }
return count;
}
@@ -2022,6 +2028,9 @@ int swap_duplicate(swp_entry_t entry)
goto out_unlock;
count = p->swap_map[offset] & SWAP_MAP_MASK;
+ if (!count && (p->swap_map[offset] & SWAP_HAS_CACHE))
+ p->orphan_swap_cache++;
+
if (count < SWAP_MAP_MAX - 1) {
p->swap_map[offset] += 1;
result = 1;
--
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>
prev parent reply other threads:[~2009-05-22 8:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-22 7:57 [RFC][PATCH 0/3] fix memcg to do swap account in right way (avoid swap account leak) KAMEZAWA Hiroyuki
2009-05-22 8:01 ` [RFC][PATCH 1/3] add SWAP_HAS_CACHE flag to swapmap KAMEZAWA Hiroyuki
2009-05-22 8:04 ` [RFC][PATCH 2/3] fix memcg swap account to handle swap ref itself KAMEZAWA Hiroyuki
2009-05-22 8:05 ` KAMEZAWA Hiroyuki [this message]
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=20090522170541.ae14df90.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=hugh.dickins@tiscali.co.uk \
--cc=linux-mm@kvack.org \
--cc=nishimura@mxp.nes.nec.co.jp \
/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