mm: memcontrol: eliminate raw access to stat and event counters
PATCH 1/3 mm: memcontrol: eliminate raw access to stat and event counters
From: Johannes Weiner <[email protected]>
commit c9019e9bf42e66d028d70d2da6206cad4dd9250d upstream
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.
--- include/linux/memcontrol.h | 31 +++++++++++++++--------- mm/memcontrol.c | 59 ++++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 45 deletions(-)
include/linux/memcontrol.h +20 -11
@@ -272,13 +272,6 @@ static inline bool mem_cgroup_disabled(void)return !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_reclaim(pg_data_t *pgdat, int order,gfp_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(struct mm_struct *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 +25 -34
144 lines not on this page · raw message
Signature · 1 line
2.16.6
Quoted 18 lines · Shaoying Xu
From: Johannes Weiner <[email protected]>
commit
c9019e9bf42e66d028d70d2da6206cad4dd9250dupstreamReplace all raw '
this_cpu_' modifications of the stat and event per-cpu counters with API functions such asmod_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]>Signed-off-by Linus Torvalds <[email protected]>Cc <[email protected]>Signed-off-by Shaoying Xu <[email protected]>
Quoted 4 lines
--- include/linux/memcontrol.h | 31 +++++++++++++++--------- mm/memcontrol.c | 59 ++++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 45 deletions(-)
All now queued up, thanks.
greg k-h