From: Roman Gushchin Date: Fri, 26 Jul 2024 20:31:09 +0000 (+0000) Subject: mm: page_counters: put page_counter_calculate_protection() under CONFIG_MEMCG X-Git-Tag: v6.12-rc1~115^2~385 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=941ce635234162c420c9185816c59f7d5dd1ad07;p=thirdparty%2Fkernel%2Flinux.git mm: page_counters: put page_counter_calculate_protection() under CONFIG_MEMCG Put page_counter_calculate_protection() under CONFIG_MEMCG. The protection functionality (min/low limits) is not supported by any other cgroup subsystem, so page_counter_calculate_protection() and related static effective_protection() can be compiled out if CONFIG_MEMCG is not enabled. Link: https://lkml.kernel.org/r/20240726203110.1577216-3-roman.gushchin@linux.dev Signed-off-by: Roman Gushchin Acked-by: Shakeel Butt Acked-by: Johannes Weiner Cc: Michal Hocko Cc: Muchun Song Signed-off-by: Andrew Morton --- diff --git a/include/linux/page_counter.h b/include/linux/page_counter.h index 0b8e993f91637..1b3e92c09b80a 100644 --- a/include/linux/page_counter.h +++ b/include/linux/page_counter.h @@ -87,8 +87,14 @@ static inline void page_counter_reset_watermark(struct page_counter *counter) counter->watermark = page_counter_read(counter); } +#ifdef CONFIG_MEMCG void page_counter_calculate_protection(struct page_counter *root, struct page_counter *counter, bool recursive_protection); +#else +static inline void page_counter_calculate_protection(struct page_counter *root, + struct page_counter *counter, + bool recursive_protection) {} +#endif #endif /* _LINUX_PAGE_COUNTER_H */ diff --git a/mm/page_counter.c b/mm/page_counter.c index dd242245bee2b..3887bd152b756 100644 --- a/mm/page_counter.c +++ b/mm/page_counter.c @@ -275,6 +275,7 @@ int page_counter_memparse(const char *buf, const char *max, } +#ifdef CONFIG_MEMCG /* * This function calculates an individual page counter's effective * protection which is derived from its own memory.min/low, its @@ -446,3 +447,4 @@ void page_counter_calculate_protection(struct page_counter *root, atomic_long_read(&parent->children_low_usage), recursive_protection)); } +#endif /* CONFIG_MEMCG */