History

mm: fix oom_kill event handling

Commit e27be240df53 ("mm: memcg: make sure memory.events is uptodate when waking pollers") converted most of memcg event counters to per-memcg atomics, which made them less confusing for a user. The "oom_kill" counter remained untouched, so now it behaves differently than other counters (including "oom"). This adds nothing but confusion. Let's fix this by adding the MEMCG_OOM_KILL event, and follow the MEMCG_OOM approach. This also removes a hack from count_memcg_event_mm(), introduced earlier specially for the OOM_KILL counter. [akpm@linux-foundation.org: fix for droppage of memcg-replace-mm-owner-with-mm-memcg.patch] Link: http://lkml.kernel.org/r/20180508124637.29984-1-guro@fb.com Signed-off-by: Roman Gushchin <guro@fb.com> Acked-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Vladimir Davydov <vdavydov.dev@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Roman Gushchin committed 8 years ago

Commit fe6bdfc1 parent d7dc8993 files · +27 −7Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/memcontrol.h+22−4
@@ -53,6 +53,7 @@ enum memcg_memory_event { · 52 unmodified lines
5353 MEMCG_HIGH,
5454 MEMCG_MAX,
5555 MEMCG_OOM,
56+ MEMCG_OOM_KILL,
5657 MEMCG_SWAP_MAX,
5758 MEMCG_SWAP_FAIL,
5859 MEMCG_NR_MEMORY_EVENTS,
@@ -720,11 +721,8 @@ static inline void count_memcg_event_mm(struct mm_struct *mm, · 661 unmodified lines
720721
721722 rcu_read_lock();
722723 memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
723− if (likely(memcg)) {
724+ if (likely(memcg))
724725 count_memcg_events(memcg, idx, 1);
725− if (idx == OOM_KILL)
726− cgroup_file_notify(&memcg->events_file);
727− }
728726 rcu_read_unlock();
729727 }
730728
@@ -735,6 +733,21 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg, · 4 unmodified lines
735733 cgroup_file_notify(&memcg->events_file);
736734 }
737735
736+static inline void memcg_memory_event_mm(struct mm_struct *mm,
737+ enum memcg_memory_event event)
738+{
739+ struct mem_cgroup *memcg;
740+
741+ if (mem_cgroup_disabled())
742+ return;
743+
744+ rcu_read_lock();
745+ memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
746+ if (likely(memcg))
747+ memcg_memory_event(memcg, event);
748+ rcu_read_unlock();
749+}
750+
738751 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
739752 void mem_cgroup_split_huge_fixup(struct page *head);
740753 #endif
@@ -756,6 +769,11 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg, · 15 unmodified lines
756769 {
757770 }
758771
772+static inline void memcg_memory_event_mm(struct mm_struct *mm,
773+ enum memcg_memory_event event)
774+{
775+}
776+
759777 static inline enum mem_cgroup_protection mem_cgroup_protected(
760778 struct mem_cgroup *root, struct mem_cgroup *memcg)
761779 {