From: Mike Galbraith <umgwanakikbuti@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
linux-rt-users <linux-rt-users@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Carsten Emde <C.Emde@osadl.org>, John Kacur <jkacur@redhat.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <williams@redhat.com>
Subject: 3.14.23-rt20 - mm,memcg: make refill_stock()/consume_stock() use get_cpu_light()
Date: Sun, 02 Nov 2014 08:31:09 +0100 [thread overview]
Message-ID: <1414913469.5380.113.camel@marge.simpson.net> (raw)
In-Reply-To: <1414910967.5380.81.camel@marge.simpson.net>
Nikita reported the following memcg scheduling while atomic bug:
Call Trace:
[e22d5a90] [c0007ea8] show_stack+0x4c/0x168 (unreliable)
[e22d5ad0] [c0618c04] __schedule_bug+0x94/0xb0
[e22d5ae0] [c060b9ec] __schedule+0x530/0x550
[e22d5bf0] [c060bacc] schedule+0x30/0xbc
[e22d5c00] [c060ca24] rt_spin_lock_slowlock+0x180/0x27c
[e22d5c70] [c00b39dc] res_counter_uncharge_until+0x40/0xc4
[e22d5ca0] [c013ca88] drain_stock.isra.20+0x54/0x98
[e22d5cc0] [c01402ac] __mem_cgroup_try_charge+0x2e8/0xbac
[e22d5d70] [c01410d4] mem_cgroup_charge_common+0x3c/0x70
[e22d5d90] [c0117284] __do_fault+0x38c/0x510
[e22d5df0] [c011a5f4] handle_pte_fault+0x98/0x858
[e22d5e50] [c060ed08] do_page_fault+0x42c/0x6fc
[e22d5f40] [c000f5b4] handle_page_fault+0xc/0x80
What happens:
refill_stock()
get_cpu_var()
drain_stock()
res_counter_uncharge()
res_counter_uncharge_until()
spin_lock() <== boom
Fix it by replacing get/put_cpu_var() with get/put_cpu_light().
Reported-by: Nikita Yushchenko <nyushchenko@dev.rtsoft.ru>
Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
---
mm/memcontrol.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2438,16 +2438,18 @@ static bool consume_stock(struct mem_cgr
{
struct memcg_stock_pcp *stock;
bool ret = true;
+ int cpu;
if (nr_pages > CHARGE_BATCH)
return false;
- stock = &get_cpu_var(memcg_stock);
+ cpu = get_cpu_light();
+ stock = &per_cpu(memcg_stock, cpu);
if (memcg == stock->cached && stock->nr_pages >= nr_pages)
stock->nr_pages -= nr_pages;
else /* need to call res_counter_charge */
ret = false;
- put_cpu_var(memcg_stock);
+ put_cpu_light();
return ret;
}
@@ -2497,14 +2499,17 @@ static void __init memcg_stock_init(void
*/
static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
{
- struct memcg_stock_pcp *stock = &get_cpu_var(memcg_stock);
+ struct memcg_stock_pcp *stock;
+ int cpu = get_cpu_light();
+
+ stock = &per_cpu(memcg_stock, cpu);
if (stock->cached != memcg) { /* reset if necessary */
drain_stock(stock);
stock->cached = memcg;
}
stock->nr_pages += nr_pages;
- put_cpu_var(memcg_stock);
+ put_cpu_light();
}
/*
next prev parent reply other threads:[~2014-11-02 7:31 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-31 21:03 [ANNOUNCE] 3.14.23-rt20 Steven Rostedt
2014-11-02 7:30 ` Mike Galbraith
[not found] ` <CADLDEKvFvw7Aa98tVtM3z5JV8oocKqAdV4PqOMoZH2mXZ6x2jg@mail.gmail.com>
2014-11-05 14:04 ` Juerg Haefliger
2014-11-05 14:27 ` Steven Rostedt
2014-11-05 14:43 ` Juerg Haefliger
2014-11-05 15:00 ` Steven Rostedt
2014-11-05 15:35 ` Harry van Haaren
2014-11-05 15:44 ` Mike Galbraith
2014-11-05 16:07 ` Thomas Gleixner
2014-11-05 16:07 ` Thomas Gleixner
2014-11-05 22:29 ` Thomas Gleixner
2014-11-05 22:48 ` Steven Rostedt
2014-11-05 23:11 ` Thomas Gleixner
[not found] ` <1414910967.5380.81.camel@marge.simpson.net>
2014-11-02 7:30 ` 3.14.23-rt20 - sched/numa: Fix task_numa_free() lockdep splat Mike Galbraith
2014-11-02 7:31 ` 3.14.23-rt20 - wwmutex: fix __ww_mutex_lock_interruptible lockdep annotation Mike Galbraith
2014-11-02 7:31 ` Mike Galbraith [this message]
2014-11-02 7:31 ` 3.14.23-rt20 - fs,btrfs: fix rt deadlock on extent_buffer->lock Mike Galbraith
2015-02-17 11:56 ` Sebastian Andrzej Siewior
2015-02-17 12:23 ` Mike Galbraith
2015-02-18 10:47 ` Mike Galbraith
2014-11-02 7:31 ` 3.14.23-rt20 - aio: fix rcu garbage collection might_sleep() splat Mike Galbraith
2015-02-17 12:53 ` Sebastian Andrzej Siewior
2015-02-17 14:01 ` Mike Galbraith
2014-11-02 7:31 ` 3.14.23-rt20 - x86, UV: raw_spinlock conversion Mike Galbraith
2015-02-17 13:02 ` Sebastian Andrzej Siewior
2015-02-17 14:11 ` Mike Galbraith
2014-11-02 7:31 ` 3.14.23-rt20 - softirq: resurrect softirq threads Mike Galbraith
2015-02-17 13:05 ` Sebastian Andrzej Siewior
2015-02-17 14:00 ` Mike Galbraith
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=1414913469.5380.113.camel@marge.simpson.net \
--to=umgwanakikbuti@gmail.com \
--cc=C.Emde@osadl.org \
--cc=bigeasy@linutronix.de \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.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