linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] sysctl: Remove sentinel elements from fs dir
@ 2023-11-07 13:44 Joel Granados via B4 Relay
  2023-11-07 13:44 ` [PATCH 1/4] cachefiles: Remove the now superfluous sentinel element from ctl_table array Joel Granados via B4 Relay
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Joel Granados via B4 Relay @ 2023-11-07 13:44 UTC (permalink / raw)
  To: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Eric Biggers, Theodore Y. Ts'o, Chandan Babu R,
	Darrick J. Wong, Jan Harkes, coda
  Cc: linux-cachefs, linux-kernel, linux-fsdevel, linux-aio, linux-mm,
	linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity, linux-xfs,
	codalist, Joel Granados

From: Joel Granados <j.granados@samsung.com>

What?
These commits remove the sentinel element (last empty element) from the
sysctl arrays of all the files under the "fs/" directory that use a
sysctl array for registration. The merging of the preparation patches
(in https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/)
to mainline allows us to just remove sentinel elements without changing
behavior (more info here [1]).

These commits are part of a bigger set (here
https://github.com/Joelgranados/linux/tree/tag/sysctl_remove_empty_elem_V5)
that remove the ctl_table sentinel. We make the review process easier by
chunking the commits into manageable pieces. Each chunk can be reviewed
separately without noise from parallel sets.

Sending the "fs/*" chunk now that the "drivers/" has been mostly
reviewed [6]. After this and the "kernel/*" are reviewed we only have 2 more
chunks ("net/*" and miscellaneous) to complete the sentinel removal.
Hurray!!!

Why?
By removing the sysctl sentinel elements we avoid kernel bloat as
ctl_table arrays get moved out of kernel/sysctl.c into their own
respective subsystems. This move was started long ago to avoid merge
conflicts; the sentinel removal bit came after Mathew Wilcox suggested
it to avoid bloating the kernel by one element as arrays moved out. This
patchset will reduce the overall build time size of the kernel and run
time memory bloat by about ~64 bytes per declared ctl_table array. I
have consolidated some links that shed light on the history of this
effort [2].

Testing:
* Ran sysctl selftests (./tools/testing/selftests/sysctl/sysctl.sh)
* Ran this through 0-day with no errors or warnings

Size saving after this patchset:
    * bloat-o-meter
        - The "yesall" config saves 1920 bytes [4]
        - The "tiny" config saves 576 bytes [5]
    * If you want to know how many bytes are saved after all the chunks
      are merged see [3]

Base commit:
tag: sysctl-6.7-rc1 (8b793bcda61f)

Comments/feedback greatly appreciated

Best

Joel

[1]
We are able to remove a sentinel table without behavioral change by
introducing a table_size argument in the same place where procname is
checked for NULL. The idea is for it to keep stopping when it hits
->procname == NULL, while the sentinel is still present. And when the
sentinel is removed, it will stop on the table_size. You can go to 
(https://lore.kernel.org/all/20230809105006.1198165-1-j.granados@samsung.com/)
for more information.

[2]
Links Related to the ctl_table sentinel removal:
* E-mail threads that summarize the sentinel effort
  https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/
  https://lore.kernel.org/all/ZMFizKFkVxUFtSqa@bombadil.infradead.org/
* Replacing the register functions:
  https://lore.kernel.org/all/20230302204612.782387-1-mcgrof@kernel.org/
  https://lore.kernel.org/all/20230302202826.776286-1-mcgrof@kernel.org/
* E-mail threads discussing prposal
  https://lore.kernel.org/all/20230321130908.6972-1-frank.li@vivo.com
  https://lore.kernel.org/all/20220220060626.15885-1-tangmeng@uniontech.com

[3]
Size saving after removing all sentinels:
  These are the bytes that we save after removing all the sentinels
  (this plus all the other chunks). I included them to get an idea of
  how much memory we are talking about.
    * bloat-o-meter:
        - The "yesall" configuration results save 9158 bytes
          https://lore.kernel.org/all/20230621091000.424843-1-j.granados@samsung.com/
        - The "tiny" config + CONFIG_SYSCTL save 1215 bytes
          https://lore.kernel.org/all/20230809105006.1198165-1-j.granados@samsung.com/
    * memory usage:
        In memory savings are measured to be 7296 bytes. (here is how to
        measure [7])

[4]
add/remove: 0/0 grow/shrink: 0/30 up/down: 0/-1920 (-1920)
Function                                     old     new   delta
xfs_table                                   1024     960     -64
vm_userfaultfd_table                         128      64     -64
test_table_unregister                        128      64     -64
test_table                                   576     512     -64
root_table                                   128      64     -64
pty_table                                    256     192     -64
ocfs2_nm_table                               128      64     -64
ntfs_sysctls                                 128      64     -64
nlm_sysctls                                  448     384     -64
nfs_cb_sysctls                               192     128     -64
nfs4_cb_sysctls                              192     128     -64
namei_sysctls                                320     256     -64
locks_sysctls                                192     128     -64
inotify_table                                256     192     -64
inodes_sysctls                               192     128     -64
fsverity_sysctl_table                        128      64     -64
fs_stat_sysctls                              256     192     -64
fs_shared_sysctls                            192     128     -64
fs_pipe_sysctls                              256     192     -64
fs_namespace_sysctls                         128      64     -64
fs_exec_sysctls                              128      64     -64
fs_dqstats_table                             576     512     -64
fs_dcache_sysctls                            128      64     -64
fanotify_table                               256     192     -64
epoll_table                                  128      64     -64
dnotify_sysctls                              128      64     -64
coredump_sysctls                             256     192     -64
coda_table                                   256     192     -64
cachefiles_sysctls                           128      64     -64
aio_sysctls                                  192     128     -64
Total: Before=429912331, After=429910411, chg -0.00%

[5]
add/remove: 0/0 grow/shrink: 0/9 up/down: 0/-576 (-576)
Function                                     old     new   delta
root_table                                   128      64     -64
namei_sysctls                                320     256     -64
inodes_sysctls                               192     128     -64
fs_stat_sysctls                              256     192     -64
fs_shared_sysctls                            192     128     -64
fs_pipe_sysctls                              256     192     -64
fs_namespace_sysctls                         128      64     -64
fs_exec_sysctls                              128      64     -64
fs_dcache_sysctls                            128      64     -64
Total: Before=1886645, After=1886069, chg -0.03%

[6]
https://lore.kernel.org/all/20231002-jag-sysctl_remove_empty_elem_drivers-v2-0-02dd0d46f71e@samsung.com

[7]
To measure the in memory savings apply this on top of this patchset.

"
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index c88854df0b62..e0073a627bac 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -976,6 +976,8 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
        table[0].procname = new_name;
        table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO;
        init_header(&new->header, set->dir.header.root, set, node, table, 1);
+       // Counts additional sentinel used for each new dir.
+       printk("%ld sysctl saved mem kzalloc \n", sizeof(struct ctl_table));

        return new;
 }
@@ -1199,6 +1201,9 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
                link_name += len;
                link++;
        }
+       // Counts additional sentinel used for each new registration
+       //
+               printk("%ld sysctl saved mem kzalloc \n", sizeof(struct ctl_table));
        init_header(links, dir->header.root, dir->header.set, node, link_table,
                    head->ctl_table_size);
        links->nreg = nr_entries;
"
and then run the following bash script in the kernel:

accum=0
for n in $(dmesg | grep kzalloc | awk '{print $3}') ; do
    echo $n
    accum=$(calc "$accum + $n")
done
echo $accum

---

Signed-off-by: Joel Granados <j.granados@samsung.com>

---
Joel Granados (4):
      cachefiles: Remove the now superfluous sentinel element from ctl_table array
      aio: Remove the now superfluous sentinel elements from ctl_table array
      sysctl:  Remove the now superfluous sentinel elements from ctl_table array
      coda:  Remove the now superfluous sentinel elements from ctl_table array

 fs/aio.c                           | 1 -
 fs/cachefiles/error_inject.c       | 1 -
 fs/coda/sysctl.c                   | 1 -
 fs/coredump.c                      | 1 -
 fs/dcache.c                        | 1 -
 fs/devpts/inode.c                  | 1 -
 fs/eventpoll.c                     | 1 -
 fs/exec.c                          | 1 -
 fs/file_table.c                    | 1 -
 fs/inode.c                         | 1 -
 fs/lockd/svc.c                     | 1 -
 fs/locks.c                         | 1 -
 fs/namei.c                         | 1 -
 fs/namespace.c                     | 1 -
 fs/nfs/nfs4sysctl.c                | 1 -
 fs/nfs/sysctl.c                    | 1 -
 fs/notify/dnotify/dnotify.c        | 1 -
 fs/notify/fanotify/fanotify_user.c | 1 -
 fs/notify/inotify/inotify_user.c   | 1 -
 fs/ntfs/sysctl.c                   | 1 -
 fs/ocfs2/stackglue.c               | 1 -
 fs/pipe.c                          | 1 -
 fs/proc/proc_sysctl.c              | 1 -
 fs/quota/dquot.c                   | 1 -
 fs/sysctls.c                       | 1 -
 fs/userfaultfd.c                   | 1 -
 fs/verity/fsverity_private.h       | 2 +-
 fs/verity/init.c                   | 8 +++++---
 fs/xfs/xfs_sysctl.c                | 2 --
 lib/test_sysctl.c                  | 2 --
 30 files changed, 6 insertions(+), 34 deletions(-)
---
base-commit: 8b793bcda61f6c3ed4f5b2ded7530ef6749580cb
change-id: 20231107-jag-sysctl_remove_empty_elem_fs-dbdcf6581fbe

Best regards,
-- 
Joel Granados <j.granados@samsung.com>


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

* [PATCH 1/4] cachefiles: Remove the now superfluous sentinel element from ctl_table array
  2023-11-07 13:44 [PATCH 0/4] sysctl: Remove sentinel elements from fs dir Joel Granados via B4 Relay
@ 2023-11-07 13:44 ` Joel Granados via B4 Relay
  2023-11-07 13:44 ` [PATCH 2/4] aio: Remove the now superfluous sentinel elements " Joel Granados via B4 Relay
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Joel Granados via B4 Relay @ 2023-11-07 13:44 UTC (permalink / raw)
  To: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Eric Biggers, Theodore Y. Ts'o, Chandan Babu R,
	Darrick J. Wong, Jan Harkes, coda
  Cc: linux-cachefs, linux-kernel, linux-fsdevel, linux-aio, linux-mm,
	linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity, linux-xfs,
	codalist, Joel Granados

From: Joel Granados <j.granados@samsung.com>

This commit comes at the tail end of a greater effort to remove the empty
elements at the end of the ctl_table arrays (sentinels) which will reduce the
overall build time size of the kernel and run time memory bloat by ~64 bytes
per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/)

Remove sentinel from cachefiles_sysctls

Signed-off-by: Joel Granados <j.granados@samsung.com>
---
 fs/cachefiles/error_inject.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/cachefiles/error_inject.c b/fs/cachefiles/error_inject.c
index 18de8a876b02..1715d5ca2b2d 100644
--- a/fs/cachefiles/error_inject.c
+++ b/fs/cachefiles/error_inject.c
@@ -19,7 +19,6 @@ static struct ctl_table cachefiles_sysctls[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_douintvec,
 	},
-	{}
 };
 
 int __init cachefiles_register_error_injection(void)

-- 
2.30.2


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

* [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-07 13:44 [PATCH 0/4] sysctl: Remove sentinel elements from fs dir Joel Granados via B4 Relay
  2023-11-07 13:44 ` [PATCH 1/4] cachefiles: Remove the now superfluous sentinel element from ctl_table array Joel Granados via B4 Relay
@ 2023-11-07 13:44 ` Joel Granados via B4 Relay
  2023-11-07 16:22   ` Darrick J. Wong
                     ` (2 more replies)
  2023-11-07 13:44 ` [PATCH 3/4] sysctl: " Joel Granados via B4 Relay
  2023-11-07 13:44 ` [PATCH 4/4] coda: " Joel Granados via B4 Relay
  3 siblings, 3 replies; 13+ messages in thread
From: Joel Granados via B4 Relay @ 2023-11-07 13:44 UTC (permalink / raw)
  To: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Eric Biggers, Theodore Y. Ts'o, Chandan Babu R,
	Darrick J. Wong, Jan Harkes, coda
  Cc: linux-cachefs, linux-kernel, linux-fsdevel, linux-aio, linux-mm,
	linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity, linux-xfs,
	codalist, Joel Granados

From: Joel Granados <j.granados@samsung.com>

This commit comes at the tail end of a greater effort to remove the
empty elements at the end of the ctl_table arrays (sentinels) which
will reduce the overall build time size of the kernel and run time
memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/)

Remove sentinel elements ctl_table struct. Special attention was placed in
making sure that an empty directory for fs/verity was created when
CONFIG_FS_VERITY_BUILTIN_SIGNATURES is not defined. In this case we use the
register sysctl call that expects a size.

Signed-off-by: Joel Granados <j.granados@samsung.com>
---
 fs/aio.c                           | 1 -
 fs/coredump.c                      | 1 -
 fs/dcache.c                        | 1 -
 fs/devpts/inode.c                  | 1 -
 fs/eventpoll.c                     | 1 -
 fs/exec.c                          | 1 -
 fs/file_table.c                    | 1 -
 fs/inode.c                         | 1 -
 fs/lockd/svc.c                     | 1 -
 fs/locks.c                         | 1 -
 fs/namei.c                         | 1 -
 fs/namespace.c                     | 1 -
 fs/nfs/nfs4sysctl.c                | 1 -
 fs/nfs/sysctl.c                    | 1 -
 fs/notify/dnotify/dnotify.c        | 1 -
 fs/notify/fanotify/fanotify_user.c | 1 -
 fs/notify/inotify/inotify_user.c   | 1 -
 fs/ntfs/sysctl.c                   | 1 -
 fs/ocfs2/stackglue.c               | 1 -
 fs/pipe.c                          | 1 -
 fs/proc/proc_sysctl.c              | 1 -
 fs/quota/dquot.c                   | 1 -
 fs/sysctls.c                       | 1 -
 fs/userfaultfd.c                   | 1 -
 fs/verity/fsverity_private.h       | 2 +-
 fs/verity/init.c                   | 8 +++++---
 fs/xfs/xfs_sysctl.c                | 2 --
 27 files changed, 6 insertions(+), 30 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index a4c2a6bac72c..da069d6b6c66 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -239,7 +239,6 @@ static struct ctl_table aio_sysctls[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_doulongvec_minmax,
 	},
-	{}
 };
 
 static void __init aio_sysctl_init(void)
diff --git a/fs/coredump.c b/fs/coredump.c
index 9d235fa14ab9..f258c17c1841 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -981,7 +981,6 @@ static struct ctl_table coredump_sysctls[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
-	{ }
 };
 
 static int __init init_fs_coredump_sysctls(void)
diff --git a/fs/dcache.c b/fs/dcache.c
index 25ac74d30bff..bafdd455b0fe 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -191,7 +191,6 @@ static struct ctl_table fs_dcache_sysctls[] = {
 		.mode		= 0444,
 		.proc_handler	= proc_nr_dentry,
 	},
-	{ }
 };
 
 static int __init init_fs_dcache_sysctls(void)
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 299c295a27a0..a4de1612b1db 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -69,7 +69,6 @@ static struct ctl_table pty_table[] = {
 		.data		= &pty_count,
 		.proc_handler	= proc_dointvec,
 	},
-	{}
 };
 
 struct pts_mount_opts {
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 1d9a71a0c4c1..975fc5623102 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -322,7 +322,6 @@ static struct ctl_table epoll_table[] = {
 		.extra1		= &long_zero,
 		.extra2		= &long_max,
 	},
-	{ }
 };
 
 static void __init epoll_sysctls_init(void)
diff --git a/fs/exec.c b/fs/exec.c
index 6518e33ea813..7a18bde22f25 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -2167,7 +2167,6 @@ static struct ctl_table fs_exec_sysctls[] = {
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_TWO,
 	},
-	{ }
 };
 
 static int __init init_fs_exec_sysctls(void)
diff --git a/fs/file_table.c b/fs/file_table.c
index ee21b3da9d08..544f7d4f166f 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -137,7 +137,6 @@ static struct ctl_table fs_stat_sysctls[] = {
 		.extra1		= &sysctl_nr_open_min,
 		.extra2		= &sysctl_nr_open_max,
 	},
-	{ }
 };
 
 static int __init init_fs_stat_sysctls(void)
diff --git a/fs/inode.c b/fs/inode.c
index 35fd688168c5..ce16e3cda7bf 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -129,7 +129,6 @@ static struct ctl_table inodes_sysctls[] = {
 		.mode		= 0444,
 		.proc_handler	= proc_nr_inodes,
 	},
-	{ }
 };
 
 static int __init init_fs_inode_sysctls(void)
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 6579948070a4..f784ff58bfd3 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -474,7 +474,6 @@ static struct ctl_table nlm_sysctls[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
-	{ }
 };
 
 #endif	/* CONFIG_SYSCTL */
diff --git a/fs/locks.c b/fs/locks.c
index 76ad05f8070a..6ecfc422fb37 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -111,7 +111,6 @@ static struct ctl_table locks_sysctls[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif /* CONFIG_MMU */
-	{}
 };
 
 static int __init init_fs_locks_sysctls(void)
diff --git a/fs/namei.c b/fs/namei.c
index 567ee547492b..fb552161c981 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1070,7 +1070,6 @@ static struct ctl_table namei_sysctls[] = {
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_TWO,
 	},
-	{ }
 };
 
 static int __init init_fs_namei_sysctls(void)
diff --git a/fs/namespace.c b/fs/namespace.c
index e157efc54023..e95d4328539d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -5008,7 +5008,6 @@ static struct ctl_table fs_namespace_sysctls[] = {
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ONE,
 	},
-	{ }
 };
 
 static int __init init_fs_namespace_sysctls(void)
diff --git a/fs/nfs/nfs4sysctl.c b/fs/nfs/nfs4sysctl.c
index e776200e9a11..886a7c4c60b3 100644
--- a/fs/nfs/nfs4sysctl.c
+++ b/fs/nfs/nfs4sysctl.c
@@ -34,7 +34,6 @@ static struct ctl_table nfs4_cb_sysctls[] = {
 		.mode = 0644,
 		.proc_handler = proc_dointvec,
 	},
-	{ }
 };
 
 int nfs4_register_sysctl(void)
diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c
index f39e2089bc4c..e645be1a3381 100644
--- a/fs/nfs/sysctl.c
+++ b/fs/nfs/sysctl.c
@@ -29,7 +29,6 @@ static struct ctl_table nfs_cb_sysctls[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
-	{ }
 };
 
 int nfs_register_sysctl(void)
diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c
index ebdcc25df0f7..8151ed5ddefc 100644
--- a/fs/notify/dnotify/dnotify.c
+++ b/fs/notify/dnotify/dnotify.c
@@ -29,7 +29,6 @@ static struct ctl_table dnotify_sysctls[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
-	{}
 };
 static void __init dnotify_sysctl_init(void)
 {
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index f69c451018e3..80539839af0c 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -86,7 +86,6 @@ static struct ctl_table fanotify_table[] = {
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO
 	},
-	{ }
 };
 
 static void __init fanotify_sysctls_init(void)
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 1c4bfdab008d..3e222a271da6 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -85,7 +85,6 @@ static struct ctl_table inotify_table[] = {
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO
 	},
-	{ }
 };
 
 static void __init inotify_sysctls_init(void)
diff --git a/fs/ntfs/sysctl.c b/fs/ntfs/sysctl.c
index 174fe536a1c0..4e980170d86a 100644
--- a/fs/ntfs/sysctl.c
+++ b/fs/ntfs/sysctl.c
@@ -28,7 +28,6 @@ static struct ctl_table ntfs_sysctls[] = {
 		.mode		= 0644,			/* Mode, proc handler. */
 		.proc_handler	= proc_dointvec
 	},
-	{}
 };
 
 /* Storage for the sysctls header. */
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index a8d5ca98fa57..20aa37b67cfb 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -658,7 +658,6 @@ static struct ctl_table ocfs2_nm_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dostring,
 	},
-	{ }
 };
 
 static struct ctl_table_header *ocfs2_table_header;
diff --git a/fs/pipe.c b/fs/pipe.c
index 6c1a9b1db907..6bc1c4ae81d5 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1492,7 +1492,6 @@ static struct ctl_table fs_pipe_sysctls[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_doulongvec_minmax,
 	},
-	{ }
 };
 #endif
 
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index de484195f49f..4e06c4d69906 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -71,7 +71,6 @@ static struct ctl_table root_table[] = {
 		.procname = "",
 		.mode = S_IFDIR|S_IRUGO|S_IXUGO,
 	},
-	{ }
 };
 static struct ctl_table_root sysctl_table_root = {
 	.default_set.dir.header = {
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 9e72bfe8bbad..69b03e13e6f2 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -2949,7 +2949,6 @@ static struct ctl_table fs_dqstats_table[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif
-	{ },
 };
 
 static int __init dquot_init(void)
diff --git a/fs/sysctls.c b/fs/sysctls.c
index 76a0aee8c229..8dbde9a802fa 100644
--- a/fs/sysctls.c
+++ b/fs/sysctls.c
@@ -26,7 +26,6 @@ static struct ctl_table fs_shared_sysctls[] = {
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_MAXOLDUID,
 	},
-	{ }
 };
 
 static int __init init_fs_sysctls(void)
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 56eaae9dac1a..7668285779c1 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -45,7 +45,6 @@ static struct ctl_table vm_userfaultfd_table[] = {
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_ONE,
 	},
-	{ }
 };
 #endif
 
diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
index d071a6e32581..8191bf7ad706 100644
--- a/fs/verity/fsverity_private.h
+++ b/fs/verity/fsverity_private.h
@@ -122,8 +122,8 @@ void __init fsverity_init_info_cache(void);
 
 /* signature.c */
 
-#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
 extern int fsverity_require_signatures;
+#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
 int fsverity_verify_signature(const struct fsverity_info *vi,
 			      const u8 *signature, size_t sig_size);
 
diff --git a/fs/verity/init.c b/fs/verity/init.c
index a29f062f6047..e31045dd4f6c 100644
--- a/fs/verity/init.c
+++ b/fs/verity/init.c
@@ -13,7 +13,6 @@
 static struct ctl_table_header *fsverity_sysctl_header;
 
 static struct ctl_table fsverity_sysctl_table[] = {
-#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
 	{
 		.procname       = "require_signatures",
 		.data           = &fsverity_require_signatures,
@@ -23,14 +22,17 @@ static struct ctl_table fsverity_sysctl_table[] = {
 		.extra1         = SYSCTL_ZERO,
 		.extra2         = SYSCTL_ONE,
 	},
-#endif
-	{ }
 };
 
 static void __init fsverity_init_sysctl(void)
 {
+#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
 	fsverity_sysctl_header = register_sysctl("fs/verity",
 						 fsverity_sysctl_table);
+#else
+	fsverity_sysctl_header = register_sysctl_sz("fs/verity",
+						 fsverity_sysctl_table, 0);
+#endif
 	if (!fsverity_sysctl_header)
 		panic("fsverity sysctl registration failed");
 }
diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c
index fade33735393..a191f6560f98 100644
--- a/fs/xfs/xfs_sysctl.c
+++ b/fs/xfs/xfs_sysctl.c
@@ -206,8 +206,6 @@ static struct ctl_table xfs_table[] = {
 		.extra2		= &xfs_params.stats_clear.max
 	},
 #endif /* CONFIG_PROC_FS */
-
-	{}
 };
 
 int

-- 
2.30.2


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

* [PATCH 3/4] sysctl: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-07 13:44 [PATCH 0/4] sysctl: Remove sentinel elements from fs dir Joel Granados via B4 Relay
  2023-11-07 13:44 ` [PATCH 1/4] cachefiles: Remove the now superfluous sentinel element from ctl_table array Joel Granados via B4 Relay
  2023-11-07 13:44 ` [PATCH 2/4] aio: Remove the now superfluous sentinel elements " Joel Granados via B4 Relay
@ 2023-11-07 13:44 ` Joel Granados via B4 Relay
  2023-11-07 13:44 ` [PATCH 4/4] coda: " Joel Granados via B4 Relay
  3 siblings, 0 replies; 13+ messages in thread
From: Joel Granados via B4 Relay @ 2023-11-07 13:44 UTC (permalink / raw)
  To: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Eric Biggers, Theodore Y. Ts'o, Chandan Babu R,
	Darrick J. Wong, Jan Harkes, coda
  Cc: linux-cachefs, linux-kernel, linux-fsdevel, linux-aio, linux-mm,
	linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity, linux-xfs,
	codalist, Joel Granados

From: Joel Granados <j.granados@samsung.com>

This commit comes at the tail end of a greater effort to remove the
empty elements at the end of the ctl_table arrays (sentinels) which
will reduce the overall build time size of the kernel and run time
memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/)

Remove empty sentinel element from test_table and test_table_unregister.

Signed-off-by: Joel Granados <j.granados@samsung.com>
---
 lib/test_sysctl.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c
index 8036aa91a1cb..9d71ec5e8a77 100644
--- a/lib/test_sysctl.c
+++ b/lib/test_sysctl.c
@@ -130,7 +130,6 @@ static struct ctl_table test_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_do_large_bitmap,
 	},
-	{ }
 };
 
 static void test_sysctl_calc_match_int_ok(void)
@@ -184,7 +183,6 @@ static struct ctl_table test_table_unregister[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 	},
-	{}
 };
 
 static int test_sysctl_run_unregister_nested(void)

-- 
2.30.2


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

* [PATCH 4/4] coda: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-07 13:44 [PATCH 0/4] sysctl: Remove sentinel elements from fs dir Joel Granados via B4 Relay
                   ` (2 preceding siblings ...)
  2023-11-07 13:44 ` [PATCH 3/4] sysctl: " Joel Granados via B4 Relay
@ 2023-11-07 13:44 ` Joel Granados via B4 Relay
  3 siblings, 0 replies; 13+ messages in thread
From: Joel Granados via B4 Relay @ 2023-11-07 13:44 UTC (permalink / raw)
  To: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Eric Biggers, Theodore Y. Ts'o, Chandan Babu R,
	Darrick J. Wong, Jan Harkes, coda
  Cc: linux-cachefs, linux-kernel, linux-fsdevel, linux-aio, linux-mm,
	linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity, linux-xfs,
	codalist, Joel Granados

From: Joel Granados <j.granados@samsung.com>

This commit comes at the tail end of a greater effort to remove the
empty elements at the end of the ctl_table arrays (sentinels) which
will reduce the overall build time size of the kernel and run time
memory bloat by ~64 bytes per sentinel (further information Link :
https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/)

Remove empty sentinel from coda_table

Signed-off-by: Joel Granados <j.granados@samsung.com>
---
 fs/coda/sysctl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c
index a247c14aaab7..9f2d5743e2c8 100644
--- a/fs/coda/sysctl.c
+++ b/fs/coda/sysctl.c
@@ -36,7 +36,6 @@ static struct ctl_table coda_table[] = {
 		.mode		= 0600,
 		.proc_handler	= proc_dointvec
 	},
-	{}
 };
 
 void coda_sysctl_init(void)

-- 
2.30.2


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

* Re: [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-07 13:44 ` [PATCH 2/4] aio: Remove the now superfluous sentinel elements " Joel Granados via B4 Relay
@ 2023-11-07 16:22   ` Darrick J. Wong
  2023-11-08  8:28     ` Joel Granados
  2023-11-08  3:42   ` Eric Biggers
  2023-11-08  9:56   ` Jan Kara
  2 siblings, 1 reply; 13+ messages in thread
From: Darrick J. Wong @ 2023-11-07 16:22 UTC (permalink / raw)
  To: j.granados
  Cc: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Eric Biggers, Theodore Y. Ts'o, Chandan Babu R, Jan Harkes,
	coda, linux-cachefs, linux-kernel, linux-fsdevel, linux-aio,
	linux-mm, linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity,
	linux-xfs, codalist

On Tue, Nov 07, 2023 at 02:44:21PM +0100, Joel Granados via B4 Relay wrote:
> From: Joel Granados <j.granados@samsung.com>
> 
> This commit comes at the tail end of a greater effort to remove the
> empty elements at the end of the ctl_table arrays (sentinels) which
> will reduce the overall build time size of the kernel and run time
> memory bloat by ~64 bytes per sentinel (further information Link :
> https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/)
> 
> Remove sentinel elements ctl_table struct. Special attention was placed in
> making sure that an empty directory for fs/verity was created when
> CONFIG_FS_VERITY_BUILTIN_SIGNATURES is not defined. In this case we use the
> register sysctl call that expects a size.
> 
> Signed-off-by: Joel Granados <j.granados@samsung.com>
> ---
>  fs/aio.c                           | 1 -
>  fs/coredump.c                      | 1 -
>  fs/dcache.c                        | 1 -
>  fs/devpts/inode.c                  | 1 -
>  fs/eventpoll.c                     | 1 -
>  fs/exec.c                          | 1 -
>  fs/file_table.c                    | 1 -
>  fs/inode.c                         | 1 -
>  fs/lockd/svc.c                     | 1 -
>  fs/locks.c                         | 1 -
>  fs/namei.c                         | 1 -
>  fs/namespace.c                     | 1 -
>  fs/nfs/nfs4sysctl.c                | 1 -
>  fs/nfs/sysctl.c                    | 1 -
>  fs/notify/dnotify/dnotify.c        | 1 -
>  fs/notify/fanotify/fanotify_user.c | 1 -
>  fs/notify/inotify/inotify_user.c   | 1 -
>  fs/ntfs/sysctl.c                   | 1 -
>  fs/ocfs2/stackglue.c               | 1 -
>  fs/pipe.c                          | 1 -
>  fs/proc/proc_sysctl.c              | 1 -
>  fs/quota/dquot.c                   | 1 -
>  fs/sysctls.c                       | 1 -
>  fs/userfaultfd.c                   | 1 -
>  fs/verity/fsverity_private.h       | 2 +-
>  fs/verity/init.c                   | 8 +++++---
>  fs/xfs/xfs_sysctl.c                | 2 --

Not sure why an xfs change came in on a patch tagged "aio:"; I would
have expected "fs:" or "vfs:" or something.  For the XFS part:

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

>  27 files changed, 6 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/aio.c b/fs/aio.c
> index a4c2a6bac72c..da069d6b6c66 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -239,7 +239,6 @@ static struct ctl_table aio_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
>  	},
> -	{}
>  };
>  
>  static void __init aio_sysctl_init(void)
> diff --git a/fs/coredump.c b/fs/coredump.c
> index 9d235fa14ab9..f258c17c1841 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -981,7 +981,6 @@ static struct ctl_table coredump_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_coredump_sysctls(void)
> diff --git a/fs/dcache.c b/fs/dcache.c
> index 25ac74d30bff..bafdd455b0fe 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -191,7 +191,6 @@ static struct ctl_table fs_dcache_sysctls[] = {
>  		.mode		= 0444,
>  		.proc_handler	= proc_nr_dentry,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_dcache_sysctls(void)
> diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
> index 299c295a27a0..a4de1612b1db 100644
> --- a/fs/devpts/inode.c
> +++ b/fs/devpts/inode.c
> @@ -69,7 +69,6 @@ static struct ctl_table pty_table[] = {
>  		.data		= &pty_count,
>  		.proc_handler	= proc_dointvec,
>  	},
> -	{}
>  };
>  
>  struct pts_mount_opts {
> diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> index 1d9a71a0c4c1..975fc5623102 100644
> --- a/fs/eventpoll.c
> +++ b/fs/eventpoll.c
> @@ -322,7 +322,6 @@ static struct ctl_table epoll_table[] = {
>  		.extra1		= &long_zero,
>  		.extra2		= &long_max,
>  	},
> -	{ }
>  };
>  
>  static void __init epoll_sysctls_init(void)
> diff --git a/fs/exec.c b/fs/exec.c
> index 6518e33ea813..7a18bde22f25 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -2167,7 +2167,6 @@ static struct ctl_table fs_exec_sysctls[] = {
>  		.extra1		= SYSCTL_ZERO,
>  		.extra2		= SYSCTL_TWO,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_exec_sysctls(void)
> diff --git a/fs/file_table.c b/fs/file_table.c
> index ee21b3da9d08..544f7d4f166f 100644
> --- a/fs/file_table.c
> +++ b/fs/file_table.c
> @@ -137,7 +137,6 @@ static struct ctl_table fs_stat_sysctls[] = {
>  		.extra1		= &sysctl_nr_open_min,
>  		.extra2		= &sysctl_nr_open_max,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_stat_sysctls(void)
> diff --git a/fs/inode.c b/fs/inode.c
> index 35fd688168c5..ce16e3cda7bf 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -129,7 +129,6 @@ static struct ctl_table inodes_sysctls[] = {
>  		.mode		= 0444,
>  		.proc_handler	= proc_nr_inodes,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_inode_sysctls(void)
> diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
> index 6579948070a4..f784ff58bfd3 100644
> --- a/fs/lockd/svc.c
> +++ b/fs/lockd/svc.c
> @@ -474,7 +474,6 @@ static struct ctl_table nlm_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec,
>  	},
> -	{ }
>  };
>  
>  #endif	/* CONFIG_SYSCTL */
> diff --git a/fs/locks.c b/fs/locks.c
> index 76ad05f8070a..6ecfc422fb37 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -111,7 +111,6 @@ static struct ctl_table locks_sysctls[] = {
>  		.proc_handler	= proc_dointvec,
>  	},
>  #endif /* CONFIG_MMU */
> -	{}
>  };
>  
>  static int __init init_fs_locks_sysctls(void)
> diff --git a/fs/namei.c b/fs/namei.c
> index 567ee547492b..fb552161c981 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -1070,7 +1070,6 @@ static struct ctl_table namei_sysctls[] = {
>  		.extra1		= SYSCTL_ZERO,
>  		.extra2		= SYSCTL_TWO,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_namei_sysctls(void)
> diff --git a/fs/namespace.c b/fs/namespace.c
> index e157efc54023..e95d4328539d 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -5008,7 +5008,6 @@ static struct ctl_table fs_namespace_sysctls[] = {
>  		.proc_handler	= proc_dointvec_minmax,
>  		.extra1		= SYSCTL_ONE,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_namespace_sysctls(void)
> diff --git a/fs/nfs/nfs4sysctl.c b/fs/nfs/nfs4sysctl.c
> index e776200e9a11..886a7c4c60b3 100644
> --- a/fs/nfs/nfs4sysctl.c
> +++ b/fs/nfs/nfs4sysctl.c
> @@ -34,7 +34,6 @@ static struct ctl_table nfs4_cb_sysctls[] = {
>  		.mode = 0644,
>  		.proc_handler = proc_dointvec,
>  	},
> -	{ }
>  };
>  
>  int nfs4_register_sysctl(void)
> diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c
> index f39e2089bc4c..e645be1a3381 100644
> --- a/fs/nfs/sysctl.c
> +++ b/fs/nfs/sysctl.c
> @@ -29,7 +29,6 @@ static struct ctl_table nfs_cb_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec,
>  	},
> -	{ }
>  };
>  
>  int nfs_register_sysctl(void)
> diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c
> index ebdcc25df0f7..8151ed5ddefc 100644
> --- a/fs/notify/dnotify/dnotify.c
> +++ b/fs/notify/dnotify/dnotify.c
> @@ -29,7 +29,6 @@ static struct ctl_table dnotify_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec,
>  	},
> -	{}
>  };
>  static void __init dnotify_sysctl_init(void)
>  {
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index f69c451018e3..80539839af0c 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -86,7 +86,6 @@ static struct ctl_table fanotify_table[] = {
>  		.proc_handler	= proc_dointvec_minmax,
>  		.extra1		= SYSCTL_ZERO
>  	},
> -	{ }
>  };
>  
>  static void __init fanotify_sysctls_init(void)
> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> index 1c4bfdab008d..3e222a271da6 100644
> --- a/fs/notify/inotify/inotify_user.c
> +++ b/fs/notify/inotify/inotify_user.c
> @@ -85,7 +85,6 @@ static struct ctl_table inotify_table[] = {
>  		.proc_handler	= proc_dointvec_minmax,
>  		.extra1		= SYSCTL_ZERO
>  	},
> -	{ }
>  };
>  
>  static void __init inotify_sysctls_init(void)
> diff --git a/fs/ntfs/sysctl.c b/fs/ntfs/sysctl.c
> index 174fe536a1c0..4e980170d86a 100644
> --- a/fs/ntfs/sysctl.c
> +++ b/fs/ntfs/sysctl.c
> @@ -28,7 +28,6 @@ static struct ctl_table ntfs_sysctls[] = {
>  		.mode		= 0644,			/* Mode, proc handler. */
>  		.proc_handler	= proc_dointvec
>  	},
> -	{}
>  };
>  
>  /* Storage for the sysctls header. */
> diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
> index a8d5ca98fa57..20aa37b67cfb 100644
> --- a/fs/ocfs2/stackglue.c
> +++ b/fs/ocfs2/stackglue.c
> @@ -658,7 +658,6 @@ static struct ctl_table ocfs2_nm_table[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dostring,
>  	},
> -	{ }
>  };
>  
>  static struct ctl_table_header *ocfs2_table_header;
> diff --git a/fs/pipe.c b/fs/pipe.c
> index 6c1a9b1db907..6bc1c4ae81d5 100644
> --- a/fs/pipe.c
> +++ b/fs/pipe.c
> @@ -1492,7 +1492,6 @@ static struct ctl_table fs_pipe_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
>  	},
> -	{ }
>  };
>  #endif
>  
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index de484195f49f..4e06c4d69906 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -71,7 +71,6 @@ static struct ctl_table root_table[] = {
>  		.procname = "",
>  		.mode = S_IFDIR|S_IRUGO|S_IXUGO,
>  	},
> -	{ }
>  };
>  static struct ctl_table_root sysctl_table_root = {
>  	.default_set.dir.header = {
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 9e72bfe8bbad..69b03e13e6f2 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -2949,7 +2949,6 @@ static struct ctl_table fs_dqstats_table[] = {
>  		.proc_handler	= proc_dointvec,
>  	},
>  #endif
> -	{ },
>  };
>  
>  static int __init dquot_init(void)
> diff --git a/fs/sysctls.c b/fs/sysctls.c
> index 76a0aee8c229..8dbde9a802fa 100644
> --- a/fs/sysctls.c
> +++ b/fs/sysctls.c
> @@ -26,7 +26,6 @@ static struct ctl_table fs_shared_sysctls[] = {
>  		.extra1		= SYSCTL_ZERO,
>  		.extra2		= SYSCTL_MAXOLDUID,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_sysctls(void)
> diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
> index 56eaae9dac1a..7668285779c1 100644
> --- a/fs/userfaultfd.c
> +++ b/fs/userfaultfd.c
> @@ -45,7 +45,6 @@ static struct ctl_table vm_userfaultfd_table[] = {
>  		.extra1		= SYSCTL_ZERO,
>  		.extra2		= SYSCTL_ONE,
>  	},
> -	{ }
>  };
>  #endif
>  
> diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
> index d071a6e32581..8191bf7ad706 100644
> --- a/fs/verity/fsverity_private.h
> +++ b/fs/verity/fsverity_private.h
> @@ -122,8 +122,8 @@ void __init fsverity_init_info_cache(void);
>  
>  /* signature.c */
>  
> -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  extern int fsverity_require_signatures;
> +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  int fsverity_verify_signature(const struct fsverity_info *vi,
>  			      const u8 *signature, size_t sig_size);
>  
> diff --git a/fs/verity/init.c b/fs/verity/init.c
> index a29f062f6047..e31045dd4f6c 100644
> --- a/fs/verity/init.c
> +++ b/fs/verity/init.c
> @@ -13,7 +13,6 @@
>  static struct ctl_table_header *fsverity_sysctl_header;
>  
>  static struct ctl_table fsverity_sysctl_table[] = {
> -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  	{
>  		.procname       = "require_signatures",
>  		.data           = &fsverity_require_signatures,
> @@ -23,14 +22,17 @@ static struct ctl_table fsverity_sysctl_table[] = {
>  		.extra1         = SYSCTL_ZERO,
>  		.extra2         = SYSCTL_ONE,
>  	},
> -#endif
> -	{ }
>  };
>  
>  static void __init fsverity_init_sysctl(void)
>  {
> +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  	fsverity_sysctl_header = register_sysctl("fs/verity",
>  						 fsverity_sysctl_table);
> +#else
> +	fsverity_sysctl_header = register_sysctl_sz("fs/verity",
> +						 fsverity_sysctl_table, 0);
> +#endif
>  	if (!fsverity_sysctl_header)
>  		panic("fsverity sysctl registration failed");
>  }
> diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c
> index fade33735393..a191f6560f98 100644
> --- a/fs/xfs/xfs_sysctl.c
> +++ b/fs/xfs/xfs_sysctl.c
> @@ -206,8 +206,6 @@ static struct ctl_table xfs_table[] = {
>  		.extra2		= &xfs_params.stats_clear.max
>  	},
>  #endif /* CONFIG_PROC_FS */
> -
> -	{}
>  };
>  
>  int
> 
> -- 
> 2.30.2
> 

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

* Re: [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-07 13:44 ` [PATCH 2/4] aio: Remove the now superfluous sentinel elements " Joel Granados via B4 Relay
  2023-11-07 16:22   ` Darrick J. Wong
@ 2023-11-08  3:42   ` Eric Biggers
  2023-11-08  8:26     ` Joel Granados
  2023-11-09 16:00     ` Joel Granados
  2023-11-08  9:56   ` Jan Kara
  2 siblings, 2 replies; 13+ messages in thread
From: Eric Biggers @ 2023-11-08  3:42 UTC (permalink / raw)
  To: j.granados
  Cc: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Theodore Y. Ts'o, Chandan Babu R, Darrick J. Wong, Jan Harkes,
	coda, linux-cachefs, linux-kernel, linux-fsdevel, linux-aio,
	linux-mm, linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity,
	linux-xfs, codalist

On Tue, Nov 07, 2023 at 02:44:21PM +0100, Joel Granados via B4 Relay wrote:
> [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array

The commit prefix should be "fs:".

> Remove sentinel elements ctl_table struct. Special attention was placed in
> making sure that an empty directory for fs/verity was created when
> CONFIG_FS_VERITY_BUILTIN_SIGNATURES is not defined. In this case we use the
> register sysctl call that expects a size.
[...]
> diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
> index d071a6e32581..8191bf7ad706 100644
> --- a/fs/verity/fsverity_private.h
> +++ b/fs/verity/fsverity_private.h
> @@ -122,8 +122,8 @@ void __init fsverity_init_info_cache(void);
>  
>  /* signature.c */
>  
> -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  extern int fsverity_require_signatures;
> +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  int fsverity_verify_signature(const struct fsverity_info *vi,
>  			      const u8 *signature, size_t sig_size);
>  
> diff --git a/fs/verity/init.c b/fs/verity/init.c
> index a29f062f6047..e31045dd4f6c 100644
> --- a/fs/verity/init.c
> +++ b/fs/verity/init.c
> @@ -13,7 +13,6 @@
>  static struct ctl_table_header *fsverity_sysctl_header;
>  
>  static struct ctl_table fsverity_sysctl_table[] = {
> -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  	{
>  		.procname       = "require_signatures",
>  		.data           = &fsverity_require_signatures,
> @@ -23,14 +22,17 @@ static struct ctl_table fsverity_sysctl_table[] = {
>  		.extra1         = SYSCTL_ZERO,
>  		.extra2         = SYSCTL_ONE,
>  	},
> -#endif
> -	{ }
>  };
>  
>  static void __init fsverity_init_sysctl(void)
>  {
> +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  	fsverity_sysctl_header = register_sysctl("fs/verity",
>  						 fsverity_sysctl_table);
> +#else
> +	fsverity_sysctl_header = register_sysctl_sz("fs/verity",
> +						 fsverity_sysctl_table, 0);
> +#endif
>  	if (!fsverity_sysctl_header)
>  		panic("fsverity sysctl registration failed");

This does not make sense, and it causes a build error when CONFIG_FS_VERITY=y
and CONFIG_FS_VERITY_BUILTIN_SIGNATURES=n.

I think all you need to do is delete the sentinel element, the same as
everywhere else.  I just tested it, and it works fine.

BTW, the comments for register_sysctl_sz() and __register_sysctl_table() are
outdated, as they still say "A completely 0 filled entry terminates the table."

- Eric

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

* Re: [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-08  3:42   ` Eric Biggers
@ 2023-11-08  8:26     ` Joel Granados
  2023-11-09 16:00     ` Joel Granados
  1 sibling, 0 replies; 13+ messages in thread
From: Joel Granados @ 2023-11-08  8:26 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Theodore Y. Ts'o, Chandan Babu R, Darrick J. Wong, Jan Harkes,
	coda, linux-cachefs, linux-kernel, linux-fsdevel, linux-aio,
	linux-mm, linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity,
	linux-xfs, codalist

[-- Attachment #1: Type: text/plain, Size: 3063 bytes --]

On Tue, Nov 07, 2023 at 07:42:31PM -0800, Eric Biggers wrote:
> On Tue, Nov 07, 2023 at 02:44:21PM +0100, Joel Granados via B4 Relay wrote:
> > [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
> 
> The commit prefix should be "fs:".
Will do

> 
> > Remove sentinel elements ctl_table struct. Special attention was placed in
> > making sure that an empty directory for fs/verity was created when
> > CONFIG_FS_VERITY_BUILTIN_SIGNATURES is not defined. In this case we use the
> > register sysctl call that expects a size.
> [...]
> > diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
> > index d071a6e32581..8191bf7ad706 100644
> > --- a/fs/verity/fsverity_private.h
> > +++ b/fs/verity/fsverity_private.h
> > @@ -122,8 +122,8 @@ void __init fsverity_init_info_cache(void);
> >  
> >  /* signature.c */
> >  
> > -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  extern int fsverity_require_signatures;
> > +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  int fsverity_verify_signature(const struct fsverity_info *vi,
> >  			      const u8 *signature, size_t sig_size);
> >  
> > diff --git a/fs/verity/init.c b/fs/verity/init.c
> > index a29f062f6047..e31045dd4f6c 100644
> > --- a/fs/verity/init.c
> > +++ b/fs/verity/init.c
> > @@ -13,7 +13,6 @@
> >  static struct ctl_table_header *fsverity_sysctl_header;
> >  
> >  static struct ctl_table fsverity_sysctl_table[] = {
> > -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  	{
> >  		.procname       = "require_signatures",
> >  		.data           = &fsverity_require_signatures,
> > @@ -23,14 +22,17 @@ static struct ctl_table fsverity_sysctl_table[] = {
> >  		.extra1         = SYSCTL_ZERO,
> >  		.extra2         = SYSCTL_ONE,
> >  	},
> > -#endif
> > -	{ }
> >  };
> >  
> >  static void __init fsverity_init_sysctl(void)
> >  {
> > +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  	fsverity_sysctl_header = register_sysctl("fs/verity",
> >  						 fsverity_sysctl_table);
> > +#else
> > +	fsverity_sysctl_header = register_sysctl_sz("fs/verity",
> > +						 fsverity_sysctl_table, 0);
> > +#endif
> >  	if (!fsverity_sysctl_header)
> >  		panic("fsverity sysctl registration failed");
> 
> This does not make sense, and it causes a build error when CONFIG_FS_VERITY=y
> and CONFIG_FS_VERITY_BUILTIN_SIGNATURES=n.
> 
> I think all you need to do is delete the sentinel element, the same as
> everywhere else.  I just tested it, and it works fine.
Indeed. good catch and thx for testing. I'll adjust it on my V2.

> 
> BTW, the comments for register_sysctl_sz() and __register_sysctl_table() are
> outdated, as they still say "A completely 0 filled entry terminates the table."
For now this is still "technically" correct. However, this will be
removed on the last patchset when we actually delete the check for the
sentinel element.
For now I'll leave it like it is, but I'll double check to make sure
that I remove it at the end.

Best
> 
> - Eric

-- 

Joel Granados

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-07 16:22   ` Darrick J. Wong
@ 2023-11-08  8:28     ` Joel Granados
  0 siblings, 0 replies; 13+ messages in thread
From: Joel Granados @ 2023-11-08  8:28 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Eric Biggers, Theodore Y. Ts'o, Chandan Babu R, Jan Harkes,
	coda, linux-cachefs, linux-kernel, linux-fsdevel, linux-aio,
	linux-mm, linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity,
	linux-xfs, codalist

[-- Attachment #1: Type: text/plain, Size: 13685 bytes --]

On Tue, Nov 07, 2023 at 08:22:51AM -0800, Darrick J. Wong wrote:
> On Tue, Nov 07, 2023 at 02:44:21PM +0100, Joel Granados via B4 Relay wrote:
> > From: Joel Granados <j.granados@samsung.com>
> > 
> > This commit comes at the tail end of a greater effort to remove the
> > empty elements at the end of the ctl_table arrays (sentinels) which
> > will reduce the overall build time size of the kernel and run time
> > memory bloat by ~64 bytes per sentinel (further information Link :
> > https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/)
> > 
> > Remove sentinel elements ctl_table struct. Special attention was placed in
> > making sure that an empty directory for fs/verity was created when
> > CONFIG_FS_VERITY_BUILTIN_SIGNATURES is not defined. In this case we use the
> > register sysctl call that expects a size.
> > 
> > Signed-off-by: Joel Granados <j.granados@samsung.com>
> > ---
> >  fs/aio.c                           | 1 -
> >  fs/coredump.c                      | 1 -
> >  fs/dcache.c                        | 1 -
> >  fs/devpts/inode.c                  | 1 -
> >  fs/eventpoll.c                     | 1 -
> >  fs/exec.c                          | 1 -
> >  fs/file_table.c                    | 1 -
> >  fs/inode.c                         | 1 -
> >  fs/lockd/svc.c                     | 1 -
> >  fs/locks.c                         | 1 -
> >  fs/namei.c                         | 1 -
> >  fs/namespace.c                     | 1 -
> >  fs/nfs/nfs4sysctl.c                | 1 -
> >  fs/nfs/sysctl.c                    | 1 -
> >  fs/notify/dnotify/dnotify.c        | 1 -
> >  fs/notify/fanotify/fanotify_user.c | 1 -
> >  fs/notify/inotify/inotify_user.c   | 1 -
> >  fs/ntfs/sysctl.c                   | 1 -
> >  fs/ocfs2/stackglue.c               | 1 -
> >  fs/pipe.c                          | 1 -
> >  fs/proc/proc_sysctl.c              | 1 -
> >  fs/quota/dquot.c                   | 1 -
> >  fs/sysctls.c                       | 1 -
> >  fs/userfaultfd.c                   | 1 -
> >  fs/verity/fsverity_private.h       | 2 +-
> >  fs/verity/init.c                   | 8 +++++---
> >  fs/xfs/xfs_sysctl.c                | 2 --
> 
> Not sure why an xfs change came in on a patch tagged "aio:"; I would
> have expected "fs:" or "vfs:" or something.  For the XFS part:
This was the same comment as Eric. will address it in my V2 and add your
reviewed tag.

Thx

> 
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> 
> --D
> 
> >  27 files changed, 6 insertions(+), 30 deletions(-)
> > 
> > diff --git a/fs/aio.c b/fs/aio.c
> > index a4c2a6bac72c..da069d6b6c66 100644
> > --- a/fs/aio.c
> > +++ b/fs/aio.c
> > @@ -239,7 +239,6 @@ static struct ctl_table aio_sysctls[] = {
> >  		.mode		= 0644,
> >  		.proc_handler	= proc_doulongvec_minmax,
> >  	},
> > -	{}
> >  };
> >  
> >  static void __init aio_sysctl_init(void)
> > diff --git a/fs/coredump.c b/fs/coredump.c
> > index 9d235fa14ab9..f258c17c1841 100644
> > --- a/fs/coredump.c
> > +++ b/fs/coredump.c
> > @@ -981,7 +981,6 @@ static struct ctl_table coredump_sysctls[] = {
> >  		.mode		= 0644,
> >  		.proc_handler	= proc_dointvec,
> >  	},
> > -	{ }
> >  };
> >  
> >  static int __init init_fs_coredump_sysctls(void)
> > diff --git a/fs/dcache.c b/fs/dcache.c
> > index 25ac74d30bff..bafdd455b0fe 100644
> > --- a/fs/dcache.c
> > +++ b/fs/dcache.c
> > @@ -191,7 +191,6 @@ static struct ctl_table fs_dcache_sysctls[] = {
> >  		.mode		= 0444,
> >  		.proc_handler	= proc_nr_dentry,
> >  	},
> > -	{ }
> >  };
> >  
> >  static int __init init_fs_dcache_sysctls(void)
> > diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
> > index 299c295a27a0..a4de1612b1db 100644
> > --- a/fs/devpts/inode.c
> > +++ b/fs/devpts/inode.c
> > @@ -69,7 +69,6 @@ static struct ctl_table pty_table[] = {
> >  		.data		= &pty_count,
> >  		.proc_handler	= proc_dointvec,
> >  	},
> > -	{}
> >  };
> >  
> >  struct pts_mount_opts {
> > diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> > index 1d9a71a0c4c1..975fc5623102 100644
> > --- a/fs/eventpoll.c
> > +++ b/fs/eventpoll.c
> > @@ -322,7 +322,6 @@ static struct ctl_table epoll_table[] = {
> >  		.extra1		= &long_zero,
> >  		.extra2		= &long_max,
> >  	},
> > -	{ }
> >  };
> >  
> >  static void __init epoll_sysctls_init(void)
> > diff --git a/fs/exec.c b/fs/exec.c
> > index 6518e33ea813..7a18bde22f25 100644
> > --- a/fs/exec.c
> > +++ b/fs/exec.c
> > @@ -2167,7 +2167,6 @@ static struct ctl_table fs_exec_sysctls[] = {
> >  		.extra1		= SYSCTL_ZERO,
> >  		.extra2		= SYSCTL_TWO,
> >  	},
> > -	{ }
> >  };
> >  
> >  static int __init init_fs_exec_sysctls(void)
> > diff --git a/fs/file_table.c b/fs/file_table.c
> > index ee21b3da9d08..544f7d4f166f 100644
> > --- a/fs/file_table.c
> > +++ b/fs/file_table.c
> > @@ -137,7 +137,6 @@ static struct ctl_table fs_stat_sysctls[] = {
> >  		.extra1		= &sysctl_nr_open_min,
> >  		.extra2		= &sysctl_nr_open_max,
> >  	},
> > -	{ }
> >  };
> >  
> >  static int __init init_fs_stat_sysctls(void)
> > diff --git a/fs/inode.c b/fs/inode.c
> > index 35fd688168c5..ce16e3cda7bf 100644
> > --- a/fs/inode.c
> > +++ b/fs/inode.c
> > @@ -129,7 +129,6 @@ static struct ctl_table inodes_sysctls[] = {
> >  		.mode		= 0444,
> >  		.proc_handler	= proc_nr_inodes,
> >  	},
> > -	{ }
> >  };
> >  
> >  static int __init init_fs_inode_sysctls(void)
> > diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
> > index 6579948070a4..f784ff58bfd3 100644
> > --- a/fs/lockd/svc.c
> > +++ b/fs/lockd/svc.c
> > @@ -474,7 +474,6 @@ static struct ctl_table nlm_sysctls[] = {
> >  		.mode		= 0644,
> >  		.proc_handler	= proc_dointvec,
> >  	},
> > -	{ }
> >  };
> >  
> >  #endif	/* CONFIG_SYSCTL */
> > diff --git a/fs/locks.c b/fs/locks.c
> > index 76ad05f8070a..6ecfc422fb37 100644
> > --- a/fs/locks.c
> > +++ b/fs/locks.c
> > @@ -111,7 +111,6 @@ static struct ctl_table locks_sysctls[] = {
> >  		.proc_handler	= proc_dointvec,
> >  	},
> >  #endif /* CONFIG_MMU */
> > -	{}
> >  };
> >  
> >  static int __init init_fs_locks_sysctls(void)
> > diff --git a/fs/namei.c b/fs/namei.c
> > index 567ee547492b..fb552161c981 100644
> > --- a/fs/namei.c
> > +++ b/fs/namei.c
> > @@ -1070,7 +1070,6 @@ static struct ctl_table namei_sysctls[] = {
> >  		.extra1		= SYSCTL_ZERO,
> >  		.extra2		= SYSCTL_TWO,
> >  	},
> > -	{ }
> >  };
> >  
> >  static int __init init_fs_namei_sysctls(void)
> > diff --git a/fs/namespace.c b/fs/namespace.c
> > index e157efc54023..e95d4328539d 100644
> > --- a/fs/namespace.c
> > +++ b/fs/namespace.c
> > @@ -5008,7 +5008,6 @@ static struct ctl_table fs_namespace_sysctls[] = {
> >  		.proc_handler	= proc_dointvec_minmax,
> >  		.extra1		= SYSCTL_ONE,
> >  	},
> > -	{ }
> >  };
> >  
> >  static int __init init_fs_namespace_sysctls(void)
> > diff --git a/fs/nfs/nfs4sysctl.c b/fs/nfs/nfs4sysctl.c
> > index e776200e9a11..886a7c4c60b3 100644
> > --- a/fs/nfs/nfs4sysctl.c
> > +++ b/fs/nfs/nfs4sysctl.c
> > @@ -34,7 +34,6 @@ static struct ctl_table nfs4_cb_sysctls[] = {
> >  		.mode = 0644,
> >  		.proc_handler = proc_dointvec,
> >  	},
> > -	{ }
> >  };
> >  
> >  int nfs4_register_sysctl(void)
> > diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c
> > index f39e2089bc4c..e645be1a3381 100644
> > --- a/fs/nfs/sysctl.c
> > +++ b/fs/nfs/sysctl.c
> > @@ -29,7 +29,6 @@ static struct ctl_table nfs_cb_sysctls[] = {
> >  		.mode		= 0644,
> >  		.proc_handler	= proc_dointvec,
> >  	},
> > -	{ }
> >  };
> >  
> >  int nfs_register_sysctl(void)
> > diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c
> > index ebdcc25df0f7..8151ed5ddefc 100644
> > --- a/fs/notify/dnotify/dnotify.c
> > +++ b/fs/notify/dnotify/dnotify.c
> > @@ -29,7 +29,6 @@ static struct ctl_table dnotify_sysctls[] = {
> >  		.mode		= 0644,
> >  		.proc_handler	= proc_dointvec,
> >  	},
> > -	{}
> >  };
> >  static void __init dnotify_sysctl_init(void)
> >  {
> > diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> > index f69c451018e3..80539839af0c 100644
> > --- a/fs/notify/fanotify/fanotify_user.c
> > +++ b/fs/notify/fanotify/fanotify_user.c
> > @@ -86,7 +86,6 @@ static struct ctl_table fanotify_table[] = {
> >  		.proc_handler	= proc_dointvec_minmax,
> >  		.extra1		= SYSCTL_ZERO
> >  	},
> > -	{ }
> >  };
> >  
> >  static void __init fanotify_sysctls_init(void)
> > diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> > index 1c4bfdab008d..3e222a271da6 100644
> > --- a/fs/notify/inotify/inotify_user.c
> > +++ b/fs/notify/inotify/inotify_user.c
> > @@ -85,7 +85,6 @@ static struct ctl_table inotify_table[] = {
> >  		.proc_handler	= proc_dointvec_minmax,
> >  		.extra1		= SYSCTL_ZERO
> >  	},
> > -	{ }
> >  };
> >  
> >  static void __init inotify_sysctls_init(void)
> > diff --git a/fs/ntfs/sysctl.c b/fs/ntfs/sysctl.c
> > index 174fe536a1c0..4e980170d86a 100644
> > --- a/fs/ntfs/sysctl.c
> > +++ b/fs/ntfs/sysctl.c
> > @@ -28,7 +28,6 @@ static struct ctl_table ntfs_sysctls[] = {
> >  		.mode		= 0644,			/* Mode, proc handler. */
> >  		.proc_handler	= proc_dointvec
> >  	},
> > -	{}
> >  };
> >  
> >  /* Storage for the sysctls header. */
> > diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
> > index a8d5ca98fa57..20aa37b67cfb 100644
> > --- a/fs/ocfs2/stackglue.c
> > +++ b/fs/ocfs2/stackglue.c
> > @@ -658,7 +658,6 @@ static struct ctl_table ocfs2_nm_table[] = {
> >  		.mode		= 0644,
> >  		.proc_handler	= proc_dostring,
> >  	},
> > -	{ }
> >  };
> >  
> >  static struct ctl_table_header *ocfs2_table_header;
> > diff --git a/fs/pipe.c b/fs/pipe.c
> > index 6c1a9b1db907..6bc1c4ae81d5 100644
> > --- a/fs/pipe.c
> > +++ b/fs/pipe.c
> > @@ -1492,7 +1492,6 @@ static struct ctl_table fs_pipe_sysctls[] = {
> >  		.mode		= 0644,
> >  		.proc_handler	= proc_doulongvec_minmax,
> >  	},
> > -	{ }
> >  };
> >  #endif
> >  
> > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> > index de484195f49f..4e06c4d69906 100644
> > --- a/fs/proc/proc_sysctl.c
> > +++ b/fs/proc/proc_sysctl.c
> > @@ -71,7 +71,6 @@ static struct ctl_table root_table[] = {
> >  		.procname = "",
> >  		.mode = S_IFDIR|S_IRUGO|S_IXUGO,
> >  	},
> > -	{ }
> >  };
> >  static struct ctl_table_root sysctl_table_root = {
> >  	.default_set.dir.header = {
> > diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> > index 9e72bfe8bbad..69b03e13e6f2 100644
> > --- a/fs/quota/dquot.c
> > +++ b/fs/quota/dquot.c
> > @@ -2949,7 +2949,6 @@ static struct ctl_table fs_dqstats_table[] = {
> >  		.proc_handler	= proc_dointvec,
> >  	},
> >  #endif
> > -	{ },
> >  };
> >  
> >  static int __init dquot_init(void)
> > diff --git a/fs/sysctls.c b/fs/sysctls.c
> > index 76a0aee8c229..8dbde9a802fa 100644
> > --- a/fs/sysctls.c
> > +++ b/fs/sysctls.c
> > @@ -26,7 +26,6 @@ static struct ctl_table fs_shared_sysctls[] = {
> >  		.extra1		= SYSCTL_ZERO,
> >  		.extra2		= SYSCTL_MAXOLDUID,
> >  	},
> > -	{ }
> >  };
> >  
> >  static int __init init_fs_sysctls(void)
> > diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
> > index 56eaae9dac1a..7668285779c1 100644
> > --- a/fs/userfaultfd.c
> > +++ b/fs/userfaultfd.c
> > @@ -45,7 +45,6 @@ static struct ctl_table vm_userfaultfd_table[] = {
> >  		.extra1		= SYSCTL_ZERO,
> >  		.extra2		= SYSCTL_ONE,
> >  	},
> > -	{ }
> >  };
> >  #endif
> >  
> > diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
> > index d071a6e32581..8191bf7ad706 100644
> > --- a/fs/verity/fsverity_private.h
> > +++ b/fs/verity/fsverity_private.h
> > @@ -122,8 +122,8 @@ void __init fsverity_init_info_cache(void);
> >  
> >  /* signature.c */
> >  
> > -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  extern int fsverity_require_signatures;
> > +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  int fsverity_verify_signature(const struct fsverity_info *vi,
> >  			      const u8 *signature, size_t sig_size);
> >  
> > diff --git a/fs/verity/init.c b/fs/verity/init.c
> > index a29f062f6047..e31045dd4f6c 100644
> > --- a/fs/verity/init.c
> > +++ b/fs/verity/init.c
> > @@ -13,7 +13,6 @@
> >  static struct ctl_table_header *fsverity_sysctl_header;
> >  
> >  static struct ctl_table fsverity_sysctl_table[] = {
> > -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  	{
> >  		.procname       = "require_signatures",
> >  		.data           = &fsverity_require_signatures,
> > @@ -23,14 +22,17 @@ static struct ctl_table fsverity_sysctl_table[] = {
> >  		.extra1         = SYSCTL_ZERO,
> >  		.extra2         = SYSCTL_ONE,
> >  	},
> > -#endif
> > -	{ }
> >  };
> >  
> >  static void __init fsverity_init_sysctl(void)
> >  {
> > +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  	fsverity_sysctl_header = register_sysctl("fs/verity",
> >  						 fsverity_sysctl_table);
> > +#else
> > +	fsverity_sysctl_header = register_sysctl_sz("fs/verity",
> > +						 fsverity_sysctl_table, 0);
> > +#endif
> >  	if (!fsverity_sysctl_header)
> >  		panic("fsverity sysctl registration failed");
> >  }
> > diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c
> > index fade33735393..a191f6560f98 100644
> > --- a/fs/xfs/xfs_sysctl.c
> > +++ b/fs/xfs/xfs_sysctl.c
> > @@ -206,8 +206,6 @@ static struct ctl_table xfs_table[] = {
> >  		.extra2		= &xfs_params.stats_clear.max
> >  	},
> >  #endif /* CONFIG_PROC_FS */
> > -
> > -	{}
> >  };
> >  
> >  int
> > 
> > -- 
> > 2.30.2
> > 

-- 

Joel Granados

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-07 13:44 ` [PATCH 2/4] aio: Remove the now superfluous sentinel elements " Joel Granados via B4 Relay
  2023-11-07 16:22   ` Darrick J. Wong
  2023-11-08  3:42   ` Eric Biggers
@ 2023-11-08  9:56   ` Jan Kara
  2 siblings, 0 replies; 13+ messages in thread
From: Jan Kara @ 2023-11-08  9:56 UTC (permalink / raw)
  To: j.granados
  Cc: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Eric Biggers, Theodore Y. Ts'o, Chandan Babu R,
	Darrick J. Wong, Jan Harkes, coda, linux-cachefs, linux-kernel,
	linux-fsdevel, linux-aio, linux-mm, linux-nfs, linux-ntfs-dev,
	ocfs2-devel, fsverity, linux-xfs, codalist

On Tue 07-11-23 14:44:21, Joel Granados via B4 Relay wrote:
> From: Joel Granados <j.granados@samsung.com>
> 
> This commit comes at the tail end of a greater effort to remove the
> empty elements at the end of the ctl_table arrays (sentinels) which
> will reduce the overall build time size of the kernel and run time
> memory bloat by ~64 bytes per sentinel (further information Link :
> https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/)
> 
> Remove sentinel elements ctl_table struct. Special attention was placed in
> making sure that an empty directory for fs/verity was created when
> CONFIG_FS_VERITY_BUILTIN_SIGNATURES is not defined. In this case we use the
> register sysctl call that expects a size.
> 
> Signed-off-by: Joel Granados <j.granados@samsung.com>

For fs/*.c, fs/quota/, fs/notify/, fs/ocfs2/ feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

Other bits look good to me as well besides fsverify changes which looks odd
and Eric already commented on that.

								Honza

> ---
>  fs/aio.c                           | 1 -
>  fs/coredump.c                      | 1 -
>  fs/dcache.c                        | 1 -
>  fs/devpts/inode.c                  | 1 -
>  fs/eventpoll.c                     | 1 -
>  fs/exec.c                          | 1 -
>  fs/file_table.c                    | 1 -
>  fs/inode.c                         | 1 -
>  fs/lockd/svc.c                     | 1 -
>  fs/locks.c                         | 1 -
>  fs/namei.c                         | 1 -
>  fs/namespace.c                     | 1 -
>  fs/nfs/nfs4sysctl.c                | 1 -
>  fs/nfs/sysctl.c                    | 1 -
>  fs/notify/dnotify/dnotify.c        | 1 -
>  fs/notify/fanotify/fanotify_user.c | 1 -
>  fs/notify/inotify/inotify_user.c   | 1 -
>  fs/ntfs/sysctl.c                   | 1 -
>  fs/ocfs2/stackglue.c               | 1 -
>  fs/pipe.c                          | 1 -
>  fs/proc/proc_sysctl.c              | 1 -
>  fs/quota/dquot.c                   | 1 -
>  fs/sysctls.c                       | 1 -
>  fs/userfaultfd.c                   | 1 -
>  fs/verity/fsverity_private.h       | 2 +-
>  fs/verity/init.c                   | 8 +++++---
>  fs/xfs/xfs_sysctl.c                | 2 --
>  27 files changed, 6 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/aio.c b/fs/aio.c
> index a4c2a6bac72c..da069d6b6c66 100644
> --- a/fs/aio.c
> +++ b/fs/aio.c
> @@ -239,7 +239,6 @@ static struct ctl_table aio_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
>  	},
> -	{}
>  };
>  
>  static void __init aio_sysctl_init(void)
> diff --git a/fs/coredump.c b/fs/coredump.c
> index 9d235fa14ab9..f258c17c1841 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -981,7 +981,6 @@ static struct ctl_table coredump_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_coredump_sysctls(void)
> diff --git a/fs/dcache.c b/fs/dcache.c
> index 25ac74d30bff..bafdd455b0fe 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -191,7 +191,6 @@ static struct ctl_table fs_dcache_sysctls[] = {
>  		.mode		= 0444,
>  		.proc_handler	= proc_nr_dentry,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_dcache_sysctls(void)
> diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
> index 299c295a27a0..a4de1612b1db 100644
> --- a/fs/devpts/inode.c
> +++ b/fs/devpts/inode.c
> @@ -69,7 +69,6 @@ static struct ctl_table pty_table[] = {
>  		.data		= &pty_count,
>  		.proc_handler	= proc_dointvec,
>  	},
> -	{}
>  };
>  
>  struct pts_mount_opts {
> diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> index 1d9a71a0c4c1..975fc5623102 100644
> --- a/fs/eventpoll.c
> +++ b/fs/eventpoll.c
> @@ -322,7 +322,6 @@ static struct ctl_table epoll_table[] = {
>  		.extra1		= &long_zero,
>  		.extra2		= &long_max,
>  	},
> -	{ }
>  };
>  
>  static void __init epoll_sysctls_init(void)
> diff --git a/fs/exec.c b/fs/exec.c
> index 6518e33ea813..7a18bde22f25 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -2167,7 +2167,6 @@ static struct ctl_table fs_exec_sysctls[] = {
>  		.extra1		= SYSCTL_ZERO,
>  		.extra2		= SYSCTL_TWO,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_exec_sysctls(void)
> diff --git a/fs/file_table.c b/fs/file_table.c
> index ee21b3da9d08..544f7d4f166f 100644
> --- a/fs/file_table.c
> +++ b/fs/file_table.c
> @@ -137,7 +137,6 @@ static struct ctl_table fs_stat_sysctls[] = {
>  		.extra1		= &sysctl_nr_open_min,
>  		.extra2		= &sysctl_nr_open_max,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_stat_sysctls(void)
> diff --git a/fs/inode.c b/fs/inode.c
> index 35fd688168c5..ce16e3cda7bf 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -129,7 +129,6 @@ static struct ctl_table inodes_sysctls[] = {
>  		.mode		= 0444,
>  		.proc_handler	= proc_nr_inodes,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_inode_sysctls(void)
> diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
> index 6579948070a4..f784ff58bfd3 100644
> --- a/fs/lockd/svc.c
> +++ b/fs/lockd/svc.c
> @@ -474,7 +474,6 @@ static struct ctl_table nlm_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec,
>  	},
> -	{ }
>  };
>  
>  #endif	/* CONFIG_SYSCTL */
> diff --git a/fs/locks.c b/fs/locks.c
> index 76ad05f8070a..6ecfc422fb37 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -111,7 +111,6 @@ static struct ctl_table locks_sysctls[] = {
>  		.proc_handler	= proc_dointvec,
>  	},
>  #endif /* CONFIG_MMU */
> -	{}
>  };
>  
>  static int __init init_fs_locks_sysctls(void)
> diff --git a/fs/namei.c b/fs/namei.c
> index 567ee547492b..fb552161c981 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -1070,7 +1070,6 @@ static struct ctl_table namei_sysctls[] = {
>  		.extra1		= SYSCTL_ZERO,
>  		.extra2		= SYSCTL_TWO,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_namei_sysctls(void)
> diff --git a/fs/namespace.c b/fs/namespace.c
> index e157efc54023..e95d4328539d 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -5008,7 +5008,6 @@ static struct ctl_table fs_namespace_sysctls[] = {
>  		.proc_handler	= proc_dointvec_minmax,
>  		.extra1		= SYSCTL_ONE,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_namespace_sysctls(void)
> diff --git a/fs/nfs/nfs4sysctl.c b/fs/nfs/nfs4sysctl.c
> index e776200e9a11..886a7c4c60b3 100644
> --- a/fs/nfs/nfs4sysctl.c
> +++ b/fs/nfs/nfs4sysctl.c
> @@ -34,7 +34,6 @@ static struct ctl_table nfs4_cb_sysctls[] = {
>  		.mode = 0644,
>  		.proc_handler = proc_dointvec,
>  	},
> -	{ }
>  };
>  
>  int nfs4_register_sysctl(void)
> diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c
> index f39e2089bc4c..e645be1a3381 100644
> --- a/fs/nfs/sysctl.c
> +++ b/fs/nfs/sysctl.c
> @@ -29,7 +29,6 @@ static struct ctl_table nfs_cb_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec,
>  	},
> -	{ }
>  };
>  
>  int nfs_register_sysctl(void)
> diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c
> index ebdcc25df0f7..8151ed5ddefc 100644
> --- a/fs/notify/dnotify/dnotify.c
> +++ b/fs/notify/dnotify/dnotify.c
> @@ -29,7 +29,6 @@ static struct ctl_table dnotify_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec,
>  	},
> -	{}
>  };
>  static void __init dnotify_sysctl_init(void)
>  {
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index f69c451018e3..80539839af0c 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -86,7 +86,6 @@ static struct ctl_table fanotify_table[] = {
>  		.proc_handler	= proc_dointvec_minmax,
>  		.extra1		= SYSCTL_ZERO
>  	},
> -	{ }
>  };
>  
>  static void __init fanotify_sysctls_init(void)
> diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
> index 1c4bfdab008d..3e222a271da6 100644
> --- a/fs/notify/inotify/inotify_user.c
> +++ b/fs/notify/inotify/inotify_user.c
> @@ -85,7 +85,6 @@ static struct ctl_table inotify_table[] = {
>  		.proc_handler	= proc_dointvec_minmax,
>  		.extra1		= SYSCTL_ZERO
>  	},
> -	{ }
>  };
>  
>  static void __init inotify_sysctls_init(void)
> diff --git a/fs/ntfs/sysctl.c b/fs/ntfs/sysctl.c
> index 174fe536a1c0..4e980170d86a 100644
> --- a/fs/ntfs/sysctl.c
> +++ b/fs/ntfs/sysctl.c
> @@ -28,7 +28,6 @@ static struct ctl_table ntfs_sysctls[] = {
>  		.mode		= 0644,			/* Mode, proc handler. */
>  		.proc_handler	= proc_dointvec
>  	},
> -	{}
>  };
>  
>  /* Storage for the sysctls header. */
> diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
> index a8d5ca98fa57..20aa37b67cfb 100644
> --- a/fs/ocfs2/stackglue.c
> +++ b/fs/ocfs2/stackglue.c
> @@ -658,7 +658,6 @@ static struct ctl_table ocfs2_nm_table[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dostring,
>  	},
> -	{ }
>  };
>  
>  static struct ctl_table_header *ocfs2_table_header;
> diff --git a/fs/pipe.c b/fs/pipe.c
> index 6c1a9b1db907..6bc1c4ae81d5 100644
> --- a/fs/pipe.c
> +++ b/fs/pipe.c
> @@ -1492,7 +1492,6 @@ static struct ctl_table fs_pipe_sysctls[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_doulongvec_minmax,
>  	},
> -	{ }
>  };
>  #endif
>  
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index de484195f49f..4e06c4d69906 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -71,7 +71,6 @@ static struct ctl_table root_table[] = {
>  		.procname = "",
>  		.mode = S_IFDIR|S_IRUGO|S_IXUGO,
>  	},
> -	{ }
>  };
>  static struct ctl_table_root sysctl_table_root = {
>  	.default_set.dir.header = {
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 9e72bfe8bbad..69b03e13e6f2 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -2949,7 +2949,6 @@ static struct ctl_table fs_dqstats_table[] = {
>  		.proc_handler	= proc_dointvec,
>  	},
>  #endif
> -	{ },
>  };
>  
>  static int __init dquot_init(void)
> diff --git a/fs/sysctls.c b/fs/sysctls.c
> index 76a0aee8c229..8dbde9a802fa 100644
> --- a/fs/sysctls.c
> +++ b/fs/sysctls.c
> @@ -26,7 +26,6 @@ static struct ctl_table fs_shared_sysctls[] = {
>  		.extra1		= SYSCTL_ZERO,
>  		.extra2		= SYSCTL_MAXOLDUID,
>  	},
> -	{ }
>  };
>  
>  static int __init init_fs_sysctls(void)
> diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
> index 56eaae9dac1a..7668285779c1 100644
> --- a/fs/userfaultfd.c
> +++ b/fs/userfaultfd.c
> @@ -45,7 +45,6 @@ static struct ctl_table vm_userfaultfd_table[] = {
>  		.extra1		= SYSCTL_ZERO,
>  		.extra2		= SYSCTL_ONE,
>  	},
> -	{ }
>  };
>  #endif
>  
> diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
> index d071a6e32581..8191bf7ad706 100644
> --- a/fs/verity/fsverity_private.h
> +++ b/fs/verity/fsverity_private.h
> @@ -122,8 +122,8 @@ void __init fsverity_init_info_cache(void);
>  
>  /* signature.c */
>  
> -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  extern int fsverity_require_signatures;
> +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  int fsverity_verify_signature(const struct fsverity_info *vi,
>  			      const u8 *signature, size_t sig_size);
>  
> diff --git a/fs/verity/init.c b/fs/verity/init.c
> index a29f062f6047..e31045dd4f6c 100644
> --- a/fs/verity/init.c
> +++ b/fs/verity/init.c
> @@ -13,7 +13,6 @@
>  static struct ctl_table_header *fsverity_sysctl_header;
>  
>  static struct ctl_table fsverity_sysctl_table[] = {
> -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  	{
>  		.procname       = "require_signatures",
>  		.data           = &fsverity_require_signatures,
> @@ -23,14 +22,17 @@ static struct ctl_table fsverity_sysctl_table[] = {
>  		.extra1         = SYSCTL_ZERO,
>  		.extra2         = SYSCTL_ONE,
>  	},
> -#endif
> -	{ }
>  };
>  
>  static void __init fsverity_init_sysctl(void)
>  {
> +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
>  	fsverity_sysctl_header = register_sysctl("fs/verity",
>  						 fsverity_sysctl_table);
> +#else
> +	fsverity_sysctl_header = register_sysctl_sz("fs/verity",
> +						 fsverity_sysctl_table, 0);
> +#endif
>  	if (!fsverity_sysctl_header)
>  		panic("fsverity sysctl registration failed");
>  }
> diff --git a/fs/xfs/xfs_sysctl.c b/fs/xfs/xfs_sysctl.c
> index fade33735393..a191f6560f98 100644
> --- a/fs/xfs/xfs_sysctl.c
> +++ b/fs/xfs/xfs_sysctl.c
> @@ -206,8 +206,6 @@ static struct ctl_table xfs_table[] = {
>  		.extra2		= &xfs_params.stats_clear.max
>  	},
>  #endif /* CONFIG_PROC_FS */
> -
> -	{}
>  };
>  
>  int
> 
> -- 
> 2.30.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-08  3:42   ` Eric Biggers
  2023-11-08  8:26     ` Joel Granados
@ 2023-11-09 16:00     ` Joel Granados
  2023-11-09 16:08       ` Eric Biggers
  1 sibling, 1 reply; 13+ messages in thread
From: Joel Granados @ 2023-11-09 16:00 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Theodore Y. Ts'o, Chandan Babu R, Darrick J. Wong, Jan Harkes,
	coda, linux-cachefs, linux-kernel, linux-fsdevel, linux-aio,
	linux-mm, linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity,
	linux-xfs, codalist

[-- Attachment #1: Type: text/plain, Size: 3395 bytes --]

On Tue, Nov 07, 2023 at 07:42:31PM -0800, Eric Biggers wrote:
> On Tue, Nov 07, 2023 at 02:44:21PM +0100, Joel Granados via B4 Relay wrote:
> > [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
> 
> The commit prefix should be "fs:".
> 
> > Remove sentinel elements ctl_table struct. Special attention was placed in
> > making sure that an empty directory for fs/verity was created when
> > CONFIG_FS_VERITY_BUILTIN_SIGNATURES is not defined. In this case we use the
> > register sysctl call that expects a size.
> [...]
> > diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
> > index d071a6e32581..8191bf7ad706 100644
> > --- a/fs/verity/fsverity_private.h
> > +++ b/fs/verity/fsverity_private.h
> > @@ -122,8 +122,8 @@ void __init fsverity_init_info_cache(void);
> >  
> >  /* signature.c */
> >  
> > -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  extern int fsverity_require_signatures;
> > +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  int fsverity_verify_signature(const struct fsverity_info *vi,
> >  			      const u8 *signature, size_t sig_size);
> >  
> > diff --git a/fs/verity/init.c b/fs/verity/init.c
> > index a29f062f6047..e31045dd4f6c 100644
> > --- a/fs/verity/init.c
> > +++ b/fs/verity/init.c
> > @@ -13,7 +13,6 @@
> >  static struct ctl_table_header *fsverity_sysctl_header;
> >  
> >  static struct ctl_table fsverity_sysctl_table[] = {
> > -#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  	{
> >  		.procname       = "require_signatures",
> >  		.data           = &fsverity_require_signatures,
> > @@ -23,14 +22,17 @@ static struct ctl_table fsverity_sysctl_table[] = {
> >  		.extra1         = SYSCTL_ZERO,
> >  		.extra2         = SYSCTL_ONE,
> >  	},
> > -#endif
> > -	{ }
> >  };
> >  
> >  static void __init fsverity_init_sysctl(void)
> >  {
> > +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> >  	fsverity_sysctl_header = register_sysctl("fs/verity",
> >  						 fsverity_sysctl_table);
> > +#else
> > +	fsverity_sysctl_header = register_sysctl_sz("fs/verity",
> > +						 fsverity_sysctl_table, 0);
> > +#endif
> >  	if (!fsverity_sysctl_header)
> >  		panic("fsverity sysctl registration failed");
> 
> This does not make sense, and it causes a build error when CONFIG_FS_VERITY=y
> and CONFIG_FS_VERITY_BUILTIN_SIGNATURES=n.
> 
> I think all you need to do is delete the sentinel element, the same as
> everywhere else.  I just tested it, and it works fine.
I found the reason why I added the CONFIG_FS_VERITY_BUILTIN_SIGNATURES
here: it is related to
https://lore.kernel.org/all/20230705212743.42180-3-ebiggers@kernel.org/
where the directory is registered with an element only if
CONFIG_FS_VERITY_BUILTIN_SIGNATURES is defined. I had forgotten, but I
even asked for a clarification on the patch :).

I see that that patch made it to v6.6. So the solution is not to remove
the CONFIG_FS_VERITY_BUILTIN_SIGNATURES, but for me to rebase on top of
a more up to date base.

@Eric: Please get back to me if the patch in
https://lore.kernel.org/all/20230705212743.42180-3-ebiggers@kernel.org/
is no longer relevant.

Best.

> 
> BTW, the comments for register_sysctl_sz() and __register_sysctl_table() are
> outdated, as they still say "A completely 0 filled entry terminates the table."
> 
> - Eric

-- 

Joel Granados

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-09 16:00     ` Joel Granados
@ 2023-11-09 16:08       ` Eric Biggers
  2023-11-09 21:12         ` Joel Granados
  0 siblings, 1 reply; 13+ messages in thread
From: Eric Biggers @ 2023-11-09 16:08 UTC (permalink / raw)
  To: Joel Granados
  Cc: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Theodore Y. Ts'o, Chandan Babu R, Darrick J. Wong, Jan Harkes,
	coda, linux-cachefs, linux-kernel, linux-fsdevel, linux-aio,
	linux-mm, linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity,
	linux-xfs, codalist

On Thu, Nov 09, 2023 at 05:00:40PM +0100, Joel Granados wrote:
> > >  static void __init fsverity_init_sysctl(void)
> > >  {
> > > +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> > >  	fsverity_sysctl_header = register_sysctl("fs/verity",
> > >  						 fsverity_sysctl_table);
> > > +#else
> > > +	fsverity_sysctl_header = register_sysctl_sz("fs/verity",
> > > +						 fsverity_sysctl_table, 0);
> > > +#endif
> > >  	if (!fsverity_sysctl_header)
> > >  		panic("fsverity sysctl registration failed");
> > 
> > This does not make sense, and it causes a build error when CONFIG_FS_VERITY=y
> > and CONFIG_FS_VERITY_BUILTIN_SIGNATURES=n.
> > 
> > I think all you need to do is delete the sentinel element, the same as
> > everywhere else.  I just tested it, and it works fine.
> I found the reason why I added the CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> here: it is related to
> https://lore.kernel.org/all/20230705212743.42180-3-ebiggers@kernel.org/
> where the directory is registered with an element only if
> CONFIG_FS_VERITY_BUILTIN_SIGNATURES is defined. I had forgotten, but I
> even asked for a clarification on the patch :).
> 
> I see that that patch made it to v6.6. So the solution is not to remove
> the CONFIG_FS_VERITY_BUILTIN_SIGNATURES, but for me to rebase on top of
> a more up to date base.
> 
> @Eric: Please get back to me if the patch in
> https://lore.kernel.org/all/20230705212743.42180-3-ebiggers@kernel.org/
> is no longer relevant.
> 
> Best.

Yes, that patch was merged in 6.6.  I don't think it really matters here though,
other than the fact that it moved the code to a different file.  I believe all
you need to do is remove the sentinel element, the same as anywhere else:

diff --git a/fs/verity/init.c b/fs/verity/init.c
index a29f062f6047b..b64a76b9ac362 100644
--- a/fs/verity/init.c
+++ b/fs/verity/init.c
@@ -24,7 +24,6 @@ static struct ctl_table fsverity_sysctl_table[] = {
 		.extra2         = SYSCTL_ONE,
 	},
 #endif
-	{ }
 };
 
 static void __init fsverity_init_sysctl(void)

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

* Re: [PATCH 2/4] aio: Remove the now superfluous sentinel elements from ctl_table array
  2023-11-09 16:08       ` Eric Biggers
@ 2023-11-09 21:12         ` Joel Granados
  0 siblings, 0 replies; 13+ messages in thread
From: Joel Granados @ 2023-11-09 21:12 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Luis Chamberlain, willy, josh, Kees Cook, David Howells,
	Alexander Viro, Christian Brauner, Benjamin LaHaise,
	Eric Biederman, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Jan Kara, Amir Goldstein, Matthew Bobrowski, Anton Altaparmakov,
	Namjae Jeon, Mark Fasheh, Joel Becker, Joseph Qi, Iurii Zaikin,
	Theodore Y. Ts'o, Chandan Babu R, Darrick J. Wong, Jan Harkes,
	coda, linux-cachefs, linux-kernel, linux-fsdevel, linux-aio,
	linux-mm, linux-nfs, linux-ntfs-dev, ocfs2-devel, fsverity,
	linux-xfs, codalist

[-- Attachment #1: Type: text/plain, Size: 2449 bytes --]

On Thu, Nov 09, 2023 at 08:08:31AM -0800, Eric Biggers wrote:
> On Thu, Nov 09, 2023 at 05:00:40PM +0100, Joel Granados wrote:
> > > >  static void __init fsverity_init_sysctl(void)
> > > >  {
> > > > +#ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> > > >  	fsverity_sysctl_header = register_sysctl("fs/verity",
> > > >  						 fsverity_sysctl_table);
> > > > +#else
> > > > +	fsverity_sysctl_header = register_sysctl_sz("fs/verity",
> > > > +						 fsverity_sysctl_table, 0);
> > > > +#endif
> > > >  	if (!fsverity_sysctl_header)
> > > >  		panic("fsverity sysctl registration failed");
> > > 
> > > This does not make sense, and it causes a build error when CONFIG_FS_VERITY=y
> > > and CONFIG_FS_VERITY_BUILTIN_SIGNATURES=n.
> > > 
> > > I think all you need to do is delete the sentinel element, the same as
> > > everywhere else.  I just tested it, and it works fine.
> > I found the reason why I added the CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> > here: it is related to
> > https://lore.kernel.org/all/20230705212743.42180-3-ebiggers@kernel.org/
> > where the directory is registered with an element only if
> > CONFIG_FS_VERITY_BUILTIN_SIGNATURES is defined. I had forgotten, but I
> > even asked for a clarification on the patch :).
> > 
> > I see that that patch made it to v6.6. So the solution is not to remove
> > the CONFIG_FS_VERITY_BUILTIN_SIGNATURES, but for me to rebase on top of
> > a more up to date base.
> > 
> > @Eric: Please get back to me if the patch in
> > https://lore.kernel.org/all/20230705212743.42180-3-ebiggers@kernel.org/
> > is no longer relevant.
> > 
> > Best.
> 
> Yes, that patch was merged in 6.6.  I don't think it really matters here though,
> other than the fact that it moved the code to a different file.  I believe all
> you need to do is remove the sentinel element, the same as anywhere else:
Indeed. I thought that I had to handle empty array in a special way, but
it seems that ARRAY_SIZE works for empty arrays as well. I'll correct
this as well. Thx again for the feedback.

Best
> 
> diff --git a/fs/verity/init.c b/fs/verity/init.c
> index a29f062f6047b..b64a76b9ac362 100644
> --- a/fs/verity/init.c
> +++ b/fs/verity/init.c
> @@ -24,7 +24,6 @@ static struct ctl_table fsverity_sysctl_table[] = {
>  		.extra2         = SYSCTL_ONE,
>  	},
>  #endif
> -	{ }
>  };
>  
>  static void __init fsverity_init_sysctl(void)

-- 

Joel Granados

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2023-11-09 21:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-07 13:44 [PATCH 0/4] sysctl: Remove sentinel elements from fs dir Joel Granados via B4 Relay
2023-11-07 13:44 ` [PATCH 1/4] cachefiles: Remove the now superfluous sentinel element from ctl_table array Joel Granados via B4 Relay
2023-11-07 13:44 ` [PATCH 2/4] aio: Remove the now superfluous sentinel elements " Joel Granados via B4 Relay
2023-11-07 16:22   ` Darrick J. Wong
2023-11-08  8:28     ` Joel Granados
2023-11-08  3:42   ` Eric Biggers
2023-11-08  8:26     ` Joel Granados
2023-11-09 16:00     ` Joel Granados
2023-11-09 16:08       ` Eric Biggers
2023-11-09 21:12         ` Joel Granados
2023-11-08  9:56   ` Jan Kara
2023-11-07 13:44 ` [PATCH 3/4] sysctl: " Joel Granados via B4 Relay
2023-11-07 13:44 ` [PATCH 4/4] coda: " Joel Granados via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).