All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drop_caches: re-enable message after disabling
@ 2025-02-16 10:05 Ruiwu Chen
  2025-02-21  8:50 ` Joel Granados
  0 siblings, 1 reply; 16+ messages in thread
From: Ruiwu Chen @ 2025-02-16 10:05 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel
  Cc: viro, brauner, jack, kees, joel.granados, Ruiwu Chen

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@gmail.com>
---
 fs/drop_caches.c | 7 +++++--
 kernel/sysctl.c  | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index d45ef541d848..c90cfaf9756d 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 stfu;
 
 		if (sysctl_drop_caches & 1) {
 			lru_add_drain_all();
@@ -73,7 +73,10 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
 				current->comm, task_pid_nr(current),
 				sysctl_drop_caches);
 		}
-		stfu |= sysctl_drop_caches & 4;
+		if (sysctl_drop_caches == 0)
+			stfu = false;
+		else if (sysctl_drop_caches == 4)
+			stfu = 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


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH] drop_caches: re-enable message after disabling
@ 2025-02-16 10:17 Ruiwu Chen
  2025-02-16 17:07 ` Darrick J. Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Ruiwu Chen @ 2025-02-16 10:17 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel
  Cc: viro, brauner, jack, kees, joel.granados, zachwade.k, Ruiwu Chen

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@gmail.com>
---
 fs/drop_caches.c | 7 +++++--
 kernel/sysctl.c  | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index d45ef541d848..c90cfaf9756d 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 stfu;
 
 		if (sysctl_drop_caches & 1) {
 			lru_add_drain_all();
@@ -73,7 +73,10 @@ int drop_caches_sysctl_handler(const struct ctl_table *table, int write,
 				current->comm, task_pid_nr(current),
 				sysctl_drop_caches);
 		}
-		stfu |= sysctl_drop_caches & 4;
+		if (sysctl_drop_caches == 0)
+			stfu = false;
+		else if (sysctl_drop_caches == 4)
+			stfu = 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


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2025-03-17 19:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [PATCH v2] " Ruiwu Chen
2025-02-23 17:22     ` 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-16 17:07 ` Darrick J. Wong
2025-02-17  8:28 ` Christian Brauner
2025-02-21  8:52 ` Joel Granados

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.