From: Greg Thelen <gthelen@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
containers@lists.osdl.org, Andrea Righi <arighi@develer.com>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
Minchan Kim <minchan.kim@gmail.com>,
Ciju Rajan K <ciju@linux.vnet.ibm.com>,
David Rientjes <rientjes@google.com>
Subject: [PATCH v3 08/11] memcg: CPU hotplug lockdep warning fix
Date: Mon, 18 Oct 2010 17:39:41 -0700 [thread overview]
Message-ID: <1287448784-25684-9-git-send-email-gthelen@google.com> (raw)
In-Reply-To: <1287448784-25684-1-git-send-email-gthelen@google.com>
From: Balbir Singh <balbir@linux.vnet.ibm.com>
memcg has lockdep warnings (sleep inside rcu lock)
From: Balbir Singh <balbir@linux.vnet.ibm.com>
Recent move to get_online_cpus() ends up calling get_online_cpus() from
mem_cgroup_read_stat(). However mem_cgroup_read_stat() is called under rcu
lock. get_online_cpus() can sleep. The dirty limit patches expose
this BUG more readily due to their usage of mem_cgroup_page_stat()
This patch address this issue as identified by lockdep and moves the
hotplug protection to a higher layer. This might increase the time
required to hotplug, but not by much.
Warning messages
BUG: sleeping function called from invalid context at kernel/cpu.c:62
in_atomic(): 0, irqs_disabled(): 0, pid: 6325, name: pagetest
2 locks held by pagetest/6325:
do_page_fault+0x27d/0x4a0
mem_cgroup_page_stat+0x0/0x23f
Pid: 6325, comm: pagetest Not tainted 2.6.36-rc5-mm1+ #201
Call Trace:
[<ffffffff81041224>] __might_sleep+0x12d/0x131
[<ffffffff8104f4af>] get_online_cpus+0x1c/0x51
[<ffffffff8110eedb>] mem_cgroup_read_stat+0x27/0xa3
[<ffffffff811125d2>] mem_cgroup_page_stat+0x131/0x23f
[<ffffffff811124a1>] ? mem_cgroup_page_stat+0x0/0x23f
[<ffffffff810d57c3>] global_dirty_limits+0x42/0xf8
[<ffffffff810d58b3>] throttle_vm_writeout+0x3a/0xb4
[<ffffffff810dc2f8>] shrink_zone+0x3e6/0x3f8
[<ffffffff81074a35>] ? ktime_get_ts+0xb2/0xbf
[<ffffffff810dd1aa>] do_try_to_free_pages+0x106/0x478
[<ffffffff810dd601>] try_to_free_mem_cgroup_pages+0xe5/0x14c
[<ffffffff8110f947>] mem_cgroup_hierarchical_reclaim+0x314/0x3a2
[<ffffffff81111b31>] __mem_cgroup_try_charge+0x29b/0x593
[<ffffffff8111194a>] ? __mem_cgroup_try_charge+0xb4/0x593
[<ffffffff81071258>] ? local_clock+0x40/0x59
[<ffffffff81009015>] ? sched_clock+0x9/0xd
[<ffffffff810710d5>] ? sched_clock_local+0x1c/0x82
[<ffffffff8111398a>] mem_cgroup_charge_common+0x4b/0x76
[<ffffffff81141469>] ? bio_add_page+0x36/0x38
[<ffffffff81113ba9>] mem_cgroup_cache_charge+0x1f4/0x214
[<ffffffff810cd195>] add_to_page_cache_locked+0x4a/0x148
....
Acked-by: Greg Thelen <gthelen@google.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
---
mm/memcontrol.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f876919..412ce73 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -588,7 +588,6 @@ static s64 mem_cgroup_read_stat(struct mem_cgroup *mem,
int cpu;
s64 val = 0;
- get_online_cpus();
for_each_online_cpu(cpu)
val += per_cpu(mem->stat->count[idx], cpu);
#ifdef CONFIG_HOTPLUG_CPU
@@ -596,7 +595,6 @@ static s64 mem_cgroup_read_stat(struct mem_cgroup *mem,
val += mem->nocpu_base.count[idx];
spin_unlock(&mem->pcp_counter_lock);
#endif
- put_online_cpus();
return val;
}
@@ -1300,6 +1298,7 @@ s64 mem_cgroup_page_stat(enum mem_cgroup_nr_pages_item item)
struct mem_cgroup *iter;
s64 value;
+ get_online_cpus();
rcu_read_lock();
mem = mem_cgroup_from_task(current);
if (mem && !mem_cgroup_is_root(mem)) {
@@ -1321,6 +1320,7 @@ s64 mem_cgroup_page_stat(enum mem_cgroup_nr_pages_item item)
} else
value = -EINVAL;
rcu_read_unlock();
+ put_online_cpus();
return value;
}
--
1.7.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>
next prev parent reply other threads:[~2010-10-19 0:43 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-19 0:39 [PATCH v3 00/11] memcg: per cgroup dirty page accounting Greg Thelen
2010-10-19 0:39 ` [PATCH v3 01/11] memcg: add page_cgroup flags for dirty page tracking Greg Thelen
2010-10-19 4:31 ` Daisuke Nishimura
2010-10-19 0:39 ` [PATCH v3 02/11] memcg: document cgroup dirty memory interfaces Greg Thelen
2010-10-19 0:46 ` KAMEZAWA Hiroyuki
2010-10-19 8:27 ` Daisuke Nishimura
2010-10-19 21:00 ` Greg Thelen
2010-10-20 0:11 ` KAMEZAWA Hiroyuki
2010-10-20 0:45 ` Greg Thelen
2010-10-20 4:06 ` KAMEZAWA Hiroyuki
2010-10-20 4:25 ` Greg Thelen
2010-10-20 4:26 ` KAMEZAWA Hiroyuki
2010-10-20 0:48 ` Daisuke Nishimura
2010-10-20 1:14 ` KAMEZAWA Hiroyuki
2010-10-20 2:24 ` KAMEZAWA Hiroyuki
2010-10-20 3:47 ` Daisuke Nishimura
2010-10-19 0:39 ` [PATCH v3 03/11] memcg: create extensible page stat update routines Greg Thelen
2010-10-19 0:47 ` KAMEZAWA Hiroyuki
2010-10-19 4:52 ` Daisuke Nishimura
2010-10-19 0:39 ` [PATCH v3 04/11] memcg: add lock to synchronize page accounting and migration Greg Thelen
2010-10-19 0:45 ` KAMEZAWA Hiroyuki
2010-10-19 4:43 ` [RFC][PATCH 1/2] memcg: move_account optimization by reduct put,get page (Re: " KAMEZAWA Hiroyuki
2010-10-19 4:45 ` [RFC][PATCH 2/2] memcg: move_account optimization by reduce locks " KAMEZAWA Hiroyuki
2010-10-19 1:17 ` Minchan Kim
2010-10-19 5:03 ` Daisuke Nishimura
2010-10-19 0:39 ` [PATCH v3 05/11] memcg: add dirty page accounting infrastructure Greg Thelen
2010-10-19 0:49 ` KAMEZAWA Hiroyuki
2010-10-20 0:53 ` Daisuke Nishimura
2010-10-19 0:39 ` [PATCH v3 06/11] memcg: add kernel calls for memcg dirty page stats Greg Thelen
2010-10-19 0:51 ` KAMEZAWA Hiroyuki
2010-10-19 7:03 ` Daisuke Nishimura
2010-10-19 0:39 ` [PATCH v3 07/11] memcg: add dirty limits to mem_cgroup Greg Thelen
2010-10-19 0:53 ` KAMEZAWA Hiroyuki
2010-10-20 0:50 ` Daisuke Nishimura
2010-10-20 4:08 ` Greg Thelen
2010-10-19 0:39 ` Greg Thelen [this message]
2010-10-19 0:54 ` [PATCH v3 08/11] memcg: CPU hotplug lockdep warning fix KAMEZAWA Hiroyuki
2010-10-20 3:47 ` Daisuke Nishimura
2010-10-19 0:39 ` [PATCH v3 09/11] memcg: add cgroupfs interface to memcg dirty limits Greg Thelen
2010-10-19 0:56 ` KAMEZAWA Hiroyuki
2010-10-20 3:31 ` Daisuke Nishimura
2010-10-20 3:44 ` KAMEZAWA Hiroyuki
2010-10-20 3:46 ` Daisuke Nishimura
2010-10-19 0:39 ` [PATCH v3 10/11] writeback: make determine_dirtyable_memory() static Greg Thelen
2010-10-19 0:57 ` KAMEZAWA Hiroyuki
2010-10-20 3:47 ` Daisuke Nishimura
2010-10-19 0:39 ` [PATCH v3 11/11] memcg: check memcg dirty limits in page writeback Greg Thelen
2010-10-19 1:00 ` KAMEZAWA Hiroyuki
2010-10-20 4:18 ` KAMEZAWA Hiroyuki
2010-10-20 4:33 ` Greg Thelen
2010-10-20 4:33 ` KAMEZAWA Hiroyuki
2010-10-20 4:34 ` Daisuke Nishimura
2010-10-20 5:25 ` Daisuke Nishimura
2010-10-20 3:21 ` [PATCH][memcg+dirtylimit] Fix overwriting global vm dirty limit setting by memcg (Re: [PATCH v3 00/11] memcg: per cgroup dirty page accounting KAMEZAWA Hiroyuki
2010-10-20 4:14 ` KAMEZAWA Hiroyuki
2010-10-20 5:02 ` [PATCH v2][memcg+dirtylimit] " KAMEZAWA Hiroyuki
2010-10-20 6:09 ` Daisuke Nishimura
2010-10-20 14:35 ` Minchan Kim
2010-10-21 0:10 ` KAMEZAWA Hiroyuki
2010-10-24 18:44 ` Greg Thelen
2010-10-25 0:24 ` KAMEZAWA Hiroyuki
2010-10-25 2:00 ` Daisuke Nishimura
2010-10-25 7:03 ` Ciju Rajan K
2010-10-25 7:08 ` 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=1287448784-25684-9-git-send-email-gthelen@google.com \
--to=gthelen@google.com \
--cc=akpm@linux-foundation.org \
--cc=arighi@develer.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=ciju@linux.vnet.ibm.com \
--cc=containers@lists.osdl.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan.kim@gmail.com \
--cc=nishimura@mxp.nes.nec.co.jp \
--cc=rientjes@google.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