diff mbox series

[v3,2/2] fs/proc: Optimize arrays defined by struct ctl_path

Message ID 20220224133217.1755-2-tangmeng@uniontech.com (mailing list archive)
State New, archived
Headers show
Series [v3,1/2] fs/proc: Optimize arrays defined by struct ctl_path | expand

Commit Message

Meng Tang Feb. 24, 2022, 1:32 p.m. UTC
Previously, arrays defined by struct ctl_path is terminated
with an empty one. When we actually only register one ctl_path,
we've gone from 8 bytes to 16 bytes.

The optimization has been implemented in the previous patch,
here to remove unnecessary terminate ctl_path with an empty one.

Signed-off-by: Meng Tang <tangmeng@uniontech.com>
---
 arch/csky/abiv1/alignment.c | 5 ++---
 arch/nds32/mm/alignment.c   | 5 ++---
 fs/verity/signature.c       | 3 +--
 kernel/pid_namespace.c      | 2 +-
 kernel/seccomp.c            | 3 +--
 security/apparmor/lsm.c     | 3 +--
 security/loadpin/loadpin.c  | 3 +--
 security/yama/yama_lsm.c    | 3 +--
 8 files changed, 10 insertions(+), 17 deletions(-)

Comments

Luis Chamberlain Feb. 26, 2022, 8:13 p.m. UTC | #1
On Thu, Feb 24, 2022 at 09:32:17PM +0800, Meng Tang wrote:
> Previously, arrays defined by struct ctl_path is terminated
> with an empty one. When we actually only register one ctl_path,
> we've gone from 8 bytes to 16 bytes.
> 
> The optimization has been implemented in the previous patch,
> here to remove unnecessary terminate ctl_path with an empty one.
> 
> Signed-off-by: Meng Tang <tangmeng@uniontech.com>

If these things are built-in, can you verify you're saving bytes
with size before and after the patch?

I wonder if having something like DECLARE_SYSCTL_PATH_ONE() would make
this nicer on the eyes, and also useful for the other changes you
are making. Do you have many other single path entries you are changing
later?

  Luis
diff mbox series

Patch

diff --git a/arch/csky/abiv1/alignment.c b/arch/csky/abiv1/alignment.c
index 2df115d0e210..5c2936b29d29 100644
--- a/arch/csky/abiv1/alignment.c
+++ b/arch/csky/abiv1/alignment.c
@@ -340,9 +340,8 @@  static struct ctl_table sysctl_table[2] = {
 	{}
 };
 
-static struct ctl_path sysctl_path[2] = {
-	{.procname = "csky"},
-	{}
+static struct ctl_path sysctl_path[1] = {
+	{.procname = "csky"}
 };
 
 static int __init csky_alignment_init(void)
diff --git a/arch/nds32/mm/alignment.c b/arch/nds32/mm/alignment.c
index 1eb7ded6992b..5e79c01b91d6 100644
--- a/arch/nds32/mm/alignment.c
+++ b/arch/nds32/mm/alignment.c
@@ -560,9 +560,8 @@  static struct ctl_table nds32_sysctl_table[2] = {
 	{}
 };
 
-static struct ctl_path nds32_path[2] = {
-	{.procname = "nds32"},
-	{}
+static struct ctl_path nds32_path[1] = {
+	{.procname = "nds32"}
 };
 
 /*
diff --git a/fs/verity/signature.c b/fs/verity/signature.c
index 143a530a8008..6cdad230c438 100644
--- a/fs/verity/signature.c
+++ b/fs/verity/signature.c
@@ -92,8 +92,7 @@  static struct ctl_table_header *fsverity_sysctl_header;
 
 static const struct ctl_path fsverity_sysctl_path[] = {
 	{ .procname = "fs", },
-	{ .procname = "verity", },
-	{ }
+	{ .procname = "verity", }
 };
 
 static struct ctl_table fsverity_sysctl_table[] = {
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index a46a3723bc66..f4f6db65bf81 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -294,7 +294,7 @@  static struct ctl_table pid_ns_ctl_table[] = {
 	},
 	{ }
 };
-static struct ctl_path kern_path[] = { { .procname = "kernel", }, { } };
+static struct ctl_path kern_path[] = { { .procname = "kernel", } };
 #endif	/* CONFIG_CHECKPOINT_RESTORE */
 
 int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index db10e73d06e0..03f88d0b79f1 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -2333,8 +2333,7 @@  static int seccomp_actions_logged_handler(struct ctl_table *ro_table, int write,
 
 static struct ctl_path seccomp_sysctl_path[] = {
 	{ .procname = "kernel", },
-	{ .procname = "seccomp", },
-	{ }
+	{ .procname = "seccomp", }
 };
 
 static struct ctl_table seccomp_sysctl_table[] = {
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index 4f0eecb67dde..e35c3b29742d 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -1729,8 +1729,7 @@  static int apparmor_dointvec(struct ctl_table *table, int write,
 }
 
 static struct ctl_path apparmor_sysctl_path[] = {
-	{ .procname = "kernel", },
-	{ }
+	{ .procname = "kernel", }
 };
 
 static struct ctl_table apparmor_sysctl_table[] = {
diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c
index b12f7d986b1e..0471b177d2e1 100644
--- a/security/loadpin/loadpin.c
+++ b/security/loadpin/loadpin.c
@@ -48,8 +48,7 @@  static DEFINE_SPINLOCK(pinned_root_spinlock);
 
 static struct ctl_path loadpin_sysctl_path[] = {
 	{ .procname = "kernel", },
-	{ .procname = "loadpin", },
-	{ }
+	{ .procname = "loadpin", }
 };
 
 static struct ctl_table loadpin_sysctl_table[] = {
diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
index 06e226166aab..b42b61e801b1 100644
--- a/security/yama/yama_lsm.c
+++ b/security/yama/yama_lsm.c
@@ -449,8 +449,7 @@  static int max_scope = YAMA_SCOPE_NO_ATTACH;
 
 static struct ctl_path yama_sysctl_path[] = {
 	{ .procname = "kernel", },
-	{ .procname = "yama", },
-	{ }
+	{ .procname = "yama", }
 };
 
 static struct ctl_table yama_sysctl_table[] = {