* [PATCH 01/14] sysctl: Prefer ctl_table_header in proc_sysctl
2023-07-26 14:06 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Joel Granados
@ 2023-07-26 14:06 ` Joel Granados
2023-07-26 14:06 ` [PATCH 02/14] sysctl: Use ctl_table_header in list_for_each_table_entry Joel Granados
` (7 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Joel Granados @ 2023-07-26 14:06 UTC (permalink / raw)
To: mcgrof, Kees Cook, Iurii Zaikin
Cc: willy, josh, Joel Granados, linux-kernel, linux-fsdevel
This is a preparation commit to use ctl_table_header instead of
ctl_table as the element that is passed around in proc_sysctl.c.
This will become necessary when the size can no longer be calculated
by searching for an empty sentinel in the ctl_table array and
will live in the ctl_table_header.
Signed-off-by: Joel Granados <j.granados@samsung.com>
---
fs/proc/proc_sysctl.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 5ea42653126e..94d71446da39 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -1125,11 +1125,11 @@ static int sysctl_check_table_array(const char *path, struct ctl_table *table)
return err;
}
-static int sysctl_check_table(const char *path, struct ctl_table *table)
+static int sysctl_check_table(const char *path, struct ctl_table_header *header)
{
struct ctl_table *entry;
int err = 0;
- list_for_each_table_entry(entry, table) {
+ list_for_each_table_entry(entry, header->ctl_table) {
if ((entry->proc_handler == proc_dostring) ||
(entry->proc_handler == proc_dobool) ||
(entry->proc_handler == proc_dointvec) ||
@@ -1159,8 +1159,7 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
return err;
}
-static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
- struct ctl_table_root *link_root)
+static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_header *head)
{
struct ctl_table *link_table, *entry, *link;
struct ctl_table_header *links;
@@ -1170,7 +1169,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
name_bytes = 0;
nr_entries = 0;
- list_for_each_table_entry(entry, table) {
+ list_for_each_table_entry(entry, head->ctl_table) {
nr_entries++;
name_bytes += strlen(entry->procname) + 1;
}
@@ -1189,12 +1188,12 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
link_name = (char *)&link_table[nr_entries + 1];
link = link_table;
- list_for_each_table_entry(entry, table) {
+ list_for_each_table_entry(entry, head->ctl_table) {
int len = strlen(entry->procname) + 1;
memcpy(link_name, entry->procname, len);
link->procname = link_name;
link->mode = S_IFLNK|S_IRWXUGO;
- link->data = link_root;
+ link->data = head->root;
link_name += len;
link++;
}
@@ -1205,15 +1204,16 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
}
static bool get_links(struct ctl_dir *dir,
- struct ctl_table *table, struct ctl_table_root *link_root)
+ struct ctl_table_header *header,
+ struct ctl_table_root *link_root)
{
- struct ctl_table_header *head;
+ struct ctl_table_header *tmp_head;
struct ctl_table *entry, *link;
/* Are there links available for every entry in table? */
- list_for_each_table_entry(entry, table) {
+ list_for_each_table_entry(entry, header->ctl_table) {
const char *procname = entry->procname;
- link = find_entry(&head, dir, procname, strlen(procname));
+ link = find_entry(&tmp_head, dir, procname, strlen(procname));
if (!link)
return false;
if (S_ISDIR(link->mode) && S_ISDIR(entry->mode))
@@ -1224,10 +1224,10 @@ static bool get_links(struct ctl_dir *dir,
}
/* The checks passed. Increase the registration count on the links */
- list_for_each_table_entry(entry, table) {
+ list_for_each_table_entry(entry, header->ctl_table) {
const char *procname = entry->procname;
- link = find_entry(&head, dir, procname, strlen(procname));
- head->nreg++;
+ link = find_entry(&tmp_head, dir, procname, strlen(procname));
+ tmp_head->nreg++;
}
return true;
}
@@ -1246,13 +1246,13 @@ static int insert_links(struct ctl_table_header *head)
if (IS_ERR(core_parent))
return 0;
- if (get_links(core_parent, head->ctl_table, head->root))
+ if (get_links(core_parent, head, head->root))
return 0;
core_parent->header.nreg++;
spin_unlock(&sysctl_lock);
- links = new_links(core_parent, head->ctl_table, head->root);
+ links = new_links(core_parent, head);
spin_lock(&sysctl_lock);
err = -ENOMEM;
@@ -1260,7 +1260,7 @@ static int insert_links(struct ctl_table_header *head)
goto out;
err = 0;
- if (get_links(core_parent, head->ctl_table, head->root)) {
+ if (get_links(core_parent, head, head->root)) {
kfree(links);
goto out;
}
@@ -1371,7 +1371,7 @@ struct ctl_table_header *__register_sysctl_table(
node = (struct ctl_node *)(header + 1);
init_header(header, root, set, node, table);
- if (sysctl_check_table(path, table))
+ if (sysctl_check_table(path, header))
goto fail;
spin_lock(&sysctl_lock);
--
2.30.2
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 02/14] sysctl: Use ctl_table_header in list_for_each_table_entry
2023-07-26 14:06 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Joel Granados
2023-07-26 14:06 ` [PATCH 01/14] sysctl: Prefer ctl_table_header in proc_sysctl Joel Granados
@ 2023-07-26 14:06 ` Joel Granados
2023-07-26 14:06 ` [PATCH 03/14] sysctl: Add ctl_table_size to ctl_table_header Joel Granados
` (6 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Joel Granados @ 2023-07-26 14:06 UTC (permalink / raw)
To: mcgrof, Kees Cook, Iurii Zaikin
Cc: willy, josh, Joel Granados, linux-kernel, linux-fsdevel
Now that the ctl_header is the preferred way of passing ctl_table
elements around, we use it (the header) in the list_for_each_table_entry
macro.
Signed-off-by: Joel Granados <j.granados@samsung.com>
---
fs/proc/proc_sysctl.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 94d71446da39..884460b0385b 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -19,8 +19,8 @@
#include <linux/kmemleak.h>
#include "internal.h"
-#define list_for_each_table_entry(entry, table) \
- for ((entry) = (table); (entry)->procname; (entry)++)
+#define list_for_each_table_entry(entry, header) \
+ for ((entry) = (header->ctl_table); (entry)->procname; (entry)++)
static const struct dentry_operations proc_sys_dentry_operations;
static const struct file_operations proc_sys_file_operations;
@@ -204,7 +204,7 @@ static void init_header(struct ctl_table_header *head,
if (node) {
struct ctl_table *entry;
- list_for_each_table_entry(entry, table) {
+ list_for_each_table_entry(entry, head) {
node->header = head;
node++;
}
@@ -215,7 +215,7 @@ static void erase_header(struct ctl_table_header *head)
{
struct ctl_table *entry;
- list_for_each_table_entry(entry, head->ctl_table)
+ list_for_each_table_entry(entry, head)
erase_entry(head, entry);
}
@@ -242,7 +242,7 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)
err = insert_links(header);
if (err)
goto fail_links;
- list_for_each_table_entry(entry, header->ctl_table) {
+ list_for_each_table_entry(entry, header) {
err = insert_entry(header, entry);
if (err)
goto fail;
@@ -1129,7 +1129,7 @@ static int sysctl_check_table(const char *path, struct ctl_table_header *header)
{
struct ctl_table *entry;
int err = 0;
- list_for_each_table_entry(entry, header->ctl_table) {
+ list_for_each_table_entry(entry, header) {
if ((entry->proc_handler == proc_dostring) ||
(entry->proc_handler == proc_dobool) ||
(entry->proc_handler == proc_dointvec) ||
@@ -1169,7 +1169,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
name_bytes = 0;
nr_entries = 0;
- list_for_each_table_entry(entry, head->ctl_table) {
+ list_for_each_table_entry(entry, head) {
nr_entries++;
name_bytes += strlen(entry->procname) + 1;
}
@@ -1188,7 +1188,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
link_name = (char *)&link_table[nr_entries + 1];
link = link_table;
- list_for_each_table_entry(entry, head->ctl_table) {
+ list_for_each_table_entry(entry, head) {
int len = strlen(entry->procname) + 1;
memcpy(link_name, entry->procname, len);
link->procname = link_name;
@@ -1211,7 +1211,7 @@ static bool get_links(struct ctl_dir *dir,
struct ctl_table *entry, *link;
/* Are there links available for every entry in table? */
- list_for_each_table_entry(entry, header->ctl_table) {
+ list_for_each_table_entry(entry, header) {
const char *procname = entry->procname;
link = find_entry(&tmp_head, dir, procname, strlen(procname));
if (!link)
@@ -1224,7 +1224,7 @@ static bool get_links(struct ctl_dir *dir,
}
/* The checks passed. Increase the registration count on the links */
- list_for_each_table_entry(entry, header->ctl_table) {
+ list_for_each_table_entry(entry, header) {
const char *procname = entry->procname;
link = find_entry(&tmp_head, dir, procname, strlen(procname));
tmp_head->nreg++;
@@ -1356,12 +1356,14 @@ struct ctl_table_header *__register_sysctl_table(
{
struct ctl_table_root *root = set->dir.header.root;
struct ctl_table_header *header;
+ struct ctl_table_header h_tmp;
struct ctl_dir *dir;
struct ctl_table *entry;
struct ctl_node *node;
int nr_entries = 0;
- list_for_each_table_entry(entry, table)
+ h_tmp.ctl_table = table;
+ list_for_each_table_entry(entry, (&h_tmp))
nr_entries++;
header = kzalloc(sizeof(struct ctl_table_header) +
@@ -1471,7 +1473,7 @@ static void put_links(struct ctl_table_header *header)
if (IS_ERR(core_parent))
return;
- list_for_each_table_entry(entry, header->ctl_table) {
+ list_for_each_table_entry(entry, header) {
struct ctl_table_header *link_head;
struct ctl_table *link;
const char *name = entry->procname;
--
2.30.2
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 03/14] sysctl: Add ctl_table_size to ctl_table_header
2023-07-26 14:06 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Joel Granados
2023-07-26 14:06 ` [PATCH 01/14] sysctl: Prefer ctl_table_header in proc_sysctl Joel Granados
2023-07-26 14:06 ` [PATCH 02/14] sysctl: Use ctl_table_header in list_for_each_table_entry Joel Granados
@ 2023-07-26 14:06 ` Joel Granados
2023-07-28 10:48 ` Simon Horman
2023-07-26 14:06 ` [PATCH 04/14] sysctl: Add size argument to init_header Joel Granados
` (5 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Joel Granados @ 2023-07-26 14:06 UTC (permalink / raw)
To: mcgrof, Kees Cook, Iurii Zaikin
Cc: willy, josh, Joel Granados, linux-kernel, linux-fsdevel
The new ctl_table_size element will hold the size of the ctl_table
contained in the header. This value is passed by the callers to the
sysctl register infrastructure.
This is a preparation commit that allows us to systematically add
ctl_table_size and start using it only when it is in all the places
where there is a sysctl registration.
Signed-off-by: Joel Granados <j.granados@samsung.com>
---
include/linux/sysctl.h | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 59d451f455bf..33252ad58ebe 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -159,12 +159,22 @@ struct ctl_node {
struct ctl_table_header *header;
};
-/* struct ctl_table_header is used to maintain dynamic lists of
- struct ctl_table trees. */
+/**
+ * struct ctl_table_header - maintains dynamic lists of struct ctl_table trees
+ * @ctl_table: pointer to the first element in ctl_table array
+ * @ctl_table_size: number of elements pointed by @ctl_table
+ * @used: The entry will never be touched when equal to 0.
+ * @count: Upped every time something is added to @inodes and downed every time
+ * something is removed from inodes
+ * @nreg: When nreg drops to 0 the ctl_table_header will be unregistered.
+ * @rcu: Delays the freeing of the inode. Introduced with "unfuck proc_sysctl ->d_compare()"
+ *
+ */
struct ctl_table_header {
union {
struct {
struct ctl_table *ctl_table;
+ int ctl_table_size;
int used;
int count;
int nreg;
--
2.30.2
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 03/14] sysctl: Add ctl_table_size to ctl_table_header
2023-07-26 14:06 ` [PATCH 03/14] sysctl: Add ctl_table_size to ctl_table_header Joel Granados
@ 2023-07-28 10:48 ` Simon Horman
2023-07-31 12:10 ` Joel Granados
0 siblings, 1 reply; 23+ messages in thread
From: Simon Horman @ 2023-07-28 10:48 UTC (permalink / raw)
To: Joel Granados
Cc: mcgrof, Kees Cook, Iurii Zaikin, willy, josh, linux-kernel,
linux-fsdevel
On Wed, Jul 26, 2023 at 04:06:23PM +0200, Joel Granados wrote:
> The new ctl_table_size element will hold the size of the ctl_table
> contained in the header. This value is passed by the callers to the
> sysctl register infrastructure.
>
> This is a preparation commit that allows us to systematically add
> ctl_table_size and start using it only when it is in all the places
> where there is a sysctl registration.
>
> Signed-off-by: Joel Granados <j.granados@samsung.com>
> ---
> include/linux/sysctl.h | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
> index 59d451f455bf..33252ad58ebe 100644
> --- a/include/linux/sysctl.h
> +++ b/include/linux/sysctl.h
> @@ -159,12 +159,22 @@ struct ctl_node {
> struct ctl_table_header *header;
> };
>
> -/* struct ctl_table_header is used to maintain dynamic lists of
> - struct ctl_table trees. */
> +/**
> + * struct ctl_table_header - maintains dynamic lists of struct ctl_table trees
> + * @ctl_table: pointer to the first element in ctl_table array
> + * @ctl_table_size: number of elements pointed by @ctl_table
> + * @used: The entry will never be touched when equal to 0.
> + * @count: Upped every time something is added to @inodes and downed every time
> + * something is removed from inodes
> + * @nreg: When nreg drops to 0 the ctl_table_header will be unregistered.
> + * @rcu: Delays the freeing of the inode. Introduced with "unfuck proc_sysctl ->d_compare()"
> + *
> + */
Please consider documenting all fields of struct ctl_table_header.
./scripts/kernel-doc complains that the following are missing:
unregistering
ctl_table_arg
root
set
parent
node
inodes
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 03/14] sysctl: Add ctl_table_size to ctl_table_header
2023-07-28 10:48 ` Simon Horman
@ 2023-07-31 12:10 ` Joel Granados
0 siblings, 0 replies; 23+ messages in thread
From: Joel Granados @ 2023-07-31 12:10 UTC (permalink / raw)
To: Simon Horman
Cc: mcgrof, Kees Cook, Iurii Zaikin, willy, josh, linux-kernel,
linux-fsdevel
[-- Attachment #1: Type: text/plain, Size: 3338 bytes --]
On Fri, Jul 28, 2023 at 12:48:31PM +0200, Simon Horman wrote:
> On Wed, Jul 26, 2023 at 04:06:23PM +0200, Joel Granados wrote:
> > The new ctl_table_size element will hold the size of the ctl_table
> > contained in the header. This value is passed by the callers to the
> > sysctl register infrastructure.
> >
> > This is a preparation commit that allows us to systematically add
> > ctl_table_size and start using it only when it is in all the places
> > where there is a sysctl registration.
> >
> > Signed-off-by: Joel Granados <j.granados@samsung.com>
> > ---
> > include/linux/sysctl.h | 14 ++++++++++++--
> > 1 file changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
> > index 59d451f455bf..33252ad58ebe 100644
> > --- a/include/linux/sysctl.h
> > +++ b/include/linux/sysctl.h
> > @@ -159,12 +159,22 @@ struct ctl_node {
> > struct ctl_table_header *header;
> > };
> >
> > -/* struct ctl_table_header is used to maintain dynamic lists of
> > - struct ctl_table trees. */
> > +/**
> > + * struct ctl_table_header - maintains dynamic lists of struct ctl_table trees
> > + * @ctl_table: pointer to the first element in ctl_table array
> > + * @ctl_table_size: number of elements pointed by @ctl_table
> > + * @used: The entry will never be touched when equal to 0.
> > + * @count: Upped every time something is added to @inodes and downed every time
> > + * something is removed from inodes
> > + * @nreg: When nreg drops to 0 the ctl_table_header will be unregistered.
> > + * @rcu: Delays the freeing of the inode. Introduced with "unfuck proc_sysctl ->d_compare()"
> > + *
> > + */
>
> Please consider documenting all fields of struct ctl_table_header.
> ./scripts/kernel-doc complains that the following are missing:
>
> unregistering
> ctl_table_arg
> root
> set
> parent
> node
> inodes
This one I'm unsure about as things go in and then get changed without updating the docs
I have tried to follow the changes from the point of introduction, but as I said, I'm
unsure if I missed something.
diff --git i/include/linux/sysctl.h w/include/linux/sysctl.h
index 09d7429d67c0..fc0461f2a0c8 100644
--- i/include/linux/sysctl.h
+++ w/include/linux/sysctl.h
@@ -168,7 +168,13 @@ struct ctl_node {
* something is removed from inodes
* @nreg: When nreg drops to 0 the ctl_table_header will be unregistered.
* @rcu: Delays the freeing of the inode. Introduced with "unfuck proc_sysctl ->d_compare()"
- *
+ * @unregistering: Holds the completion when dropping (un-registering) a ctl_table
+ * @ctl_table_arg: The ctl_table array that was passed to register_sysctl_paths
+ * @root: The root of a sysctl namespace
+ * @set: Set of sysctls
+ * @parent: Pointer to the ctl_dir of the parent directory
+ * @node: Pointer to the rbtree node for this header
+ * @inodes: head for proc_inode->sysctl_inodes
*/
struct ctl_table_header {
union {
@@ -187,7 +193,7 @@ struct ctl_table_header {
struct ctl_table_set *set;
struct ctl_dir *parent;
struct ctl_node *node;
- struct hlist_head inodes; /* head for proc_inode->sysctl_inodes */
+ struct hlist_head inodes;
};
struct ctl_dir {
~
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 04/14] sysctl: Add size argument to init_header
2023-07-26 14:06 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Joel Granados
` (2 preceding siblings ...)
2023-07-26 14:06 ` [PATCH 03/14] sysctl: Add ctl_table_size to ctl_table_header Joel Granados
@ 2023-07-26 14:06 ` Joel Granados
2023-07-26 14:06 ` [PATCH 05/14] sysctl: Add a size arg to __register_sysctl_table Joel Granados
` (4 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Joel Granados @ 2023-07-26 14:06 UTC (permalink / raw)
To: mcgrof, Kees Cook, Iurii Zaikin
Cc: willy, josh, Joel Granados, linux-kernel, linux-fsdevel
In this commit, the size of the ctl_table array is passed to initialize
the ctl_table_size element in the ctl_table_header struct. Although
ctl_table_size is not currently used, this step prepares us for when we
begin traversing the ctl_table array with it. In __register_sysctl_table
we use a calculated size until we add the size argument to that
function.
Signed-off-by: Joel Granados <j.granados@samsung.com>
---
fs/proc/proc_sysctl.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 884460b0385b..fa1438f1a355 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -188,9 +188,10 @@ static void erase_entry(struct ctl_table_header *head, struct ctl_table *entry)
static void init_header(struct ctl_table_header *head,
struct ctl_table_root *root, struct ctl_table_set *set,
- struct ctl_node *node, struct ctl_table *table)
+ struct ctl_node *node, struct ctl_table *table, size_t table_size)
{
head->ctl_table = table;
+ head->ctl_table_size = table_size;
head->ctl_table_arg = table;
head->used = 0;
head->count = 1;
@@ -973,7 +974,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
memcpy(new_name, name, namelen);
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);
+ init_header(&new->header, set->dir.header.root, set, node, table, 1);
return new;
}
@@ -1197,7 +1198,8 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
link_name += len;
link++;
}
- init_header(links, dir->header.root, dir->header.set, node, link_table);
+ init_header(links, dir->header.root, dir->header.set, node, link_table,
+ head->ctl_table_size);
links->nreg = nr_entries;
return links;
@@ -1372,7 +1374,7 @@ struct ctl_table_header *__register_sysctl_table(
return NULL;
node = (struct ctl_node *)(header + 1);
- init_header(header, root, set, node, table);
+ init_header(header, root, set, node, table, nr_entries);
if (sysctl_check_table(path, header))
goto fail;
@@ -1537,7 +1539,7 @@ void setup_sysctl_set(struct ctl_table_set *set,
{
memset(set, 0, sizeof(*set));
set->is_seen = is_seen;
- init_header(&set->dir.header, root, set, NULL, root_table);
+ init_header(&set->dir.header, root, set, NULL, root_table, 1);
}
void retire_sysctl_set(struct ctl_table_set *set)
--
2.30.2
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 05/14] sysctl: Add a size arg to __register_sysctl_table
2023-07-26 14:06 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Joel Granados
` (3 preceding siblings ...)
2023-07-26 14:06 ` [PATCH 04/14] sysctl: Add size argument to init_header Joel Granados
@ 2023-07-26 14:06 ` Joel Granados
2023-07-28 10:51 ` Simon Horman
2023-07-26 14:06 ` [PATCH 06/14] sysctl: Add size to register_sysctl Joel Granados
` (3 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Joel Granados @ 2023-07-26 14:06 UTC (permalink / raw)
To: mcgrof, Kees Cook, Iurii Zaikin, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: willy, josh, Joel Granados, linux-kernel, linux-fsdevel, netdev
This is part of the effort to remove the sentinel element in the
ctl_table arrays. We add a table_size argument to
__register_sysctl_table and adjust callers, all of which pass ctl_table
pointers and need an explicit call to ARRAY_SIZE.
The new table_size argument does not yet have any effect in the
init_header call which is still dependent on the sentinel's presence.
table_size *does* however drive the `kzalloc` allocation in
__register_sysctl_table with no adverse effects as the allocated memory
is either one element greater than the calculated ctl_table array (for
the calls in ipc_sysctl.c, mq_sysctl.c and ucount.c) or the exact size
of the calculated ctl_table array (for the call from sysctl_net.c and
register_sysctl). This approach will allows us to "just" remove the
sentinel without further changes to __register_sysctl_table as
table_size will represent the exact size for all the callers at that
point.
Temporarily implement a size calculation in register_net_sysctl, which
is an indirection call for all the network register calls.
Signed-off-by: Joel Granados <j.granados@samsung.com>
---
fs/proc/proc_sysctl.c | 22 +++++++++++-----------
include/linux/sysctl.h | 2 +-
ipc/ipc_sysctl.c | 4 +++-
ipc/mq_sysctl.c | 4 +++-
kernel/ucount.c | 3 ++-
net/sysctl_net.c | 8 +++++++-
6 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index fa1438f1a355..8d04f01a89c1 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -1354,27 +1354,20 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)
*/
struct ctl_table_header *__register_sysctl_table(
struct ctl_table_set *set,
- const char *path, struct ctl_table *table)
+ const char *path, struct ctl_table *table, size_t table_size)
{
struct ctl_table_root *root = set->dir.header.root;
struct ctl_table_header *header;
- struct ctl_table_header h_tmp;
struct ctl_dir *dir;
- struct ctl_table *entry;
struct ctl_node *node;
- int nr_entries = 0;
-
- h_tmp.ctl_table = table;
- list_for_each_table_entry(entry, (&h_tmp))
- nr_entries++;
header = kzalloc(sizeof(struct ctl_table_header) +
- sizeof(struct ctl_node)*nr_entries, GFP_KERNEL_ACCOUNT);
+ sizeof(struct ctl_node)*table_size, GFP_KERNEL_ACCOUNT);
if (!header)
return NULL;
node = (struct ctl_node *)(header + 1);
- init_header(header, root, set, node, table, nr_entries);
+ init_header(header, root, set, node, table, table_size);
if (sysctl_check_table(path, header))
goto fail;
@@ -1423,8 +1416,15 @@ struct ctl_table_header *__register_sysctl_table(
*/
struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table)
{
+ int count = 0;
+ struct ctl_table *entry;
+ struct ctl_table_header t_hdr;
+
+ t_hdr.ctl_table = table;
+ list_for_each_table_entry(entry, (&t_hdr))
+ count++;
return __register_sysctl_table(&sysctl_table_root.default_set,
- path, table);
+ path, table, count);
}
EXPORT_SYMBOL(register_sysctl);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 33252ad58ebe..0495c858989f 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -226,7 +226,7 @@ extern void retire_sysctl_set(struct ctl_table_set *set);
struct ctl_table_header *__register_sysctl_table(
struct ctl_table_set *set,
- const char *path, struct ctl_table *table);
+ const char *path, struct ctl_table *table, size_t table_size);
struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
void unregister_sysctl_table(struct ctl_table_header * table);
diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
index ef313ecfb53a..8c62e443f78b 100644
--- a/ipc/ipc_sysctl.c
+++ b/ipc/ipc_sysctl.c
@@ -259,7 +259,9 @@ bool setup_ipc_sysctls(struct ipc_namespace *ns)
tbl[i].data = NULL;
}
- ns->ipc_sysctls = __register_sysctl_table(&ns->ipc_set, "kernel", tbl);
+ ns->ipc_sysctls = __register_sysctl_table(&ns->ipc_set,
+ "kernel", tbl,
+ ARRAY_SIZE(ipc_sysctls));
}
if (!ns->ipc_sysctls) {
kfree(tbl);
diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
index fbf6a8b93a26..ebb5ed81c151 100644
--- a/ipc/mq_sysctl.c
+++ b/ipc/mq_sysctl.c
@@ -109,7 +109,9 @@ bool setup_mq_sysctls(struct ipc_namespace *ns)
tbl[i].data = NULL;
}
- ns->mq_sysctls = __register_sysctl_table(&ns->mq_set, "fs/mqueue", tbl);
+ ns->mq_sysctls = __register_sysctl_table(&ns->mq_set,
+ "fs/mqueue", tbl,
+ ARRAY_SIZE(mq_sysctls));
}
if (!ns->mq_sysctls) {
kfree(tbl);
diff --git a/kernel/ucount.c b/kernel/ucount.c
index ee8e57fd6f90..2b80264bb79f 100644
--- a/kernel/ucount.c
+++ b/kernel/ucount.c
@@ -104,7 +104,8 @@ bool setup_userns_sysctls(struct user_namespace *ns)
for (i = 0; i < UCOUNT_COUNTS; i++) {
tbl[i].data = &ns->ucount_max[i];
}
- ns->sysctls = __register_sysctl_table(&ns->set, "user", tbl);
+ ns->sysctls = __register_sysctl_table(&ns->set, "user", tbl,
+ ARRAY_SIZE(user_table));
}
if (!ns->sysctls) {
kfree(tbl);
diff --git a/net/sysctl_net.c b/net/sysctl_net.c
index 4b45ed631eb8..8ee4b74bc009 100644
--- a/net/sysctl_net.c
+++ b/net/sysctl_net.c
@@ -163,10 +163,16 @@ static void ensure_safe_net_sysctl(struct net *net, const char *path,
struct ctl_table_header *register_net_sysctl(struct net *net,
const char *path, struct ctl_table *table)
{
+ int count = 0;
+ struct ctl_table *entry;
+
if (!net_eq(net, &init_net))
ensure_safe_net_sysctl(net, path, table);
- return __register_sysctl_table(&net->sysctls, path, table);
+ for (entry = table; entry->procname; entry++)
+ count++;
+
+ return __register_sysctl_table(&net->sysctls, path, table, count);
}
EXPORT_SYMBOL_GPL(register_net_sysctl);
--
2.30.2
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 05/14] sysctl: Add a size arg to __register_sysctl_table
2023-07-26 14:06 ` [PATCH 05/14] sysctl: Add a size arg to __register_sysctl_table Joel Granados
@ 2023-07-28 10:51 ` Simon Horman
2023-07-28 16:08 ` Joel Granados
0 siblings, 1 reply; 23+ messages in thread
From: Simon Horman @ 2023-07-28 10:51 UTC (permalink / raw)
To: Joel Granados
Cc: mcgrof, Kees Cook, Iurii Zaikin, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, willy, josh, linux-kernel,
linux-fsdevel, netdev
On Wed, Jul 26, 2023 at 04:06:25PM +0200, Joel Granados wrote:
> This is part of the effort to remove the sentinel element in the
> ctl_table arrays. We add a table_size argument to
> __register_sysctl_table and adjust callers, all of which pass ctl_table
> pointers and need an explicit call to ARRAY_SIZE.
>
> The new table_size argument does not yet have any effect in the
> init_header call which is still dependent on the sentinel's presence.
> table_size *does* however drive the `kzalloc` allocation in
> __register_sysctl_table with no adverse effects as the allocated memory
> is either one element greater than the calculated ctl_table array (for
> the calls in ipc_sysctl.c, mq_sysctl.c and ucount.c) or the exact size
> of the calculated ctl_table array (for the call from sysctl_net.c and
> register_sysctl). This approach will allows us to "just" remove the
> sentinel without further changes to __register_sysctl_table as
> table_size will represent the exact size for all the callers at that
> point.
>
> Temporarily implement a size calculation in register_net_sysctl, which
> is an indirection call for all the network register calls.
>
> Signed-off-by: Joel Granados <j.granados@samsung.com>
> ---
> fs/proc/proc_sysctl.c | 22 +++++++++++-----------
> include/linux/sysctl.h | 2 +-
> ipc/ipc_sysctl.c | 4 +++-
> ipc/mq_sysctl.c | 4 +++-
> kernel/ucount.c | 3 ++-
> net/sysctl_net.c | 8 +++++++-
> 6 files changed, 27 insertions(+), 16 deletions(-)
>
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index fa1438f1a355..8d04f01a89c1 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -1354,27 +1354,20 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)
> */
> struct ctl_table_header *__register_sysctl_table(
> struct ctl_table_set *set,
> - const char *path, struct ctl_table *table)
> + const char *path, struct ctl_table *table, size_t table_size)
Hi Joel,
Please consider adding table_size to the kernel doc for this function.
...
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 05/14] sysctl: Add a size arg to __register_sysctl_table
2023-07-28 10:51 ` Simon Horman
@ 2023-07-28 16:08 ` Joel Granados
0 siblings, 0 replies; 23+ messages in thread
From: Joel Granados @ 2023-07-28 16:08 UTC (permalink / raw)
To: Simon Horman
Cc: mcgrof, Kees Cook, Iurii Zaikin, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, willy, josh, linux-kernel,
linux-fsdevel, netdev
[-- Attachment #1: Type: text/plain, Size: 2326 bytes --]
On Fri, Jul 28, 2023 at 12:51:22PM +0200, Simon Horman wrote:
> On Wed, Jul 26, 2023 at 04:06:25PM +0200, Joel Granados wrote:
> > This is part of the effort to remove the sentinel element in the
> > ctl_table arrays. We add a table_size argument to
> > __register_sysctl_table and adjust callers, all of which pass ctl_table
> > pointers and need an explicit call to ARRAY_SIZE.
> >
> > The new table_size argument does not yet have any effect in the
> > init_header call which is still dependent on the sentinel's presence.
> > table_size *does* however drive the `kzalloc` allocation in
> > __register_sysctl_table with no adverse effects as the allocated memory
> > is either one element greater than the calculated ctl_table array (for
> > the calls in ipc_sysctl.c, mq_sysctl.c and ucount.c) or the exact size
> > of the calculated ctl_table array (for the call from sysctl_net.c and
> > register_sysctl). This approach will allows us to "just" remove the
> > sentinel without further changes to __register_sysctl_table as
> > table_size will represent the exact size for all the callers at that
> > point.
> >
> > Temporarily implement a size calculation in register_net_sysctl, which
> > is an indirection call for all the network register calls.
> >
> > Signed-off-by: Joel Granados <j.granados@samsung.com>
> > ---
> > fs/proc/proc_sysctl.c | 22 +++++++++++-----------
> > include/linux/sysctl.h | 2 +-
> > ipc/ipc_sysctl.c | 4 +++-
> > ipc/mq_sysctl.c | 4 +++-
> > kernel/ucount.c | 3 ++-
> > net/sysctl_net.c | 8 +++++++-
> > 6 files changed, 27 insertions(+), 16 deletions(-)
> >
> > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> > index fa1438f1a355..8d04f01a89c1 100644
> > --- a/fs/proc/proc_sysctl.c
> > +++ b/fs/proc/proc_sysctl.c
> > @@ -1354,27 +1354,20 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)
> > */
> > struct ctl_table_header *__register_sysctl_table(
> > struct ctl_table_set *set,
> > - const char *path, struct ctl_table *table)
> > + const char *path, struct ctl_table *table, size_t table_size)
>
> Hi Joel,
>
> Please consider adding table_size to the kernel doc for this function.
Good catch. Will do for V2.
>
> ...
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 06/14] sysctl: Add size to register_sysctl
2023-07-26 14:06 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Joel Granados
` (4 preceding siblings ...)
2023-07-26 14:06 ` [PATCH 05/14] sysctl: Add a size arg to __register_sysctl_table Joel Granados
@ 2023-07-26 14:06 ` Joel Granados
2023-07-26 17:58 ` Luis Chamberlain
2023-07-26 14:06 ` [PATCH 07/14] sysctl: Add size arg to __register_sysctl_init Joel Granados
` (2 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Joel Granados @ 2023-07-26 14:06 UTC (permalink / raw)
To: mcgrof, Catalin Marinas, Will Deacon, Heiko Carstens,
Vasily Gorbik, Alexander Gordeev, Kees Cook, Iurii Zaikin,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: willy, josh, Joel Granados, Christian Borntraeger, Sven Schnelle,
linux-arm-kernel, linux-kernel, linux-s390, linux-fsdevel, netdev
In order to remove the end element from the ctl_table struct arrays, we
replace the register_syctl function with a macro that will add the
ARRAY_SIZE to the new register_sysctl_sz function. In this way the
callers that are already using an array of ctl_table structs do not have
to change. We *do* change the callers that pass the ctl_table array as a
pointer.
Signed-off-by: Joel Granados <j.granados@samsung.com>
---
arch/arm64/kernel/armv8_deprecated.c | 2 +-
arch/s390/appldata/appldata_base.c | 2 +-
fs/proc/proc_sysctl.c | 30 +++++++++++++++-------------
include/linux/sysctl.h | 10 ++++++++--
kernel/ucount.c | 2 +-
net/sysctl_net.c | 2 +-
6 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
index 1febd412b4d2..e459cfd33711 100644
--- a/arch/arm64/kernel/armv8_deprecated.c
+++ b/arch/arm64/kernel/armv8_deprecated.c
@@ -569,7 +569,7 @@ static void __init register_insn_emulation(struct insn_emulation *insn)
sysctl->extra2 = &insn->max;
sysctl->proc_handler = emulation_proc_handler;
- register_sysctl("abi", sysctl);
+ register_sysctl_sz("abi", sysctl, 1);
}
}
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index bbefe5e86bdf..3b0994625652 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -365,7 +365,7 @@ int appldata_register_ops(struct appldata_ops *ops)
ops->ctl_table[0].proc_handler = appldata_generic_handler;
ops->ctl_table[0].data = ops;
- ops->sysctl_header = register_sysctl(appldata_proc_name, ops->ctl_table);
+ ops->sysctl_header = register_sysctl_sz(appldata_proc_name, ops->ctl_table, 1);
if (!ops->sysctl_header)
goto out;
return 0;
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 8d04f01a89c1..c04293911e7e 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -43,7 +43,7 @@ static struct ctl_table sysctl_mount_point[] = {
*/
struct ctl_table_header *register_sysctl_mount_point(const char *path)
{
- return register_sysctl(path, sysctl_mount_point);
+ return register_sysctl_sz(path, sysctl_mount_point, 0);
}
EXPORT_SYMBOL(register_sysctl_mount_point);
@@ -1398,7 +1398,7 @@ struct ctl_table_header *__register_sysctl_table(
}
/**
- * register_sysctl - register a sysctl table
+ * register_sysctl_sz - register a sysctl table
* @path: The path to the directory the sysctl table is in. If the path
* doesn't exist we will create it for you.
* @table: the table structure. The calller must ensure the life of the @table
@@ -1408,25 +1408,20 @@ struct ctl_table_header *__register_sysctl_table(
* to call unregister_sysctl_table() and can instead use something like
* register_sysctl_init() which does not care for the result of the syctl
* registration.
+ * @table_size: The number of elements in table.
*
* Register a sysctl table. @table should be a filled in ctl_table
* array. A completely 0 filled entry terminates the table.
*
* See __register_sysctl_table for more details.
*/
-struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table)
+struct ctl_table_header *register_sysctl_sz(const char *path, struct ctl_table *table,
+ size_t table_size)
{
- int count = 0;
- struct ctl_table *entry;
- struct ctl_table_header t_hdr;
-
- t_hdr.ctl_table = table;
- list_for_each_table_entry(entry, (&t_hdr))
- count++;
return __register_sysctl_table(&sysctl_table_root.default_set,
- path, table, count);
+ path, table, table_size);
}
-EXPORT_SYMBOL(register_sysctl);
+EXPORT_SYMBOL(register_sysctl_sz);
/**
* __register_sysctl_init() - register sysctl table to path
@@ -1451,10 +1446,17 @@ EXPORT_SYMBOL(register_sysctl);
void __init __register_sysctl_init(const char *path, struct ctl_table *table,
const char *table_name)
{
- struct ctl_table_header *hdr = register_sysctl(path, table);
+ int count = 0;
+ struct ctl_table *entry;
+ struct ctl_table_header t_hdr, *hdr;
+
+ t_hdr.ctl_table = table;
+ list_for_each_table_entry(entry, (&t_hdr))
+ count++;
+ hdr = register_sysctl_sz(path, table, count);
if (unlikely(!hdr)) {
- pr_err("failed when register_sysctl %s to %s\n", table_name, path);
+ pr_err("failed when register_sysctl_sz %s to %s\n", table_name, path);
return;
}
kmemleak_not_leak(hdr);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 0495c858989f..b1168ae281c9 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -215,6 +215,9 @@ struct ctl_path {
const char *procname;
};
+#define register_sysctl(path, table) \
+ register_sysctl_sz(path, table, ARRAY_SIZE(table))
+
#ifdef CONFIG_SYSCTL
void proc_sys_poll_notify(struct ctl_table_poll *poll);
@@ -227,7 +230,8 @@ extern void retire_sysctl_set(struct ctl_table_set *set);
struct ctl_table_header *__register_sysctl_table(
struct ctl_table_set *set,
const char *path, struct ctl_table *table, size_t table_size);
-struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
+struct ctl_table_header *register_sysctl_sz(const char *path, struct ctl_table *table,
+ size_t table_size);
void unregister_sysctl_table(struct ctl_table_header * table);
extern int sysctl_init_bases(void);
@@ -262,7 +266,9 @@ static inline struct ctl_table_header *register_sysctl_mount_point(const char *p
return NULL;
}
-static inline struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table)
+static inline struct ctl_table_header *register_sysctl_sz(const char *path,
+ struct ctl_table *table,
+ size_t table_size)
{
return NULL;
}
diff --git a/kernel/ucount.c b/kernel/ucount.c
index 2b80264bb79f..4aa6166cb856 100644
--- a/kernel/ucount.c
+++ b/kernel/ucount.c
@@ -365,7 +365,7 @@ static __init int user_namespace_sysctl_init(void)
* default set so that registrations in the child sets work
* properly.
*/
- user_header = register_sysctl("user", empty);
+ user_header = register_sysctl_sz("user", empty, 0);
kmemleak_ignore(user_header);
BUG_ON(!user_header);
BUG_ON(!setup_userns_sysctls(&init_user_ns));
diff --git a/net/sysctl_net.c b/net/sysctl_net.c
index 8ee4b74bc009..d9cbbb51b143 100644
--- a/net/sysctl_net.c
+++ b/net/sysctl_net.c
@@ -101,7 +101,7 @@ __init int net_sysctl_init(void)
* registering "/proc/sys/net" as an empty directory not in a
* network namespace.
*/
- net_header = register_sysctl("net", empty);
+ net_header = register_sysctl_sz("net", empty, 0);
if (!net_header)
goto out;
ret = register_pernet_subsys(&sysctl_pernet_ops);
--
2.30.2
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 06/14] sysctl: Add size to register_sysctl
2023-07-26 14:06 ` [PATCH 06/14] sysctl: Add size to register_sysctl Joel Granados
@ 2023-07-26 17:58 ` Luis Chamberlain
2023-07-27 12:22 ` Joel Granados
0 siblings, 1 reply; 23+ messages in thread
From: Luis Chamberlain @ 2023-07-26 17:58 UTC (permalink / raw)
To: Joel Granados, Greg Kroah-Hartman
Cc: Catalin Marinas, Will Deacon, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Kees Cook, Iurii Zaikin, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, willy, josh,
Christian Borntraeger, Sven Schnelle, linux-arm-kernel,
linux-kernel, linux-s390, linux-fsdevel, netdev
On Wed, Jul 26, 2023 at 04:06:26PM +0200, Joel Granados wrote:
> In order to remove the end element from the ctl_table struct arrays, we
> replace the register_syctl function with a macro that will add the
> ARRAY_SIZE to the new register_sysctl_sz function. In this way the
> callers that are already using an array of ctl_table structs do not have
> to change. We *do* change the callers that pass the ctl_table array as a
> pointer.
Thanks for doing this and this series!
> Signed-off-by: Joel Granados <j.granados@samsung.com>
> ---
> diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
> index 0495c858989f..b1168ae281c9 100644
> --- a/include/linux/sysctl.h
> +++ b/include/linux/sysctl.h
> @@ -215,6 +215,9 @@ struct ctl_path {
> const char *procname;
> };
>
> +#define register_sysctl(path, table) \
> + register_sysctl_sz(path, table, ARRAY_SIZE(table))
> +
> #ifdef CONFIG_SYSCTL
Wasn't it Greg who had suggested this? Maybe add Suggested-by with him
on it.
Also, your cover letter and first few patches are not CC'd to the netdev
list or others. What you want to do is collect all the email addresses
for this small patch series and add them to who you email for your
entire series, otherwise at times they won't be able to properly review
or understand the exact context of the changes. You want folks to do less
work to review, not more.
So please resend and add others to the other patches.
Luis
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 06/14] sysctl: Add size to register_sysctl
2023-07-26 17:58 ` Luis Chamberlain
@ 2023-07-27 12:22 ` Joel Granados
2023-07-27 15:42 ` Luis Chamberlain
0 siblings, 1 reply; 23+ messages in thread
From: Joel Granados @ 2023-07-27 12:22 UTC (permalink / raw)
To: Luis Chamberlain
Cc: Greg Kroah-Hartman, Catalin Marinas, Will Deacon, Heiko Carstens,
Vasily Gorbik, Alexander Gordeev, Kees Cook, Iurii Zaikin,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, willy,
josh, Christian Borntraeger, Sven Schnelle, linux-arm-kernel,
linux-kernel, linux-s390, linux-fsdevel, netdev
[-- Attachment #1: Type: text/plain, Size: 2057 bytes --]
On Wed, Jul 26, 2023 at 10:58:30AM -0700, Luis Chamberlain wrote:
> On Wed, Jul 26, 2023 at 04:06:26PM +0200, Joel Granados wrote:
> > In order to remove the end element from the ctl_table struct arrays, we
> > replace the register_syctl function with a macro that will add the
> > ARRAY_SIZE to the new register_sysctl_sz function. In this way the
> > callers that are already using an array of ctl_table structs do not have
> > to change. We *do* change the callers that pass the ctl_table array as a
> > pointer.
>
> Thanks for doing this and this series!
>
> > Signed-off-by: Joel Granados <j.granados@samsung.com>
> > ---
> > diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
> > index 0495c858989f..b1168ae281c9 100644
> > --- a/include/linux/sysctl.h
> > +++ b/include/linux/sysctl.h
> > @@ -215,6 +215,9 @@ struct ctl_path {
> > const char *procname;
> > };
> >
> > +#define register_sysctl(path, table) \
> > + register_sysctl_sz(path, table, ARRAY_SIZE(table))
> > +
> > #ifdef CONFIG_SYSCTL
>
> Wasn't it Greg who had suggested this? Maybe add Suggested-by with him
> on it.
Yes. I mentioned him in the cover letter and did not add the tag because
I had not asked for permission to use it. I'll drop him a mail and
include the suggested-by if he agrees.
>
> Also, your cover letter and first few patches are not CC'd to the netdev
> list or others. What you want to do is collect all the email addresses
> for this small patch series and add them to who you email for your
> entire series, otherwise at times they won't be able to properly review
> or understand the exact context of the changes. You want folks to do less
> work to review, not more.
Here I wanted to avoid very big e-mail headers as I have received
rejections from lists in the past. But I for this set, the number of
e-mails is ok to just include everyone.
I'll do that for V2.
thx for your feedback
best
>
> So please resend and add others to the other patches.
>
> Luis
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 06/14] sysctl: Add size to register_sysctl
2023-07-27 12:22 ` Joel Granados
@ 2023-07-27 15:42 ` Luis Chamberlain
2023-07-28 7:41 ` Joel Granados
0 siblings, 1 reply; 23+ messages in thread
From: Luis Chamberlain @ 2023-07-27 15:42 UTC (permalink / raw)
To: Joel Granados
Cc: Greg Kroah-Hartman, Catalin Marinas, Will Deacon, Heiko Carstens,
Vasily Gorbik, Alexander Gordeev, Kees Cook, Iurii Zaikin,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, willy,
josh, Christian Borntraeger, Sven Schnelle, linux-arm-kernel,
linux-kernel, linux-s390, linux-fsdevel, netdev
On Thu, Jul 27, 2023 at 02:22:00PM +0200, Joel Granados wrote:
> On Wed, Jul 26, 2023 at 10:58:30AM -0700, Luis Chamberlain wrote:
> > On Wed, Jul 26, 2023 at 04:06:26PM +0200, Joel Granados wrote:
> > > In order to remove the end element from the ctl_table struct arrays, we
> > > replace the register_syctl function with a macro that will add the
> > > ARRAY_SIZE to the new register_sysctl_sz function. In this way the
> > > callers that are already using an array of ctl_table structs do not have
> > > to change. We *do* change the callers that pass the ctl_table array as a
> > > pointer.
> >
> > Thanks for doing this and this series!
> >
> > > Signed-off-by: Joel Granados <j.granados@samsung.com>
> > > ---
> > > diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
> > > index 0495c858989f..b1168ae281c9 100644
> > > --- a/include/linux/sysctl.h
> > > +++ b/include/linux/sysctl.h
> > > @@ -215,6 +215,9 @@ struct ctl_path {
> > > const char *procname;
> > > };
> > >
> > > +#define register_sysctl(path, table) \
> > > + register_sysctl_sz(path, table, ARRAY_SIZE(table))
> > > +
> > > #ifdef CONFIG_SYSCTL
> >
> > Wasn't it Greg who had suggested this? Maybe add Suggested-by with him
> > on it.
> Yes. I mentioned him in the cover letter and did not add the tag because
> I had not asked for permission to use it. I'll drop him a mail and
> include the suggested-by if he agrees.
FWIW, I never ask, if they ask for it, clearly they suggested it.
> > Also, your cover letter and first few patches are not CC'd to the netdev
> > list or others. What you want to do is collect all the email addresses
> > for this small patch series and add them to who you email for your
> > entire series, otherwise at times they won't be able to properly review
> > or understand the exact context of the changes. You want folks to do less
> > work to review, not more.
> Here I wanted to avoid very big e-mail headers as I have received
> rejections from lists in the past. But I for this set, the number of
> e-mails is ok to just include everyone.
I hear that from time to time, if you have issues with adding folks on
the To address it may be an SMTP server issue, ie, corp email SMTP
server issues. To fix that I avoid corp email SMTP servers.
Luis
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 06/14] sysctl: Add size to register_sysctl
2023-07-27 15:42 ` Luis Chamberlain
@ 2023-07-28 7:41 ` Joel Granados
0 siblings, 0 replies; 23+ messages in thread
From: Joel Granados @ 2023-07-28 7:41 UTC (permalink / raw)
To: Luis Chamberlain
Cc: Greg Kroah-Hartman, Catalin Marinas, Will Deacon, Heiko Carstens,
Vasily Gorbik, Alexander Gordeev, Kees Cook, Iurii Zaikin,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, willy,
josh, Christian Borntraeger, Sven Schnelle, linux-arm-kernel,
linux-kernel, linux-s390, linux-fsdevel, netdev
[-- Attachment #1: Type: text/plain, Size: 2886 bytes --]
On Thu, Jul 27, 2023 at 08:42:02AM -0700, Luis Chamberlain wrote:
> On Thu, Jul 27, 2023 at 02:22:00PM +0200, Joel Granados wrote:
> > On Wed, Jul 26, 2023 at 10:58:30AM -0700, Luis Chamberlain wrote:
> > > On Wed, Jul 26, 2023 at 04:06:26PM +0200, Joel Granados wrote:
> > > > In order to remove the end element from the ctl_table struct arrays, we
> > > > replace the register_syctl function with a macro that will add the
> > > > ARRAY_SIZE to the new register_sysctl_sz function. In this way the
> > > > callers that are already using an array of ctl_table structs do not have
> > > > to change. We *do* change the callers that pass the ctl_table array as a
> > > > pointer.
> > >
> > > Thanks for doing this and this series!
> > >
> > > > Signed-off-by: Joel Granados <j.granados@samsung.com>
> > > > ---
> > > > diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
> > > > index 0495c858989f..b1168ae281c9 100644
> > > > --- a/include/linux/sysctl.h
> > > > +++ b/include/linux/sysctl.h
> > > > @@ -215,6 +215,9 @@ struct ctl_path {
> > > > const char *procname;
> > > > };
> > > >
> > > > +#define register_sysctl(path, table) \
> > > > + register_sysctl_sz(path, table, ARRAY_SIZE(table))
> > > > +
> > > > #ifdef CONFIG_SYSCTL
> > >
> > > Wasn't it Greg who had suggested this? Maybe add Suggested-by with him
> > > on it.
> > Yes. I mentioned him in the cover letter and did not add the tag because
> > I had not asked for permission to use it. I'll drop him a mail and
> > include the suggested-by if he agrees.
>
> FWIW, I never ask, if they ask for it, clearly they suggested it.
I was following Documentation/process/submitting-patches.rst:
"... Please note that this tag should not be added without the
reporter's permission... ".
In any case, Greg has already said yes :)
>
> > > Also, your cover letter and first few patches are not CC'd to the netdev
> > > list or others. What you want to do is collect all the email addresses
> > > for this small patch series and add them to who you email for your
> > > entire series, otherwise at times they won't be able to properly review
> > > or understand the exact context of the changes. You want folks to do less
> > > work to review, not more.
> > Here I wanted to avoid very big e-mail headers as I have received
> > rejections from lists in the past. But I for this set, the number of
> > e-mails is ok to just include everyone.
>
> I hear that from time to time, if you have issues with adding folks on
> the To address it may be an SMTP server issue, ie, corp email SMTP
> server issues. To fix that I avoid corp email SMTP servers.
My experience was more from the lists rejecting the e-mail because the
header was too big. With that said, I'll look into SMTP alternatives to
reduce possible errors
>
> Luis
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 07/14] sysctl: Add size arg to __register_sysctl_init
2023-07-26 14:06 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Joel Granados
` (5 preceding siblings ...)
2023-07-26 14:06 ` [PATCH 06/14] sysctl: Add size to register_sysctl Joel Granados
@ 2023-07-26 14:06 ` Joel Granados
2023-07-28 10:56 ` Simon Horman
2023-07-26 14:06 ` [PATCH 14/14] sysctl: Use size as stopping criteria for list macro Joel Granados
2023-07-26 18:15 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Luis Chamberlain
8 siblings, 1 reply; 23+ messages in thread
From: Joel Granados @ 2023-07-26 14:06 UTC (permalink / raw)
To: mcgrof, Kees Cook, Iurii Zaikin
Cc: willy, josh, Joel Granados, linux-kernel, linux-fsdevel
This is part of the effort to remove the sentinel element from the
ctl_table array at register time. We add a size argument to
__register_sysctl_init and modify the register_sysctl_init macro to
calculate the array size with ARRAY_SIZE. The original callers do not
need to be updated as they will go through the new macro.
Signed-off-by: Joel Granados <j.granados@samsung.com>
---
fs/proc/proc_sysctl.c | 11 ++---------
include/linux/sysctl.h | 5 +++--
2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index c04293911e7e..6c0721cd35f3 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -1444,16 +1444,9 @@ EXPORT_SYMBOL(register_sysctl_sz);
* Context: if your base directory does not exist it will be created for you.
*/
void __init __register_sysctl_init(const char *path, struct ctl_table *table,
- const char *table_name)
+ const char *table_name, size_t table_size)
{
- int count = 0;
- struct ctl_table *entry;
- struct ctl_table_header t_hdr, *hdr;
-
- t_hdr.ctl_table = table;
- list_for_each_table_entry(entry, (&t_hdr))
- count++;
- hdr = register_sysctl_sz(path, table, count);
+ struct ctl_table_header *hdr = register_sysctl_sz(path, table, table_size);
if (unlikely(!hdr)) {
pr_err("failed when register_sysctl_sz %s to %s\n", table_name, path);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index b1168ae281c9..09d7429d67c0 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -236,8 +236,9 @@ void unregister_sysctl_table(struct ctl_table_header * table);
extern int sysctl_init_bases(void);
extern void __register_sysctl_init(const char *path, struct ctl_table *table,
- const char *table_name);
-#define register_sysctl_init(path, table) __register_sysctl_init(path, table, #table)
+ const char *table_name, size_t table_size);
+#define register_sysctl_init(path, table) \
+ __register_sysctl_init(path, table, #table, ARRAY_SIZE(table))
extern struct ctl_table_header *register_sysctl_mount_point(const char *path);
void do_sysctl_args(void);
--
2.30.2
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 07/14] sysctl: Add size arg to __register_sysctl_init
2023-07-26 14:06 ` [PATCH 07/14] sysctl: Add size arg to __register_sysctl_init Joel Granados
@ 2023-07-28 10:56 ` Simon Horman
2023-07-28 16:11 ` Joel Granados
0 siblings, 1 reply; 23+ messages in thread
From: Simon Horman @ 2023-07-28 10:56 UTC (permalink / raw)
To: Joel Granados
Cc: mcgrof, Kees Cook, Iurii Zaikin, willy, josh, linux-kernel,
linux-fsdevel
On Wed, Jul 26, 2023 at 04:06:27PM +0200, Joel Granados wrote:
> This is part of the effort to remove the sentinel element from the
> ctl_table array at register time. We add a size argument to
> __register_sysctl_init and modify the register_sysctl_init macro to
> calculate the array size with ARRAY_SIZE. The original callers do not
> need to be updated as they will go through the new macro.
>
> Signed-off-by: Joel Granados <j.granados@samsung.com>
> ---
> fs/proc/proc_sysctl.c | 11 ++---------
> include/linux/sysctl.h | 5 +++--
> 2 files changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index c04293911e7e..6c0721cd35f3 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -1444,16 +1444,9 @@ EXPORT_SYMBOL(register_sysctl_sz);
> * Context: if your base directory does not exist it will be created for you.
> */
> void __init __register_sysctl_init(const char *path, struct ctl_table *table,
> - const char *table_name)
> + const char *table_name, size_t table_size)
Hi Joel,
in the same vein as my comment on another patch.
Please add table_size to the kernel doc for this function.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 07/14] sysctl: Add size arg to __register_sysctl_init
2023-07-28 10:56 ` Simon Horman
@ 2023-07-28 16:11 ` Joel Granados
0 siblings, 0 replies; 23+ messages in thread
From: Joel Granados @ 2023-07-28 16:11 UTC (permalink / raw)
To: Simon Horman
Cc: mcgrof, Kees Cook, Iurii Zaikin, willy, josh, linux-kernel,
linux-fsdevel
[-- Attachment #1: Type: text/plain, Size: 1372 bytes --]
On Fri, Jul 28, 2023 at 12:56:36PM +0200, Simon Horman wrote:
> On Wed, Jul 26, 2023 at 04:06:27PM +0200, Joel Granados wrote:
> > This is part of the effort to remove the sentinel element from the
> > ctl_table array at register time. We add a size argument to
> > __register_sysctl_init and modify the register_sysctl_init macro to
> > calculate the array size with ARRAY_SIZE. The original callers do not
> > need to be updated as they will go through the new macro.
> >
> > Signed-off-by: Joel Granados <j.granados@samsung.com>
> > ---
> > fs/proc/proc_sysctl.c | 11 ++---------
> > include/linux/sysctl.h | 5 +++--
> > 2 files changed, 5 insertions(+), 11 deletions(-)
> >
> > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> > index c04293911e7e..6c0721cd35f3 100644
> > --- a/fs/proc/proc_sysctl.c
> > +++ b/fs/proc/proc_sysctl.c
> > @@ -1444,16 +1444,9 @@ EXPORT_SYMBOL(register_sysctl_sz);
> > * Context: if your base directory does not exist it will be created for you.
> > */
> > void __init __register_sysctl_init(const char *path, struct ctl_table *table,
> > - const char *table_name)
> > + const char *table_name, size_t table_size)
>
> Hi Joel,
>
> in the same vein as my comment on another patch.
> Please add table_size to the kernel doc for this function.
Will do.
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 14/14] sysctl: Use size as stopping criteria for list macro
2023-07-26 14:06 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Joel Granados
` (6 preceding siblings ...)
2023-07-26 14:06 ` [PATCH 07/14] sysctl: Add size arg to __register_sysctl_init Joel Granados
@ 2023-07-26 14:06 ` Joel Granados
2023-07-26 18:15 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Luis Chamberlain
8 siblings, 0 replies; 23+ messages in thread
From: Joel Granados @ 2023-07-26 14:06 UTC (permalink / raw)
To: mcgrof, Kees Cook, Iurii Zaikin
Cc: willy, josh, Joel Granados, linux-kernel, linux-fsdevel
Add header->ctl_table_size as an additional stopping criteria for the
list_for_each_table_entry macro. In this way it will execute until it
finds an "empty" ->procname or until the size runs out. Therefore if a
ctl_table array with a sentinel is passed its size will be too big (by
one element) but it will stop on the sentinel. On the other hand, if the
ctl_table array without a sentinel is passed its size will be just write
and there will be no need for a sentinel.
Signed-off-by: Joel Granados <j.granados@samsung.com>
---
fs/proc/proc_sysctl.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 6c0721cd35f3..3eea34d98d54 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -19,8 +19,9 @@
#include <linux/kmemleak.h>
#include "internal.h"
-#define list_for_each_table_entry(entry, header) \
- for ((entry) = (header->ctl_table); (entry)->procname; (entry)++)
+#define list_for_each_table_entry(entry, header) \
+ entry = header->ctl_table; \
+ for (size_t i = 0 ; i < header->ctl_table_size && entry->procname; ++i, entry++)
static const struct dentry_operations proc_sys_dentry_operations;
static const struct file_operations proc_sys_file_operations;
--
2.30.2
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl
2023-07-26 14:06 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Joel Granados
` (7 preceding siblings ...)
2023-07-26 14:06 ` [PATCH 14/14] sysctl: Use size as stopping criteria for list macro Joel Granados
@ 2023-07-26 18:15 ` Luis Chamberlain
2023-07-27 11:43 ` Joel Granados
8 siblings, 1 reply; 23+ messages in thread
From: Luis Chamberlain @ 2023-07-26 18:15 UTC (permalink / raw)
To: Joel Granados
Cc: Kees Cook, Iurii Zaikin, willy, josh, linux-kernel, linux-fsdevel,
netdev
On Wed, Jul 26, 2023 at 04:06:20PM +0200, Joel Granados wrote:
> What?
> These commits set things up so we can start removing the sentinel elements.
Yes but the why must explained right away.
> Why?
> This is part of the push to trim down kernel/sysctl.c by moving the large array
> that was causing merge conflicts.
Let me elaborate on that:
While the move moving over time of array elements out of kernel/sysctl.c
to their own place helps merge conflicts this patch set does not help
with that in and of itself, what it does is help make sure the move of
sysctls to their own files does not bloat the kernel more, and in fact
helps reduce the overall build time size of the kernel and run time
memory consumed by the kernel by about ~64 bytes per array.
Without this patch set each time we moved a set of sysctls out of
kernel/sysctl.c to its own subsystem we'd have to add a new sentinel
element (an empty sysctl entry), and while that helps clean up
kernel/sysctl.c to avoid merge conflicts, it also bloats the kernel
by about 64 bytes on average each time.
We can do better. We can make those moves *not* have a size penalty, and
all around also reduce the build / run time of the kernel.
*This* is the why, that if we don't do this the cleanup of
kernel/sysctl.c ends up slowly bloating the kernel. Willy had
suggested we instead remove the sentinel so that each move does not
incur a size penalty, but also that in turn reduces the size of the
kernel at build time / run time by a ballpark about ~64 bytes per
array.
Then the following is more details about estimates of overall size
savings, it's not miscellaneous information at all, it's very relevant
information to this patch set.
> Misc:
> A consequence of eventually removing all the sentinels (64 bytes per sentinel)
> is the bytes we save. Here I include numbers for when all sentinels are removed
> to contextualize this chunk
> * bloat-o-meter:
> The "yesall" configuration results save 9158 bytes (you can see the output here
> https://lore.kernel.org/all/20230621091000.424843-1-j.granados@samsung.com/.
> The "tiny" configuration + CONFIG_SYSCTL save 1215 bytes (you can see the
> output here [2])
> * memory usage:
> As we no longer need the sentinel element within proc_sysctl.c, we save some
> bytes in main memory as well. In my testing kernel I measured a difference of
> 6720 bytes. I include the way to measure this in [1]
Luis
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl
2023-07-26 18:15 ` [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl Luis Chamberlain
@ 2023-07-27 11:43 ` Joel Granados
2023-07-27 15:39 ` Luis Chamberlain
0 siblings, 1 reply; 23+ messages in thread
From: Joel Granados @ 2023-07-27 11:43 UTC (permalink / raw)
To: Luis Chamberlain
Cc: Kees Cook, Iurii Zaikin, willy, josh, linux-kernel, linux-fsdevel,
netdev
[-- Attachment #1: Type: text/plain, Size: 3312 bytes --]
On Wed, Jul 26, 2023 at 11:15:40AM -0700, Luis Chamberlain wrote:
> On Wed, Jul 26, 2023 at 04:06:20PM +0200, Joel Granados wrote:
> > What?
> > These commits set things up so we can start removing the sentinel elements.
>
> Yes but the why must explained right away.
My intention of putting the "what" first was to explain the chunking and
clarify right away that what was contained in the "why" was not for this
chunk but for the *whole* patchset.
I have swapped them in my cover letter as I can see that the ambiguity
is gone once you start reading the "what"
>
> > Why?
> > This is part of the push to trim down kernel/sysctl.c by moving the large array
> > that was causing merge conflicts.
>
> Let me elaborate on that:
>
> While the move moving over time of array elements out of kernel/sysctl.c
> to their own place helps merge conflicts this patch set does not help
> with that in and of itself, what it does is help make sure the move of
> sysctls to their own files does not bloat the kernel more, and in fact
> helps reduce the overall build time size of the kernel and run time
> memory consumed by the kernel by about ~64 bytes per array.
>
> Without this patch set each time we moved a set of sysctls out of
> kernel/sysctl.c to its own subsystem we'd have to add a new sentinel
> element (an empty sysctl entry), and while that helps clean up
> kernel/sysctl.c to avoid merge conflicts, it also bloats the kernel
> by about 64 bytes on average each time.
>
> We can do better. We can make those moves *not* have a size penalty, and
> all around also reduce the build / run time of the kernel.
>
> *This* is the why, that if we don't do this the cleanup of
> kernel/sysctl.c ends up slowly bloating the kernel. Willy had
> suggested we instead remove the sentinel so that each move does not
> incur a size penalty, but also that in turn reduces the size of the
> kernel at build time / run time by a ballpark about ~64 bytes per
> array.
Thx for this.
This is a more clear wording for the "Why". Do you mind if I copy/paste
it (with some changes to make it flow) into my next cover letter?
>
> Then the following is more details about estimates of overall size
> savings, it's not miscellaneous information at all, it's very relevant
> information to this patch set.
Did not mean to downplay the importance here. Just did not have a good
title for the section. I'll change it to "Size saving estimates".
>
> > Misc:
> > A consequence of eventually removing all the sentinels (64 bytes per sentinel)
> > is the bytes we save. Here I include numbers for when all sentinels are removed
> > to contextualize this chunk
> > * bloat-o-meter:
> > The "yesall" configuration results save 9158 bytes (you can see the output here
> > https://lore.kernel.org/all/20230621091000.424843-1-j.granados@samsung.com/.
> > The "tiny" configuration + CONFIG_SYSCTL save 1215 bytes (you can see the
> > output here [2])
> > * memory usage:
> > As we no longer need the sentinel element within proc_sysctl.c, we save some
> > bytes in main memory as well. In my testing kernel I measured a difference of
> > 6720 bytes. I include the way to measure this in [1]
>
> Luis
--
best
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl
2023-07-27 11:43 ` Joel Granados
@ 2023-07-27 15:39 ` Luis Chamberlain
2023-07-28 7:04 ` Joel Granados
0 siblings, 1 reply; 23+ messages in thread
From: Luis Chamberlain @ 2023-07-27 15:39 UTC (permalink / raw)
To: Joel Granados
Cc: Kees Cook, Iurii Zaikin, willy, josh, linux-kernel, linux-fsdevel,
netdev
On Thu, Jul 27, 2023 at 01:43:18PM +0200, Joel Granados wrote:
> On Wed, Jul 26, 2023 at 11:15:40AM -0700, Luis Chamberlain wrote:
> > On Wed, Jul 26, 2023 at 04:06:20PM +0200, Joel Granados wrote:
> > > What?
> > > These commits set things up so we can start removing the sentinel elements.
> >
> > Yes but the why must explained right away.
> My intention of putting the "what" first was to explain the chunking and
It may help also just to clarify:
sentinel, the extra empty struct ctl_table at the end of each
sysctl array.
> Thx for this.
> This is a more clear wording for the "Why". Do you mind if I copy/paste
> it (with some changes to make it flow) into my next cover letter?
I don't mind at all.
Luis
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 00/14] sysctl: Add a size argument to register functions in sysctl
2023-07-27 15:39 ` Luis Chamberlain
@ 2023-07-28 7:04 ` Joel Granados
0 siblings, 0 replies; 23+ messages in thread
From: Joel Granados @ 2023-07-28 7:04 UTC (permalink / raw)
To: Luis Chamberlain
Cc: Kees Cook, Iurii Zaikin, willy, josh, linux-kernel, linux-fsdevel,
netdev
[-- Attachment #1: Type: text/plain, Size: 998 bytes --]
On Thu, Jul 27, 2023 at 08:39:59AM -0700, Luis Chamberlain wrote:
> On Thu, Jul 27, 2023 at 01:43:18PM +0200, Joel Granados wrote:
> > On Wed, Jul 26, 2023 at 11:15:40AM -0700, Luis Chamberlain wrote:
> > > On Wed, Jul 26, 2023 at 04:06:20PM +0200, Joel Granados wrote:
> > > > What?
> > > > These commits set things up so we can start removing the sentinel elements.
> > >
> > > Yes but the why must explained right away.
> > My intention of putting the "what" first was to explain the chunking and
>
> It may help also just to clarify:
>
> sentinel, the extra empty struct ctl_table at the end of each
> sysctl array.
This clarification is already there: "... sentinel element (the extra
empty element in the ctl_table arrays ...".
>
> > Thx for this.
> > This is a more clear wording for the "Why". Do you mind if I copy/paste
> > it (with some changes to make it flow) into my next cover letter?
>
> I don't mind at all.
>
> Luis
--
Joel Granados
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread