All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ruiwu Chen <rwchen404@gmail.com>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-doc@vger.kernel.org
Cc: corbet@lwn.net, viro@zeniv.linux.org.uk, mcgrof@kernel.org,
	keescook@chromium.org, zachwade.k@gmail.com,
	Ruiwu Chen <rwchen404@gmail.com>
Subject: [PATCH v2] drop_caches: re-enable message after disabling
Date: Sat, 22 Feb 2025 16:45:13 +0800	[thread overview]
Message-ID: <20250222084513.15832-1-rwchen404@gmail.com> (raw)
In-Reply-To: <virvi6vh663p5ypdjr2v2fr3o77w5st3cagr4fe6z7nhhqehc6@xb7nqlop6nct>

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 add the 'echo 0 > /proc/sys/vm/drop_caches' way to
enabled the message again.

Signed-off-by: Ruiwu Chen <rwchen404@gmail.com>
---
v2: - updated Documentation/ to note this new API.
    - renamed the variable.
    - rebase this on top of sysctl-next [1].
[1] https://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl.git/log/?h=sysctl-next

 Documentation/admin-guide/sysctl/vm.rst | 11 ++++++++++-
 fs/drop_caches.c                        | 11 +++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admin-guide/sysctl/vm.rst
index f48eaa98d22d..ef73d36e8b84 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 019a8b4eaaf9..a49af7023886 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -57,7 +57,7 @@ static 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 @@ static 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 = true;
+		else if (sysctl_drop_caches == 4)
+			silent = false;
 	}
 	return 0;
 }
@@ -85,7 +88,7 @@ static const struct ctl_table drop_caches_table[] = {
 		.maxlen		= sizeof(int),
 		.mode		= 0200,
 		.proc_handler	= drop_caches_sysctl_handler,
-		.extra1		= SYSCTL_ONE,
+		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_FOUR,
 	},
 };
-- 
2.27.0


  reply	other threads:[~2025-02-22  8:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-16 10:05 [PATCH] drop_caches: re-enable message after disabling Ruiwu Chen
2025-02-21  8:50 ` Joel Granados
2025-02-22  8:45   ` Ruiwu Chen [this message]
2025-02-23 17:22     ` [PATCH v2] " Luis Chamberlain
2025-03-08  8:05       ` Ruiwu Chen
2025-03-10 13:51         ` Joel Granados
2025-03-12 22:55           ` Luis Chamberlain
2025-03-13 15:19             ` Joel Granados
2025-03-13 15:52             ` Joel Granados
2025-03-14 12:28               ` Ruiwu Chen
2025-03-17 19:28                 ` Joel Granados
2025-03-11  3:53         ` Luis Chamberlain
  -- strict thread matches above, loose matches on Subject: below --
2025-02-16 10:17 [PATCH] " Ruiwu Chen
2025-02-20 13:18 ` [PATCH v2] " Ruiwu Chen
2025-02-17 17:33 Ruiwu Chen

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=20250222084513.15832-1-rwchen404@gmail.com \
    --to=rwchen404@gmail.com \
    --cc=corbet@lwn.net \
    --cc=keescook@chromium.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zachwade.k@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.