mm: memcontrol: eliminate raw access to stat and event counters
Subsystems (2)
[email protected]
maintainerPATCH 42/119 mm: memcontrol: eliminate raw access to stat and event counters
From: Johannes Weiner <[email protected]>
Subject: mm: memcontrol: eliminate raw access to stat and event counters
Replace all raw 'this_cpu_' modifications of the stat and event per-cpu counters with API functions such as mod_memcg_state().
This makes the code easier to read, but is also in preparation for the next patch, which changes the per-cpu implementation of those counters.
Signed-off-by Johannes Weiner <[email protected]>
Acked-by Vladimir Davydov <[email protected]>
Cc Michal Hocko <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
include/linux/memcontrol.h | 31 +++++++++++------- mm/memcontrol.c | 59 ++++++++++++++--------------------- 2 files changed, 45 insertions(+), 45 deletions(-)
include/linux/memcontrol.h renamed from include/linux/memcontrol.h~mm-memcontrol-eliminate-raw-access-to-stat-and-event-counters +20 -11
@@ -272,13 +272,6 @@ static inline bool mem_cgroup_disabled(vreturn !cgroup_subsys_enabled (memory_cgrp_subsys); } -static inline void mem_cgroup_event (struct mem_cgroup *memcg, -enum memcg_event_item event) -{ -this_cpu_inc (memcg->stat->events[event]); -cgroup_file_notify (&memcg->events_file); -} -bool mem_cgroup_low (struct mem_cgroup *root,struct mem_cgroup *memcg); int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
@@ -627,15 +620,23 @@ unsigned long mem_cgroup_soft_limit_reclgfp_t gfp_mask, unsigned long *total_scanned); +/* idx can be of type enum memcg_event_item or vm_event_item */ +static inline void __count_memcg_events (struct mem_cgroup *memcg, +int idx,unsigned long count) +{ +if (!mem_cgroup_disabled ()) +__this_cpu_add (memcg->stat->events[idx], count); +} + +/* idx can be of type enum memcg_event_item or vm_event_item */ static inline void count_memcg_events (struct mem_cgroup *memcg, -enum vm_event_item idx, -unsigned long count) +int idx,unsigned long count) {if (!mem_cgroup_disabled ())this_cpu_add (memcg->stat->events[idx], count); } -/* idx can be of type enum memcg_stat_item or node_stat_item */ +/* idx can be of type enum memcg_event_item or vm_event_item */ static inline void count_memcg_page_event (struct page *page,int idx) {
@@ -654,12 +655,20 @@ static inline void count_memcg_event_mm(rcu_read_lock (); memcg =mem_cgroup_from_task (rcu_dereference (mm->owner));if (likely (memcg)) { -this_cpu_inc (memcg->stat->events[idx]); +count_memcg_events (memcg, idx,1 );if (idx ==OOM_KILL )cgroup_file_notify (&memcg->events_file); }rcu_read_unlock (); } + +static inline void mem_cgroup_event (struct mem_cgroup *memcg, +enum memcg_event_item event) +{ +count_memcg_events (memcg, event,1 ); +cgroup_file_notify (&memcg->events_file); +} +#ifdef CONFIG_TRANSPARENT_HUGEPAGE void mem_cgroup_split_huge_fixup (struct page *head);#endif
mm/memcontrol.c renamed from mm/memcontrol.c~mm-memcontrol-eliminate-raw-access-to-stat-and-event-counters +25 -34
144 lines not on this page · raw message
_