From: Johannes Weiner <hannes@cmpxchg.org>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, mhocko@suse.com, vdavydov.dev@gmail.com
Subject: Re: [patch 07/15] mm: memcontrol: fix excessive complexity in memory.stat reporting
Date: Fri, 1 Dec 2017 13:57:50 +0000 [thread overview]
Message-ID: <20171201135750.GB8097@cmpxchg.org> (raw)
In-Reply-To: <5a208303.hxMsAOT0gjSsd0Gf%akpm@linux-foundation.org>
On Thu, Nov 30, 2017 at 02:15:31PM -0800, akpm@linux-foundation.org wrote:
> @@ -1858,9 +1824,44 @@ static void drain_all_stock(struct mem_c
> static int memcg_hotplug_cpu_dead(unsigned int cpu)
> {
> struct memcg_stock_pcp *stock;
> + struct mem_cgroup *memcg;
>
> stock = &per_cpu(memcg_stock, cpu);
> drain_stock(stock);
> +
> + for_each_mem_cgroup(memcg) {
> + int i;
> +
> + for (i = 0; i < MEMCG_NR_STAT; i++) {
> + int nid;
> + long x;
> +
> + x = __this_cpu_xchg(memcg->stat_cpu->count[i], 0);
> + if (x)
> + atomic_long_add(x, &memcg->stat[i]);
> +
> + if (i >= NR_VM_NODE_STAT_ITEMS)
> + continue;
> +
> + for_each_node(nid) {
> + struct mem_cgroup_per_node *pn;
> +
> + pn = mem_cgroup_nodeinfo(memcg, nid);
> + x = __this_cpu_xchg(pn->lruvec_stat_cpu->count[i], 0);
> + if (x)
> + atomic_long_add(x, &pn->lruvec_stat[i]);
> + }
> + }
> +
> + for (i = 0; i < MEMCG_NR_EVENTS; i++) {
> + long x;
> +
> + x = __this_cpu_xchg(memcg->stat_cpu->events[i], 0);
> + if (x)
> + atomic_long_add(x, &memcg->events[i]);
> + }
> + }
> +
> return 0;
> }
The memcg cpu_dead callback can be called early during startup
(CONFIG_DEBUG_HOTPLUG_CPU0) with preemption enabled, which triggers a
warning in its __this_cpu_xchg() calls. But CPU locality is always
guaranteed, which is the only thing we really care about here.
Using the preemption-safe this_cpu_xchg() addresses this problem.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
Andrew, can you please merge this fixlet into the original patch?
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 40d1ef65fbd2..e616c1b0e458 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1836,7 +1836,7 @@ static int memcg_hotplug_cpu_dead(unsigned int cpu)
int nid;
long x;
- x = __this_cpu_xchg(memcg->stat_cpu->count[i], 0);
+ x = this_cpu_xchg(memcg->stat_cpu->count[i], 0);
if (x)
atomic_long_add(x, &memcg->stat[i]);
@@ -1847,7 +1847,7 @@ static int memcg_hotplug_cpu_dead(unsigned int cpu)
struct mem_cgroup_per_node *pn;
pn = mem_cgroup_nodeinfo(memcg, nid);
- x = __this_cpu_xchg(pn->lruvec_stat_cpu->count[i], 0);
+ x = this_cpu_xchg(pn->lruvec_stat_cpu->count[i], 0);
if (x)
atomic_long_add(x, &pn->lruvec_stat[i]);
}
@@ -1856,7 +1856,7 @@ static int memcg_hotplug_cpu_dead(unsigned int cpu)
for (i = 0; i < MEMCG_NR_EVENTS; i++) {
long x;
- x = __this_cpu_xchg(memcg->stat_cpu->events[i], 0);
+ x = this_cpu_xchg(memcg->stat_cpu->events[i], 0);
if (x)
atomic_long_add(x, &memcg->events[i]);
}
--
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:[~2017-12-01 13:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-30 22:15 [patch 07/15] mm: memcontrol: fix excessive complexity in memory.stat reporting akpm
2017-12-01 13:57 ` Johannes Weiner [this message]
2017-12-07 1:06 ` Andrew Morton
2018-01-12 17:05 ` Johannes Weiner
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=20171201135750.GB8097@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=vdavydov.dev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.