UPSTREAM: mm: memcg: make sure is uptodate when waking pollers

Commit a983b5ebee57 ("mm: memcontrol: fix excessive complexity in
memory.stat reporting") added per-cpu drift to all memory cgroup stats
and events shown in memory.stat and

For memory.stat this is acceptable.  But issues file
notifications, and somebody polling the file for changes will be
confused when the counters in it are unchanged after a wakeup.

Luckily, the events in - MEMCG_LOW, MEMCG_HIGH, MEMCG_MAX,
MEMCG_OOM - are sufficiently rare and high-level that we don't need
per-cpu buffering for them: MEMCG_HIGH and MEMCG_MAX would be the most
frequent, but they're counting invocations of reclaim, which is a
complex operation that touches many shared cachelines.

This splits from the generic VM events and tracks them in
their own, unbuffered atomic counters.  That's also cleaner, as it
eliminates the ugly enum nesting of VM and cgroup events.

[ "array subscript is above array bounds"]
Fixes: a983b5ebee57 ("mm: memcontrol: fix excessive complexity in memory.stat reporting")
Signed-off-by: Johannes Weiner <>
Reported-by: Tejun Heo <>
Acked-by: Tejun Heo <>
Acked-by: Michal Hocko <>
Cc: Vladimir Davydov <>
Cc: Roman Gushchin <>
Cc: Rik van Riel <>
Cc: Stephen Rothwell <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
(cherry picked from commit e27be240df53f1a20c659168e722b5d9f16cc7f4)
Signed-off-by: vaibhavrustagi <>

TEST=tryjob and validation test. Tested with the repro steps for creating zombies.

Change-Id: Iefd7d7d3327ef340dd0e825bd20479cbb4bf78e1
(cherry picked from commit 685af806625a877a1b8400a14561811e822be183)
Reviewed-by: Guenter Roeck <>
Reviewed-by: Sean Paul <>
Reviewed-by: Greg Thelen <>
Commit-Queue: Vaibhav Rustagi <>
Tested-by: Vaibhav Rustagi <>
3 files changed