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>
Showing the changes to include/linux (1 of 3 files). Show all
Unified · Split
| @@ -53,6 +53,7 @@ enum memcg_memory_event { · 52 unmodified lines | |||
| 53 | MEMCG_HIGH, | 53 | MEMCG_HIGH, |
| 54 | MEMCG_MAX, | 54 | MEMCG_MAX, |
| 55 | MEMCG_OOM, | 55 | MEMCG_OOM, |
| 56 | MEMCG_OOM_KILL, | ||
| 56 | MEMCG_SWAP_MAX, | 57 | MEMCG_SWAP_MAX, |
| 57 | MEMCG_SWAP_FAIL, | 58 | MEMCG_SWAP_FAIL, |
| 58 | MEMCG_NR_MEMORY_EVENTS, | 59 | MEMCG_NR_MEMORY_EVENTS, |
| @@ -720,11 +721,8 @@ static inline void count_memcg_event_mm(struct mm_struct *mm, · 661 unmodified lines | |||
| 720 | 721 | ||
| 721 | rcu_read_lock(); | 722 | rcu_read_lock(); |
| 722 | memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); | 723 | memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); |
| 723 | if (likely(memcg)) { | 724 | if (likely(memcg)) |
| 724 | count_memcg_events(memcg, idx, 1); | 725 | count_memcg_events(memcg, idx, 1); |
| 725 | if (idx == OOM_KILL) | ||
| 726 | cgroup_file_notify(&memcg->events_file); | ||
| 727 | } | ||
| 728 | rcu_read_unlock(); | 726 | rcu_read_unlock(); |
| 729 | } | 727 | } |
| 730 | 728 | ||
| @@ -735,6 +733,21 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg, · 4 unmodified lines | |||
| 735 | cgroup_file_notify(&memcg->events_file); | 733 | cgroup_file_notify(&memcg->events_file); |
| 736 | } | 734 | } |
| 737 | 735 | ||
| 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 | |||
| 738 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 751 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
| 739 | void mem_cgroup_split_huge_fixup(struct page *head); | 752 | void mem_cgroup_split_huge_fixup(struct page *head); |
| 740 | #endif | 753 | #endif |
| @@ -756,6 +769,11 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg, · 15 unmodified lines | |||
| 756 | { | 769 | { |
| 757 | } | 770 | } |
| 758 | 771 | ||
| 772 | static inline void memcg_memory_event_mm(struct mm_struct *mm, | ||
| 773 | enum memcg_memory_event event) | ||
| 774 | { | ||
| 775 | } | ||
| 776 | |||
| 759 | static inline enum mem_cgroup_protection mem_cgroup_protected( | 777 | static inline enum mem_cgroup_protection mem_cgroup_protected( |
| 760 | struct mem_cgroup *root, struct mem_cgroup *memcg) | 778 | struct mem_cgroup *root, struct mem_cgroup *memcg) |
| 761 | { | 779 | { |