[PATCH 4/4] mm: fix oom_kill event handling
Krzysztof Kozlowski
krzysztof.kozlowski at canonical.com
Fri Apr 30 07:36:00 UTC 2021
On 29/04/2021 20:54, Tim Gardner wrote:
> From: Roman Gushchin <guro at fb.com>
>
> BugLink: https://bugs.launchpad.net/bugs/1926081
>
> 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 at 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 at fb.com>
> Acked-by: Konstantin Khlebnikov <khlebnikov at yandex-team.ru>
> Acked-by: Johannes Weiner <hannes at cmpxchg.org>
> Acked-by: Michal Hocko <mhocko at suse.com>
> Cc: Vladimir Davydov <vdavydov.dev at gmail.com>
> Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
> Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
> (backported from commit fe6bdfc8e1e131720abbe77a2eb990c94c9024cb)
> [rtg - context adjustments]
> Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
> ---
> include/linux/memcontrol.h | 26 ++++++++++++++++++++++----
> mm/memcontrol.c | 6 ++++--
> mm/oom_kill.c | 2 +-
> 3 files changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index c7876eadd206d..b5cd86e320ff3 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -53,6 +53,7 @@ enum memcg_memory_event {
> MEMCG_HIGH,
> MEMCG_MAX,
> MEMCG_OOM,
> + MEMCG_OOM_KILL,
> MEMCG_NR_MEMORY_EVENTS,
> };
>
> @@ -706,11 +707,8 @@ static inline void count_memcg_event_mm(struct mm_struct *mm,
>
> rcu_read_lock();
> memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
> - if (likely(memcg)) {
> + if (likely(memcg))
> count_memcg_events(memcg, idx, 1);
> - if (idx == OOM_KILL)
> - cgroup_file_notify(&memcg->events_file);
> - }
> rcu_read_unlock();
> }
>
> @@ -721,6 +719,21 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg,
> cgroup_file_notify(&memcg->events_file);
> }
>
> +static inline void memcg_memory_event_mm(struct mm_struct *mm,
> + enum memcg_memory_event event)
> +{
> + struct mem_cgroup *memcg;
> +
> + if (mem_cgroup_disabled())
> + return;
> +
> + rcu_read_lock();
> + memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
> + if (likely(memcg))
> + memcg_memory_event(memcg, event);
> + rcu_read_unlock();
> +}
I cannot find memcg_memory_event() in bionic/linux. Does this compile?
Best regards,
Krzysztof
More information about the kernel-team
mailing list