mm-kmem-prepare-remote-memcg-charging-infra-for-interrupt-contexts.patch removed from -mm tree
The patch titled
Subject: mm: kmem: prepare remote memcg charging infra for interrupt contexts
has been removed from the -mm tree. Its filename was
mm-kmem-prepare-remote-memcg-charging-infra-for-interrupt-contexts.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Roman Gushchin <[email protected]>
Subject: mm: kmem: prepare remote memcg charging infra for interrupt contexts
Remote memcg charging API uses current->active_memcg to store the currently active memory cgroup, which overwrites the memory cgroup of the current process. It works well for normal contexts, but doesn't work for interrupt contexts: indeed, if an interrupt occurs during the execution of a section with an active memcg set, all allocations inside the interrupt will be charged to the active memcg set (given that we'll enable accounting for allocations from an interrupt context). But because the interrupt might have no relation to the active memcg set outside, it's obviously wrong from the accounting prospective.
To resolve this problem, let's add a global percpu int_active_memcg variable, which will be used to store an active memory cgroup which will be used from interrupt contexts. set_active_memcg() will transparently use current->active_memcg or int_active_memcg depending on the context.
To make the read part simple and transparent for the caller, let's introduce two new functions:
- struct mem_cgroup *active_memcg(void),
- struct mem_cgroup *get_active_memcg(void).
They are returning the active memcg if it's set, hiding all implementation
details: where to get it depending on the current context.
---
include/linux/sched/mm.h | 13 ++++++++-- mm/memcontrol.c | 48 ++++++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 16 deletions(-)
include/linux/sched/mm.h renamed from include/linux/sched/mm.h~mm-kmem-prepare-remote-memcg-charging-infra-for-interrupt-contexts +11 -2
@@ -279,6 +279,7 @@ static inline void memalloc_nocma_restor#endif #ifdef CONFIG_MEMCG +DECLARE_PER_CPU(struct mem_cgroup *, int_active_memcg);/** * set_active_memcg - Starts the remote memcg charging scope. * @memcg: memcg to charge.
@@ -293,8 +294,16 @@ static inline void memalloc_nocma_restorstatic inline struct mem_cgroup *set_active_memcg (struct mem_cgroup *memcg) { -struct mem_cgroup *old = current->active_memcg; - current->active_memcg = memcg; +struct mem_cgroup *old; + +if (in_interrupt ()) { + old =this_cpu_read (int_active_memcg); +this_cpu_write (int_active_memcg, memcg); + }else { + old = current->active_memcg; + current->active_memcg = memcg; + } +return old; }#else
mm/memcontrol.c renamed from mm/memcontrol.c~mm-kmem-prepare-remote-memcg-charging-infra-for-interrupt-contexts +34 -14
74 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are
mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings.patch mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings-fix.patch