lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250319064148.774406-2-jingxiangzeng.cas@gmail.com>
Date: Wed, 19 Mar 2025 14:41:44 +0800
From: Jingxiang Zeng <jingxiangzeng.cas@...il.com>
To: akpm@...ux-foundation.org
Cc: linux-mm@...ck.org,
	cgroups@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	hannes@...xchg.org,
	mhocko@...nel.org,
	roman.gushchin@...ux.dev,
	shakeel.butt@...ux.dev,
	muchun.song@...ux.dev,
	kasong@...cent.com,
	Zeng Jingxiang <linuszeng@...cent.com>
Subject: [RFC 1/5] Kconfig: add SWAP_CHARGE_V1_MODE config

From: Zeng Jingxiang <linuszeng@...cent.com>

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@...cent.com>
---
 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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ