kernel: pid_namespace: simplify sysctls with register_sysctl()
authorLuis Chamberlain <mcgrof@kernel.org>
Thu, 2 Mar 2023 20:28:23 +0000 (12:28 -0800)
committerLuis Chamberlain <mcgrof@kernel.org>
Wed, 3 May 2023 02:23:29 +0000 (19:23 -0700)
register_sysctl_paths() is only required if your child (directories)
have entries and pid_namespace does not. So use register_sysctl_init()
instead where we don't care about the return value and use
register_sysctl() where we do.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Acked-by: Jeff Xu <jeffxu@google.com>
Link: https://lore.kernel.org/r/20230302202826.776286-9-mcgrof@kernel.org
kernel/pid_namespace.c
kernel/pid_sysctl.h

index 46e0d5a3f91f0d21923966adbdbedaa71aa3968f..b43eee07b00c0b999aa8f2083a0f99c2c815da85 100644 (file)
@@ -314,7 +314,6 @@ static struct ctl_table pid_ns_ctl_table[] = {
        },
        { }
 };
-static struct ctl_path kern_path[] = { { .procname = "kernel", }, { } };
 #endif /* CONFIG_CHECKPOINT_RESTORE */
 
 int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
@@ -473,7 +472,7 @@ static __init int pid_namespaces_init(void)
        pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC | SLAB_ACCOUNT);
 
 #ifdef CONFIG_CHECKPOINT_RESTORE
-       register_sysctl_paths(kern_path, pid_ns_ctl_table);
+       register_sysctl_init("kernel", pid_ns_ctl_table);
 #endif
 
        register_pid_ns_sysctl_table_vm();
index e22d072e1e243b0d11f1de177d414d3753902f3b..d67a4d45bb4274fc7f092c89e2edcb43f19a572a 100644 (file)
@@ -46,10 +46,9 @@ static struct ctl_table pid_ns_ctl_table_vm[] = {
        },
        { }
 };
-static struct ctl_path vm_path[] = { { .procname = "vm", }, { } };
 static inline void register_pid_ns_sysctl_table_vm(void)
 {
-       register_sysctl_paths(vm_path, pid_ns_ctl_table_vm);
+       register_sysctl("vm", pid_ns_ctl_table_vm);
 }
 #else
 static inline void initialize_memfd_noexec_scope(struct pid_namespace *ns) {}