From: Roman Gushchin <roman.gushchin@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Shakeel Butt <shakeel.butt@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Roman Gushchin <roman.gushchin@linux.dev>
Subject: [PATCH v2 2/5] mm: page_counters: put page_counter_calculate_protection() under CONFIG_MEMCG
Date: Wed, 24 Jul 2024 20:21:00 +0000 [thread overview]
Message-ID: <20240724202103.1210065-3-roman.gushchin@linux.dev> (raw)
In-Reply-To: <20240724202103.1210065-1-roman.gushchin@linux.dev>
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.
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
---
include/linux/page_counter.h | 6 ++++++
mm/page_counter.c | 2 ++
2 files changed, 8 insertions(+)
diff --git a/include/linux/page_counter.h b/include/linux/page_counter.h
index b31fd5b208aa..d85fc7df3280 100644
--- a/include/linux/page_counter.h
+++ b/include/linux/page_counter.h
@@ -91,8 +91,14 @@ static inline void page_counter_reset_watermark(struct page_counter *counter)
counter->local_watermark = usage;
}
+#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 a54382a58ace..b249d15af9dd 100644
--- a/mm/page_counter.c
+++ b/mm/page_counter.c
@@ -288,6 +288,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
@@ -459,3 +460,4 @@ void page_counter_calculate_protection(struct page_counter *root,
atomic_long_read(&parent->children_low_usage),
recursive_protection));
}
+#endif /* CONFIG_MEMCG */
--
2.46.0.rc1.232.g9752f9e123-goog
next prev parent reply other threads:[~2024-07-24 20:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 20:20 [PATCH v2 0/5] This patchset reorganizes page_counter structures which helps to make Roman Gushchin
2024-07-24 20:20 ` [PATCH v2 1/5] mm: memcg: don't call propagate_protected_usage() needlessly Roman Gushchin
2024-07-24 20:52 ` Shakeel Butt
2024-07-24 23:13 ` Yosry Ahmed
2024-07-24 23:31 ` Roman Gushchin
2024-07-24 23:35 ` Yosry Ahmed
2024-07-24 20:21 ` Roman Gushchin [this message]
2024-07-24 23:05 ` [PATCH v2 2/5] mm: page_counters: put page_counter_calculate_protection() under CONFIG_MEMCG Shakeel Butt
2024-07-24 20:21 ` [PATCH v2 3/5] mm: memcg: merge multiple page_counters into a single structure Roman Gushchin
2024-07-24 23:43 ` Shakeel Butt
2024-07-25 21:42 ` Johannes Weiner
2024-07-25 23:33 ` Roman Gushchin
2024-07-26 23:31 ` Johannes Weiner
2024-07-24 20:21 ` [PATCH v2 4/5] mm: page_counters: initialize usage using ATOMIC_LONG_INIT() macro Roman Gushchin
2024-07-24 23:45 ` Shakeel Butt
2024-07-24 20:21 ` [PATCH v2 5/5] mm: memcg: convert enum res_type to mem_counter_type Roman Gushchin
2024-07-24 23:48 ` Shakeel Butt
2024-07-24 23:54 ` Roman Gushchin
2024-07-24 20:40 ` [PATCH v2 0/5] This patchset reorganizes page_counter structures which helps to make Roman Gushchin
2024-07-24 22:17 ` Shakeel Butt
2024-07-24 22:30 ` Roman Gushchin
2024-07-25 21:42 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240724202103.1210065-3-roman.gushchin@linux.dev \
--to=roman.gushchin@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=shakeel.butt@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox