[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250217173333.2448-1-rwchen404@gmail.com>
Date: Tue, 18 Feb 2025 01:33:33 +0800
From: Ruiwu Chen <rwchen404@...il.com>
To: linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
linux-doc@...r.kernel.org
Cc: corbet@....net,
viro@...iv.linux.org.uk,
mcgrof@...nel.org,
keescook@...omium.org,
zachwade.k@...il.com,
Ruiwu Chen <rwchen404@...il.com>
Subject: [PATCH v2] drop_caches: re-enable message after disabling
When 'echo 4 > /proc/sys/vm/drop_caches' the message is disabled,
but there is no interface to enable the message, only by restarting
the way, so I want to add the 'echo 0 > /proc/sys/vm/drop_caches'
way to enabled the message again.
Signed-off-by: Ruiwu Chen <rwchen404@...il.com>
---
v2: - updated Documentation/ to note this new API.
- renamed the variable.
Documentation/admin-guide/sysctl/vm.rst | 11 ++++++++++-
fs/drop_caches.c | 9 ++++++---
kernel/sysctl.c | 2 +-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admin-guide/sysctl/vm.rst
index f48eaa98d22d..1b9ae9bc6cf9 100644
--- a/Documentation/admin-guide/sysctl/vm.rst
+++ b/Documentation/admin-guide/sysctl/vm.rst
@@ -266,7 +266,16 @@ used::
cat (1234): drop_caches: 3
These are informational only. They do not mean that anything is wrong
-with your system. To disable them, echo 4 (bit 2) into drop_caches.
+with your system.
+
+To disable informational::
+
+ echo 4 > /proc/sys/vm/drop_caches
+
+To enable informational::
+
+ echo 0 > /proc/sys/vm/drop_caches
+
enable_soft_offline
===================
diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index d45ef541d848..5d02c1d99d9f 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -57,7 +57,7 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
if (ret)
return ret;
if (write) {
- static int stfu;
+ static bool silent;
if (sysctl_drop_caches & 1) {
lru_add_drain_all();
@@ -68,12 +68,15 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
drop_slab();
count_vm_event(DROP_SLAB);
}
- if (!stfu) {
+ if (!silent) {
pr_info("%s (%d): drop_caches: %d\n",
current->comm, task_pid_nr(current),
sysctl_drop_caches);
}
- stfu |= sysctl_drop_caches & 4;
+ if (sysctl_drop_caches == 0)
+ silent = false;
+ else if (sysctl_drop_caches == 4)
+ silent = true;
}
return 0;
}
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index cb57da499ebb..f2e06e074724 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2088,7 +2088,7 @@ static const struct ctl_table vm_table[] = {
.maxlen = sizeof(int),
.mode = 0200,
.proc_handler = drop_caches_sysctl_handler,
- .extra1 = SYSCTL_ONE,
+ .extra1 = SYSCTL_ZERO,
.extra2 = SYSCTL_FOUR,
},
{
--
2.27.0
Powered by blists - more mailing lists