From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Ying Han <yinghan@google.com>,
Minchan Kim <minchan.kim@gmail.com>,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
Tejun Heo <tj@kernel.org>, Pavel Emelyanov <xemul@openvz.org>,
Andrew Morton <akpm@linux-foundation.org>,
Li Zefan <lizf@cn.fujitsu.com>, Mel Gorman <mel@csn.ul.ie>,
Christoph Lameter <cl@linux.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Rik van Riel <riel@redhat.com>, Hugh Dickins <hughd@google.com>,
Michal Hocko <mhocko@suse.cz>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Zhu Yanhai <zhu.yanhai@gmail.com>,
linux-mm@kvack.org
Subject: Re: [PATCH V7 4/9] Add memcg kswapd thread pool
Date: Fri, 22 Apr 2011 14:56:00 +0900 [thread overview]
Message-ID: <20110422145600.504b53d6.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <20110422143957.FA6D.A69D9226@jp.fujitsu.com>
On Fri, 22 Apr 2011 14:39:24 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> > +bool mem_cgroup_kswapd_can_sleep(void)
> > +{
> > + return list_empty(&memcg_kswapd_control.list);
> > +}
>
> and,
>
> > @@ -2583,40 +2585,46 @@ static void kswapd_try_to_sleep(struct kswapd *kswapd_p, int order,
> > } else {
> > + /* For now, we just check the remaining works.*/
> > + if (mem_cgroup_kswapd_can_sleep())
> > + schedule();
>
> has bad assumption. If freeable memory is very little and kswapds are
> contended, memcg-kswap also have to give up and go into sleep as global
> kswapd.
>
> Otherwise, We are going to see kswapd cpu 100% consumption issue again.
>
Hmm, ok. need to add more logics. Is it ok to have add-on patch like this ?
I'll consider some more smart and fair....
==
Because memcg-kswapd push back memcg to the list when there is remaining work,
it may consume too much cpu when it finds hard-to-reclaim-memcg.
This patch adds a penalty to hard-to-reclaim memcg and reduces chance to
be scheduled again.
---
include/linux/memcontrol.h | 2 +-
mm/memcontrol.c | 14 +++++++++++---
mm/vmscan.c | 4 ++--
3 files changed, 14 insertions(+), 6 deletions(-)
Index: mmotm-Apr14/include/linux/memcontrol.h
===================================================================
--- mmotm-Apr14.orig/include/linux/memcontrol.h
+++ mmotm-Apr14/include/linux/memcontrol.h
@@ -96,7 +96,7 @@ extern int mem_cgroup_select_victim_node
extern bool mem_cgroup_kswapd_can_sleep(void);
extern struct mem_cgroup *mem_cgroup_get_shrink_target(void);
-extern void mem_cgroup_put_shrink_target(struct mem_cgroup *mem);
+extern void mem_cgroup_put_shrink_target(struct mem_cgroup *mem, int pages);
extern wait_queue_head_t *mem_cgroup_kswapd_waitq(void);
extern int mem_cgroup_kswapd_bonus(struct mem_cgroup *mem);
Index: mmotm-Apr14/mm/memcontrol.c
===================================================================
--- mmotm-Apr14.orig/mm/memcontrol.c
+++ mmotm-Apr14/mm/memcontrol.c
@@ -4739,6 +4739,10 @@ struct mem_cgroup *mem_cgroup_get_shrink
memcg_kswapd_wait_list);
list_del_init(&mem->memcg_kswapd_wait_list);
}
+ if (mem && mem->stalled) {
+ mem->stalled--; /* This memcg was cpu hog */
+ continue;
+ }
} while (mem && !css_tryget(&mem->css));
if (mem)
atomic_inc(&mem->kswapd_running);
@@ -4747,7 +4751,7 @@ struct mem_cgroup *mem_cgroup_get_shrink
return mem;
}
-void mem_cgroup_put_shrink_target(struct mem_cgroup *mem)
+void mem_cgroup_put_shrink_target(struct mem_cgroup *mem, int nr_pages)
{
if (!mem)
return;
@@ -4755,8 +4759,12 @@ void mem_cgroup_put_shrink_target(struct
if (!mem_cgroup_watermark_ok(mem, CHARGE_WMARK_HIGH)) {
spin_lock(&memcg_kswapd_control.lock);
if (list_empty(&mem->memcg_kswapd_wait_list)) {
- list_add_tail(&mem->memcg_kswapd_wait_list,
- &memcg_kswapd_control.list);
+ /* If memory reclaim was smooth, resched it */
+ if (nr_pages >= SWAP_CLUSTER_MAX/2)
+ list_add_tail(&mem->memcg_kswapd_wait_list,
+ &memcg_kswapd_control.list);
+ else
+ mem->stalled += 1; /* ignore this memcg for a while */
}
spin_unlock(&memcg_kswapd_control.lock);
}
Index: mmotm-Apr14/mm/vmscan.c
===================================================================
--- mmotm-Apr14.orig/mm/vmscan.c
+++ mmotm-Apr14/mm/vmscan.c
@@ -2892,8 +2892,8 @@ int kswapd(void *p)
} else {
mem = mem_cgroup_get_shrink_target();
if (mem)
- shrink_mem_cgroup(mem, order);
- mem_cgroup_put_shrink_target(mem);
+ ret = shrink_mem_cgroup(mem, order);
+ mem_cgroup_put_shrink_target(mem, ret);
}
}
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-04-22 6:02 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-22 4:24 [RFC PATCH V7 0/9] memcg: per cgroup background reclaim Ying Han
2011-04-22 4:24 ` [PATCH V7 1/9] Add kswapd descriptor Ying Han
2011-04-22 4:31 ` KAMEZAWA Hiroyuki
2011-04-22 4:47 ` KOSAKI Motohiro
2011-04-22 5:55 ` Ying Han
2011-04-22 4:24 ` [PATCH V7 2/9] Add per memcg reclaim watermarks Ying Han
2011-04-22 4:24 ` [PATCH V7 3/9] New APIs to adjust per-memcg wmarks Ying Han
2011-04-22 4:32 ` KAMEZAWA Hiroyuki
2011-04-22 4:24 ` [PATCH V7 4/9] Add memcg kswapd thread pool Ying Han
2011-04-22 4:36 ` KAMEZAWA Hiroyuki
2011-04-22 4:49 ` Ying Han
2011-04-22 5:00 ` KAMEZAWA Hiroyuki
2011-04-22 5:53 ` Ying Han
2011-04-22 5:59 ` KAMEZAWA Hiroyuki
2011-04-22 6:10 ` Ying Han
2011-04-22 7:46 ` KAMEZAWA Hiroyuki
2011-04-22 7:59 ` Ying Han
2011-04-22 8:02 ` KAMEZAWA Hiroyuki
2011-04-24 23:26 ` KAMEZAWA Hiroyuki
2011-04-25 2:08 ` Ying Han
2011-04-22 6:02 ` Zhu Yanhai
2011-04-22 6:14 ` Ying Han
2011-04-22 5:39 ` KOSAKI Motohiro
2011-04-22 5:56 ` KAMEZAWA Hiroyuki [this message]
2011-04-22 4:24 ` [PATCH V7 5/9] Infrastructure to support per-memcg reclaim Ying Han
2011-04-22 4:38 ` KAMEZAWA Hiroyuki
2011-04-22 5:11 ` KOSAKI Motohiro
2011-04-22 5:59 ` Ying Han
2011-04-22 5:27 ` KOSAKI Motohiro
2011-04-22 6:00 ` Ying Han
2011-04-22 4:24 ` [PATCH V7 6/9] Implement the select_victim_node within memcg Ying Han
2011-04-22 4:39 ` KAMEZAWA Hiroyuki
2011-04-22 4:24 ` [PATCH V7 7/9] Per-memcg background reclaim Ying Han
2011-04-22 4:40 ` KAMEZAWA Hiroyuki
2011-04-22 6:00 ` KOSAKI Motohiro
2011-04-22 7:54 ` Ying Han
2011-04-22 8:44 ` KOSAKI Motohiro
2011-04-22 18:37 ` Ying Han
2011-04-25 2:21 ` [PATCH] vmscan,memcg: memcg aware swap token KOSAKI Motohiro
2011-04-25 9:47 ` KAMEZAWA Hiroyuki
2011-04-25 17:13 ` Ying Han
2011-04-26 2:08 ` KOSAKI Motohiro
2011-04-22 4:24 ` [PATCH V7 8/9] Add per-memcg zone "unreclaimable" Ying Han
2011-04-22 4:43 ` KAMEZAWA Hiroyuki
2011-04-22 6:13 ` KOSAKI Motohiro
2011-04-22 6:17 ` Ying Han
2011-04-22 4:24 ` [PATCH V7 9/9] Enable per-memcg background reclaim Ying Han
2011-04-22 4: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=20110422145600.504b53d6.kamezawa.hiroyu@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=cl@linux.com \
--cc=dave@linux.vnet.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.com \
--cc=mel@csn.ul.ie \
--cc=mhocko@suse.cz \
--cc=minchan.kim@gmail.com \
--cc=nishimura@mxp.nes.nec.co.jp \
--cc=riel@redhat.com \
--cc=tj@kernel.org \
--cc=xemul@openvz.org \
--cc=yinghan@google.com \
--cc=zhu.yanhai@gmail.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