[RFC 1/5] Kconfig: add SWAP_CHARGE_V1_MODE config

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Zeng Jingxiang <linuszeng@xxxxxxxxxxx>

Added SWAP_CHARGE_V1_MODE config, which is disabled by default.
When enabled in cgroupv2 mode, the memory accounting method of
swap will be restored to cgroupv1 mode.

Signed-off-by: Zeng Jingxiang <linuszeng@xxxxxxxxxxx>
---
 include/linux/memcontrol.h |  6 ++++++
 init/Kconfig               | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 53364526d877..dcb087ee6e8d 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -62,6 +62,12 @@ struct mem_cgroup_reclaim_cookie {
 
 #ifdef CONFIG_MEMCG
 
+/* Whether enable memory+swap account in cgroupv2 */
+static inline bool do_memsw_account_on_dfl(void)
+{
+	return IS_ENABLED(CONFIG_MEMSW_ACCOUNT_ON_DFL);
+}
+
 #define MEM_CGROUP_ID_SHIFT	16
 
 struct mem_cgroup_id {
diff --git a/init/Kconfig b/init/Kconfig
index 7f67d8942a09..669e39214244 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1012,6 +1012,22 @@ config MEMCG_V1
 
 	  Say N if unsure.
 
+config MEMSW_ACCOUNT_ON_DFL
+	bool "Whether enable memory+swap account in cgroup v2"
+	depends on MEMCG && MEMCG_V1
+	default n
+	help
+	  Say Y here to enable memory+swap account in cgroup v2. Enabling this
+	  option means that the semantics of memory.swap.max will align with
+	  memory.memsw.limit_in_bytes, and memory.swap.current will align with
+	  memory.memsw.usage_in_bytes.
+	  This is particularly useful for workloads that require strict memory
+	  and swap limits.
+
+	  If you are unsure whether to enable this option, it is recommended
+	  to leave it disabled (N) unless you specifically need memory and swap
+	  accounting features in your cgroup v2 setup.
+
 config BLK_CGROUP
 	bool "IO controller"
 	depends on BLOCK
-- 
2.41.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux