diff mbox series

[v3,3/3] mm, migrc: Add a sysctl knob to enable/disable MIGRC mechanism

Message ID 20231030072540.38631-4-byungchul@sk.com (mailing list archive)
State New
Headers show
Series Reduce TLB flushes under some specific conditions | expand

Commit Message

Byungchul Park Oct. 30, 2023, 7:25 a.m. UTC
Add a sysctl knob, '/proc/sys/vm/migrc_enable' to switch on/off migrc.

Signed-off-by: Byungchul Park <byungchul@sk.com>
---
 mm/migrate.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

Comments

Nadav Amit Oct. 30, 2023, 8:51 a.m. UTC | #1
> On Oct 30, 2023, at 9:25 AM, Byungchul Park <byungchul@sk.com> wrote:
> 
> Add a sysctl knob, '/proc/sys/vm/migrc_enable' to switch on/off migrc.

Please explain how users are expected to use this knob.

I suspect that the knob and the config option are not useful. You probably
used them for your evaluation or as a “chicken-bit”, but they are not
useful anymore.
Byungchul Park Oct. 30, 2023, 10:36 a.m. UTC | #2
On Mon, Oct 30, 2023 at 08:51:35AM +0000, Nadav Amit wrote:
> 
> > On Oct 30, 2023, at 9:25 AM, Byungchul Park <byungchul@sk.com> wrote:
> > 
> > Add a sysctl knob, '/proc/sys/vm/migrc_enable' to switch on/off migrc.
> 
> Please explain how users are expected to use this knob.
> 
> I suspect that the knob and the config option are not useful. You probably
> used them for your evaluation or as a “chicken-bit”, but they are not
> useful anymore.

Okay. We can add the sysctl knob when we need it. Will remove it for now.

However, I'm not sure if it'd be okay without CONFIG_MIGRC. I'd like to
see more opinion on it before going with it.

	Byungchul
diff mbox series

Patch

diff --git a/mm/migrate.c b/mm/migrate.c
index 76278eca8417..f6bbdc2d4fb1 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -58,6 +58,48 @@ 
 #include "internal.h"
 
 #ifdef CONFIG_MIGRC
+static int sysctl_migrc_enable = 1;
+#ifdef CONFIG_SYSCTL
+static int sysctl_migrc_enable_handler(struct ctl_table *table, int write,
+		void *buffer, size_t *lenp, loff_t *ppos)
+{
+	struct ctl_table t;
+	int err;
+	int enabled = sysctl_migrc_enable;
+
+	if (write && !capable(CAP_SYS_ADMIN))
+		return -EPERM;
+
+	t = *table;
+	t.data = &enabled;
+	err = proc_dointvec_minmax(&t, write, buffer, lenp, ppos);
+	if (err < 0)
+		return err;
+	if (write)
+		sysctl_migrc_enable = enabled;
+	return err;
+}
+
+static struct ctl_table migrc_sysctls[] = {
+	{
+		.procname	= "migrc_enable",
+		.data		= NULL, /* filled in by handler */
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= sysctl_migrc_enable_handler,
+		.extra1         = SYSCTL_ZERO,
+		.extra2         = SYSCTL_ONE,
+	},
+	{}
+};
+
+static int __init migrc_sysctl_init(void)
+{
+	register_sysctl_init("vm", migrc_sysctls);
+	return 0;
+}
+late_initcall(migrc_sysctl_init);
+#endif
 
 atomic_t migrc_gen;
 
@@ -242,7 +284,7 @@  static inline bool migrc_stopped_pending(void)
 
 static bool can_migrc_system(void)
 {
-	return !migrc_stopped_pending();
+	return sysctl_migrc_enable && !migrc_stopped_pending();
 }
 #else
 static inline void migrc_mark_folios(struct folio *fsrc, struct folio *fdst) {}