diff options
author | Shakeel Butt <shakeel.butt@linux.dev> | 2024-08-14 22:04:49 -0700 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2024-09-01 20:26:19 -0700 |
commit | 7d7602b4bed9b4e70c3c0650791b6b4531733a42 (patch) | |
tree | 8500644e6396e0fbdfda994603918ee93946fbd9 | |
parent | 41213dd0f81654f0a7863bb5b07a2ebaaf732ebe (diff) |
memcg: move mem_cgroup_charge_statistics to v1 code
There are no callers of mem_cgroup_charge_statistics() in the v2 code
base, so move it to the v1 only code and rename it to
memcg1_charge_statistics().
Link: https://lkml.kernel.org/r/20240815050453.1298138-4-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: T.J. Mercier <tjmercier@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | mm/memcontrol-v1.c | 17 | ||||
-rw-r--r-- | mm/memcontrol-v1.h | 3 | ||||
-rw-r--r-- | mm/memcontrol.c | 19 |
3 files changed, 20 insertions, 19 deletions
diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c index 38809a26089a..7317f2ce8876 100644 --- a/mm/memcontrol-v1.c +++ b/mm/memcontrol-v1.c @@ -853,9 +853,9 @@ static int mem_cgroup_move_account(struct folio *folio, nid = folio_nid(folio); local_irq_disable(); - mem_cgroup_charge_statistics(to, nr_pages); + memcg1_charge_statistics(to, nr_pages); memcg1_check_events(to, nid); - mem_cgroup_charge_statistics(from, -nr_pages); + memcg1_charge_statistics(from, -nr_pages); memcg1_check_events(from, nid); local_irq_enable(); out: @@ -1439,6 +1439,19 @@ static void mem_cgroup_threshold(struct mem_cgroup *memcg) } } +void memcg1_charge_statistics(struct mem_cgroup *memcg, int nr_pages) +{ + /* pagein of a big page is an event. So, ignore page size */ + if (nr_pages > 0) + __count_memcg_events(memcg, PGPGIN, 1); + else { + __count_memcg_events(memcg, PGPGOUT, 1); + nr_pages = -nr_pages; /* for event */ + } + + __this_cpu_add(memcg->events_percpu->nr_page_events, nr_pages); +} + #define THRESHOLDS_EVENTS_TARGET 128 #define SOFTLIMIT_EVENTS_TARGET 1024 diff --git a/mm/memcontrol-v1.h b/mm/memcontrol-v1.h index fb7d439f19de..ef72d0b7c5c6 100644 --- a/mm/memcontrol-v1.h +++ b/mm/memcontrol-v1.h @@ -7,7 +7,6 @@ /* Cgroup v1 and v2 common declarations */ -void mem_cgroup_charge_statistics(struct mem_cgroup *memcg, int nr_pages); int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask, unsigned int nr_pages); @@ -116,6 +115,7 @@ bool memcg1_oom_prepare(struct mem_cgroup *memcg, bool *locked); void memcg1_oom_finish(struct mem_cgroup *memcg, bool locked); void memcg1_oom_recover(struct mem_cgroup *memcg); +void memcg1_charge_statistics(struct mem_cgroup *memcg, int nr_pages); void memcg1_check_events(struct mem_cgroup *memcg, int nid); void memcg1_stat_format(struct mem_cgroup *memcg, struct seq_buf *s); @@ -147,6 +147,7 @@ static inline bool memcg1_oom_prepare(struct mem_cgroup *memcg, bool *locked) { static inline void memcg1_oom_finish(struct mem_cgroup *memcg, bool locked) {} static inline void memcg1_oom_recover(struct mem_cgroup *memcg) {} +static inline void memcg1_charge_statistics(struct mem_cgroup *memcg, int nr_pages) {} static inline void memcg1_check_events(struct mem_cgroup *memcg, int nid) {} static inline void memcg1_stat_format(struct mem_cgroup *memcg, struct seq_buf *s) {} diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 35dec7e38870..059c9e0ba350 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -840,19 +840,6 @@ unsigned long memcg_events_local(struct mem_cgroup *memcg, int event) return READ_ONCE(memcg->vmstats->events_local[i]); } -void mem_cgroup_charge_statistics(struct mem_cgroup *memcg, int nr_pages) -{ - /* pagein of a big page is an event. So, ignore page size */ - if (nr_pages > 0) - __count_memcg_events(memcg, PGPGIN, 1); - else { - __count_memcg_events(memcg, PGPGOUT, 1); - nr_pages = -nr_pages; /* for event */ - } - - __this_cpu_add(memcg->events_percpu->nr_page_events, nr_pages); -} - struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) { /* @@ -2366,7 +2353,7 @@ void mem_cgroup_commit_charge(struct folio *folio, struct mem_cgroup *memcg) commit_charge(folio, memcg); local_irq_disable(); - mem_cgroup_charge_statistics(memcg, folio_nr_pages(folio)); + memcg1_charge_statistics(memcg, folio_nr_pages(folio)); memcg1_check_events(memcg, folio_nid(folio)); local_irq_enable(); } @@ -4742,7 +4729,7 @@ void mem_cgroup_replace_folio(struct folio *old, struct folio *new) commit_charge(new, memcg); local_irq_save(flags); - mem_cgroup_charge_statistics(memcg, nr_pages); + memcg1_charge_statistics(memcg, nr_pages); memcg1_check_events(memcg, folio_nid(new)); local_irq_restore(flags); } @@ -4987,7 +4974,7 @@ void mem_cgroup_swapout(struct folio *folio, swp_entry_t entry) * only synchronisation we have for updating the per-CPU variables. */ memcg_stats_lock(); - mem_cgroup_charge_statistics(memcg, -nr_entries); + memcg1_charge_statistics(memcg, -nr_entries); memcg_stats_unlock(); memcg1_check_events(memcg, folio_nid(folio)); |