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>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
"kosaki.motohiro@jp.fujitsu.com" <kosaki.motohiro@jp.fujitsu.com>
Subject: [RFC][PATCH 8/9] lru reordering
Date: Fri, 3 Apr 2009 17:17:35 +0900 [thread overview]
Message-ID: <20090403171735.7a048a25.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20090403170835.a2d6cbc3.kamezawa.hiroyu@jp.fujitsu.com>
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
This patch adds a function to change the LRU order of pages in global LRU
under control of memcg's victim of soft limit.
FILE and ANON victim is divided and LRU rotation will be done independently.
(memcg which only includes FILE cache or ANON can exists.)
This patch removes finds specfied number of pages from memcg's LRU and
move it to top of global LRU. They will be the first target of shrink_xxx_list.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
include/linux/memcontrol.h | 15 ++++++++++
mm/memcontrol.c | 67 +++++++++++++++++++++++++++++++++++++++++++++
mm/vmscan.c | 18 +++++++++++-
3 files changed, 99 insertions(+), 1 deletion(-)
Index: softlimit-test2/include/linux/memcontrol.h
===================================================================
--- softlimit-test2.orig/include/linux/memcontrol.h
+++ softlimit-test2/include/linux/memcontrol.h
@@ -117,6 +117,9 @@ static inline bool mem_cgroup_disabled(v
extern bool mem_cgroup_oom_called(struct task_struct *task);
+void mem_cgroup_soft_limit_reorder_lru(struct zone *zone,
+ unsigned long nr_to_scan, enum lru_list l);
+int mem_cgroup_soft_limit_inactive_anon_is_low(struct zone *zone);
#else /* CONFIG_CGROUP_MEM_RES_CTLR */
struct mem_cgroup;
@@ -264,6 +267,18 @@ mem_cgroup_print_oom_info(struct mem_cgr
{
}
+static inline void
+mem_cgroup_soft_limit_reorder_lru(struct zone *zone, unsigned long nr_to_scan,
+ enum lru_list lru);
+{
+}
+
+static inline
+int mem_cgroup_soft_limit_inactive_anon_is_low(struct zone *zone)
+{
+ return 0;
+}
+
#endif /* CONFIG_CGROUP_MEM_CONT */
#endif /* _LINUX_MEMCONTROL_H */
Index: softlimit-test2/mm/memcontrol.c
===================================================================
--- softlimit-test2.orig/mm/memcontrol.c
+++ softlimit-test2/mm/memcontrol.c
@@ -1257,6 +1257,73 @@ static struct mem_cgroup *get_soft_limit
return ret;
}
+/*
+ * zone->lru and memcg's lru is synchronous under zone->lock.
+ * This tries to rotate pages in specfied LRU.
+ */
+void mem_cgroup_soft_limit_reorder_lru(struct zone *zone,
+ unsigned long nr_to_scan,
+ enum lru_list l)
+{
+ struct mem_cgroup *mem;
+ struct mem_cgroup_per_zone *mz;
+ int nid, zid, file;
+ unsigned long scan, flags;
+ struct list_head *src;
+ LIST_HEAD(found);
+ struct page_cgroup *pc;
+ struct page *page;
+
+ nid = zone->zone_pgdat->node_id;
+ zid = zone_idx(zone);
+
+ file = is_file_lru(l);
+
+ mem = get_soft_limit_victim(zone, file);
+ if (!mem)
+ return;
+ mz = mem_cgroup_zoneinfo(mem, nid, zid);
+ src = &mz->lists[l];
+ scan = 0;
+
+ /* Find at most nr_to_scan pages from local LRU */
+ spin_lock_irqsave(&zone->lru_lock, flags);
+ list_for_each_entry_reverse(pc, src, lru) {
+ if (scan >= nr_to_scan)
+ break;
+ /* We don't check Used bit */
+ page = pc->page;
+ /* Can happen ? */
+ if (unlikely(!PageLRU(page)))
+ continue;
+ /* This page is on (the same) LRU */
+ list_move(&page->lru, &found);
+ scan++;
+ }
+ /* vmscan searches pages from lru->prev. link this to lru->prev. */
+ list_splice_tail(&found, &zone->lru[l].list);
+ spin_unlock_irqrestore(&zone->lru_lock, flags);
+
+ /* When we cannot fill the request, check we should forget this cache
+ or not */
+ if (scan < nr_to_scan &&
+ !is_active_lru(l) &&
+ mem_cgroup_usage(mem, zone, file) < SWAP_CLUSTER_MAX)
+ slc_reset_cache_ticket(file);
+}
+
+/* Returns 1 if soft limit is active && memcg's zone's status is that */
+int mem_cgroup_soft_limit_inactive_anon_is_low(struct zone *zone)
+{
+ struct soft_limit_cache *slc;
+ int ret = 0;
+
+ slc = &get_cpu_var(soft_limit_cache);
+ if (slc->mem[SL_ANON])
+ ret = mem_cgroup_inactive_anon_is_low(slc->mem[SL_ANON], zone);
+ put_cpu_var(soft_limit_cache);
+ return ret;
+}
static void softlimitq_init(void)
{
Index: softlimit-test2/mm/vmscan.c
===================================================================
--- softlimit-test2.orig/mm/vmscan.c
+++ softlimit-test2/mm/vmscan.c
@@ -1066,6 +1066,13 @@ static unsigned long shrink_inactive_lis
pagevec_init(&pvec, 1);
lru_add_drain();
+ if (scanning_global_lru(sc)) {
+ enum lru_list l = LRU_INACTIVE_ANON;
+ if (file)
+ l = LRU_INACTIVE_FILE;
+ mem_cgroup_soft_limit_reorder_lru(zone, max_scan, l);
+ }
+
spin_lock_irq(&zone->lru_lock);
do {
struct page *page;
@@ -1233,6 +1240,13 @@ static void shrink_active_list(unsigned
struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc);
lru_add_drain();
+ if (scanning_global_lru(sc)) {
+ enum lru_list l = LRU_ACTIVE_ANON;
+ if (file)
+ l = LRU_ACTIVE_FILE;
+ mem_cgroup_soft_limit_reorder_lru(zone, nr_pages, l);
+ }
+
spin_lock_irq(&zone->lru_lock);
pgmoved = sc->isolate_pages(nr_pages, &l_hold, &pgscanned, sc->order,
ISOLATE_ACTIVE, zone,
@@ -1328,7 +1342,9 @@ static int inactive_anon_is_low_global(s
if (inactive * zone->inactive_ratio < active)
return 1;
-
+ /* check soft limit vicitm's status */
+ if (mem_cgroup_soft_limit_inactive_anon_is_low(zone))
+ return 1;
return 0;
}
--
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-03 8:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-03 8:08 [RFC][PATCH 0/9] memcg soft limit v2 (new design) KAMEZAWA Hiroyuki
2009-04-03 8:09 ` [RFC][PATCH 1/9] " KAMEZAWA Hiroyuki
2009-04-03 8:10 ` [RFC][PATCH 2/9] soft limit framework for memcg KAMEZAWA Hiroyuki
2009-04-03 8:12 ` [RFC][PATCH 3/9] soft limit update filter KAMEZAWA Hiroyuki
2009-04-06 9:43 ` Balbir Singh
2009-04-07 0:04 ` KAMEZAWA Hiroyuki
2009-04-07 2:26 ` Balbir Singh
2009-04-03 8:12 ` [RFC][PATCH 4/9] soft limit queue and priority KAMEZAWA Hiroyuki
2009-04-06 11:05 ` Balbir Singh
2009-04-06 23:55 ` KAMEZAWA Hiroyuki
2009-04-06 18:42 ` Balbir Singh
2009-04-06 23:54 ` KAMEZAWA Hiroyuki
2009-04-03 8:13 ` [RFC][PATCH 5/9] add more hooks and check in lazy manner KAMEZAWA Hiroyuki
2009-04-03 8:14 ` [RFC][PATCH 6/9] active inactive ratio for private KAMEZAWA Hiroyuki
2009-04-03 8:15 ` [RFC][PATCH 7/9] vicitim selection logic KAMEZAWA Hiroyuki
2009-04-03 8:17 ` KAMEZAWA Hiroyuki [this message]
2009-04-03 8:18 ` [RFC][PATCH 9/9] more event filter depend on priority KAMEZAWA Hiroyuki
2009-04-03 8:24 ` [RFC][PATCH ex/9] for debug KAMEZAWA Hiroyuki
2009-04-06 9:08 ` [RFC][PATCH 0/9] memcg soft limit v2 (new design) Balbir Singh
2009-04-07 0:16 ` KAMEZAWA Hiroyuki
2009-04-24 12:24 ` Balbir Singh
2009-04-24 15:19 ` 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=20090403171735.7a048a25.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=kosaki.motohiro@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