sysctl: 3rd set of kernel/sysctl cleanups
Subsystems (10)
Luis Chamberlain
maintainerPATCH v2 2/8 random: move the random sysctl declarations to its own file
In reply to Luis ChamberlainFrom: Xiaoming Ni <[email protected]>
The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain.
To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic.
So move the random sysctls to its own file and use register_sysctl_init().
--- drivers/char/random.c | 14 ++++++++++++-- include/linux/sysctl.h | 1 - kernel/sysctl.c | 5 ----- 3 files changed, 12 insertions(+), 8 deletions(-)
drivers/char/random.c +12 -2
@@ -2077,8 +2077,7 @@ static int proc_do_entropy(struct ctl_table *table, int write, }static int sysctl_poolsize =INPUT_POOL_WORDS *32 ; -extern struct ctl_table random_table[]; -struct ctl_table random_table[] = { +static struct ctl_table random_table[] = { { .procname ="poolsize" , .data = &sysctl_poolsize,
@@ -2140,6 +2139,17 @@ struct ctl_table random_table[] = {#endif { } }; + +/* +* rand_initialize() is called before sysctl_init(), +* so we cannot call register_sysctl_init() in rand_initialize() +*/ +static int __init random_sysctls_init (void ) +{ +register_sysctl_init ("kernel/random" , random_table); +return 0 ; +} +device_initcall (random_sysctls_init);#endif /* CONFIG_SYSCTL */ struct batched_entropy {
include/linux/sysctl.h +0 -1
@@ -216,7 +216,6 @@ extern int unaligned_dump_stack;extern int no_unaligned_warning;extern struct ctl_table sysctl_mount_point[]; -extern struct ctl_table random_table[];#else /* CONFIG_SYSCTL */ static inline struct ctl_table_header *register_sysctl_table (struct ctl_table * table)
kernel/sysctl.c +0 -5
@@ -2143,11 +2143,6 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = sysctl_max_threads, }, - { - .procname = "random", - .mode = 0555, - .child = random_table, - }, { .procname = "usermodehelper", .mode = 0555,
Signature · 1 line
2.33.0
Luis Chamberlain
maintainerPATCH v2 7/8 stackleak: move stack_erasing sysctl to stackleak.c
In reply to Luis ChamberlainFrom: Xiaoming Ni <[email protected]>
The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain.
To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic.
So move the stack_erasing sysctl from kernel/sysctl.c to kernel/stackleak.c and use register_sysctl() to register the sysctl interface.
--- include/linux/stackleak.h | 5 ----- kernel/stackleak.c | 26 ++++++++++++++++++++++++-- kernel/sysctl.c | 14 -------------- 3 files changed, 24 insertions(+), 21 deletions(-)
include/linux/stackleak.h +0 -5
@@ -23,11 +23,6 @@ static inline void stackleak_task_init(struct task_struct *t) # endif } -#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE -int stack_erasing_sysctl (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos); -#endif -#else /* !CONFIG_GCC_PLUGIN_STACKLEAK */ static inline void stackleak_task_init (struct task_struct *t) { }#endif
kernel/stackleak.c +24 -2
@@ -16,11 +16,13 @@ #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE #include <linux/jump_label.h> #include <linux/sysctl.h> +#include <linux/init.h> static DEFINE_STATIC_KEY_FALSE(stack_erasing_bypass); -int stack_erasing_sysctl (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +#ifdef CONFIG_SYSCTL +static int stack_erasing_sysctl(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) { int ret = 0; int state = !static_branch_unlikely(&stack_erasing_bypass);
@@ -42,6 +44,26 @@ int stack_erasing_sysctl(struct ctl_table *table, int write, state ? "enabled" : "disabled"); return ret; } +static struct ctl_table stackleak_sysctls[] = { + { + .procname ="stack_erasing" , + .data =NULL , + .maxlen =sizeof (int ), + .mode =0600 , + .proc_handler = stack_erasing_sysctl, + .extra1 =SYSCTL_ZERO , + .extra2 =SYSCTL_ONE , + }, + {} +}; + +static int __init stackleak_sysctls_init (void ) +{ +register_sysctl_init ("kernel" , stackleak_sysctls); +return 0 ; +} +late_initcall (stackleak_sysctls_init); +#endif /* CONFIG_SYSCTL */ #define skip_erasing () static_branch_unlikely(&stack_erasing_bypass)#else
kernel/sysctl.c +0 -14
@@ -94,9 +94,6 @@#if defined(CONFIG_PROVE_LOCKING ) || defined(CONFIG_LOCK_STAT )#include <linux/lockdep.h> #endif -#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE -#include <linux/stackleak.h> -#endif #if defined(CONFIG_SYSCTL )
@@ -2441,17 +2438,6 @@ static struct ctl_table kern_table[] = { .extra1 = SYSCTL_ONE, .extra2 = SYSCTL_INT_MAX, }, -#endif -#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE - { - .procname = "stack_erasing", - .data = NULL, - .maxlen = sizeof(int), - .mode = 0600, - .proc_handler = stack_erasing_sysctl, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - },#endif { } };
Signature · 1 line
2.33.0
Luis Chamberlain
maintainerPATCH v2 1/8 firmware_loader: move firmware sysctl to its own files
In reply to Luis ChamberlainFrom: Xiaoming Ni <[email protected]>
The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain.
To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic.
So move the firmware configuration sysctl table to the only place where it is used, and make it clear that if sysctls are disabled this is not used.
--- drivers/base/firmware_loader/fallback.c | 7 ++++++- drivers/base/firmware_loader/fallback.h | 11 ++++++++++ drivers/base/firmware_loader/fallback_table.c | 21 +++++++++++++++++-- include/linux/sysctl.h | 1 - kernel/sysctl.c | 7 ------- 5 files changed, 36 insertions(+), 11 deletions(-)
drivers/base/firmware_loader/fallback.c +6 -1
@@ -199,11 +199,16 @@ static struct class firmware_class = {int register_sysfs_loader (void ) { -return class_register (&firmware_class); +int ret =class_register (&firmware_class); + +if (ret !=0 ) +return ret; +return register_firmware_config_sysctl (); }void unregister_sysfs_loader (void ) { +unregister_firmware_config_sysctl ();class_unregister (&firmware_class); }
drivers/base/firmware_loader/fallback.h +11 -0
@@ -42,6 +42,17 @@ void fw_fallback_set_default_timeout(void);int register_sysfs_loader (void );void unregister_sysfs_loader (void ); +#ifdef CONFIG_SYSCTL +extern int register_firmware_config_sysctl (void ); +extern void unregister_firmware_config_sysctl (void ); +#else +static inline int register_firmware_config_sysctl (void ) +{ +return 0 ; +} +static inline void unregister_firmware_config_sysctl (void ) { } +#endif /* CONFIG_SYSCTL */ +#else /* CONFIG_FW_LOADER_USER_HELPER */ static inline int firmware_fallback_sysfs(struct firmware *fw, const char *name, struct device *device,
drivers/base/firmware_loader/fallback_table.c +19 -2
@@ -24,7 +24,7 @@ struct firmware_fallback_config fw_fallback_config = {EXPORT_SYMBOL_NS_GPL (fw_fallback_config,FIRMWARE_LOADER_PRIVATE ); #ifdef CONFIG_SYSCTL -struct ctl_table firmware_config_table[] = { +static struct ctl_table firmware_config_table[] = { { .procname = "force_sysfs_fallback", .data = &fw_fallback_config.force_sysfs_fallback,
@@ -45,4 +45,21 @@ struct ctl_table firmware_config_table[] = { }, { } }; -#endif + +static struct ctl_table_header *firmware_config_sysct_table_header; +int register_firmware_config_sysctl (void ) +{ + firmware_config_sysct_table_header = +register_sysctl ("kernel/firmware_config" , + firmware_config_table); +if (!firmware_config_sysct_table_header) +return -ENOMEM ; +return 0 ; +} + +void unregister_firmware_config_sysctl (void ) +{ +unregister_sysctl_table (firmware_config_sysct_table_header); + firmware_config_sysct_table_header =NULL ; +} +#endif /* CONFIG_SYSCTL */
include/linux/sysctl.h +0 -1
@@ -217,7 +217,6 @@ extern int no_unaligned_warning;extern struct ctl_table sysctl_mount_point[];extern struct ctl_table random_table[]; -extern struct ctl_table firmware_config_table[];#else /* CONFIG_SYSCTL */ static inline struct ctl_table_header *register_sysctl_table (struct ctl_table * table)
kernel/sysctl.c +0 -7
@@ -2153,13 +2153,6 @@ static struct ctl_table kern_table[] = { .mode = 0555, .child = usermodehelper_table, }, -#ifdef CONFIG_FW_LOADER_USER_HELPER - { - .procname = "firmware_config", - .mode = 0555, - .child = firmware_config_table, - }, -#endif { .procname = "overflowuid", .data = &overflowuid,
Signature · 1 line
2.33.0
Luis Chamberlain
maintainerv2 cover sysctl: 3rd set of kernel/sysctl cleanups
This is the third set of patches to help address cleaning the kitchen seink in kernel/sysctl.c and to move sysctls away to where they are actually implemented / used.
Note that Andrew Morton is staging these to get visibility into changes in the various trees which might conflict. He already grabbed the first two sets of patch sets, and so I think these changes are probably best to be eventually considered to be merged through his tree, to avoid conflicts.
On this v2 series since last year's v1 series has these changes:
* extended commit log to clarify that in these cases, while we are not producing less lines of code we justify the move because otherwise the file kernel/sysctl.c gets way out of hand to maintain.
* addressed 0-day complaints
* the firmware loader changes requested by Greg KH were adopted
* added the new sysctl mount point helper as suggested by Eric W. Biederman
Luis Chamberlain (3):
sysctl: add helper to register a sysctl mount point
fs: move binfmt_misc sysctl to its own file
sysctl: share unsigned long const values
Xiaoming Ni (5):
firmware_loader: move firmware sysctl to its own files
random: move the random sysctl declarations to its own file
printk: move printk sysctl to printk/sysctl.c scsi/sg: move sg-big-buff sysctl to scsi/sg.c
stackleak: move stack_erasing sysctl to stackleak.c
drivers/base/firmware_loader/fallback.c | 7 +- drivers/base/firmware_loader/fallback.h | 11 ++ drivers/base/firmware_loader/fallback_table.c | 21 ++- drivers/char/random.c | 14 +- drivers/scsi/sg.c | 35 ++++- fs/binfmt_misc.c | 6 +- fs/proc/proc_sysctl.c | 16 +++ include/linux/stackleak.h | 5 - include/linux/sysctl.h | 15 ++- include/scsi/sg.h | 4 - kernel/printk/Makefile | 5 +- kernel/printk/internal.h | 6 + kernel/printk/printk.c | 1 + kernel/printk/sysctl.c | 85 ++++++++++++ kernel/stackleak.c | 26 +++- kernel/sysctl.c | 122 +----------------- 16 files changed, 239 insertions(+), 140 deletions(-) create mode 100644 kernel/printk/sysctl.c
Signature · 1 line
2.33.0
Luis Chamberlain
maintainerPATCH v2 6/8 scsi/sg: move sg-big-buff sysctl to scsi/sg.c
From: Xiaoming Ni <[email protected]>
The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain.
To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic.
So move the sg-big-buff sysctl from kernel/sysctl.c to drivers/scsi/sg.c and use register_sysctl() to register the sysctl interface.
--- drivers/scsi/sg.c | 35 ++++++++++++++++++++++++++++++++++- include/scsi/sg.h | 4 ---- kernel/sysctl.c | 12 ------------ 3 files changed, 34 insertions(+), 17 deletions(-)
drivers/scsi/sg.c +34 -1
@@ -77,7 +77,7 @@ static int sg_proc_init(void);#define SG_DEFAULT_TIMEOUT mult_frac(SG_DEFAULT_TIMEOUT_USER, HZ, USER_HZ) -int sg_big_buff =SG_DEF_RESERVED_SIZE ; +static int sg_big_buff =SG_DEF_RESERVED_SIZE ;/* N.B. This variable is readable and writeable via /proc/scsi/sg/def_reserved_size . Each time sg_open() is called a buffer of this size (or less if there is not enough memory) will be reserved
@@ -1634,6 +1634,37 @@ MODULE_PARM_DESC(scatter_elem_sz, "scatter gather element "MODULE_PARM_DESC (def_reserved_size,"size of buffer reserved for each fd" );MODULE_PARM_DESC (allow_dio,"allow direct I/O (default: 0 (disallow))" ); +#ifdef CONFIG_SYSCTL +#include <linux/sysctl.h> + +static struct ctl_table sg_sysctls[] = { + { + .procname ="sg-big-buff" , + .data = &sg_big_buff, + .maxlen =sizeof (int ), + .mode =0444 , + .proc_handler = proc_dointvec, + }, + {} +}; + +static struct ctl_table_header *hdr; +static void register_sg_sysctls (void ) +{ +if (!hdr) + hdr =register_sysctl ("kernel" , sg_sysctls); +} + +static void unregister_sg_sysctls (void ) +{ +if (hdr) +unregister_sysctl_table (hdr); +} +#else +#define register_sg_sysctls () do { } while (0) +#define unregister_sg_sysctls () do { } while (0) +#endif /* CONFIG_SYSCTL */ +static int __init init_sg (void ) {
@@ -1666,6 +1697,7 @@ init_sg(void)return 0 ; }class_destroy (sg_sysfs_class); +register_sg_sysctls (); err_out:unregister_chrdev_region (MKDEV (SCSI_GENERIC_MAJOR ,0 ),SG_MAX_DEVS );return rc;
@@ -1674,6 +1706,7 @@ init_sg(void) static void __exitexit_sg (void ) { +unregister_sg_sysctls ();#ifdef CONFIG_SCSI_PROC_FS remove_proc_subtree ("scsi/sg" ,NULL );#endif /* CONFIG_SCSI_PROC_FS */
include/scsi/sg.h +0 -4
@@ -29,10 +29,6 @@* For utility and test programs see: http://sg.danny.cz/sg/sg3_utils.html */ -#ifdef __KERNEL__ -extern int sg_big_buff;/* for sysctl */ -#endif - typedef struct sg_iovec /* same structure as used by readv() Linux system */ { /* call. It defines one scatter-gather element. */
kernel/sysctl.c +0 -12
@@ -94,9 +94,6 @@#if defined(CONFIG_PROVE_LOCKING ) || defined(CONFIG_LOCK_STAT )#include <linux/lockdep.h> #endif -#ifdef CONFIG_CHR_DEV_SG -#include <scsi/sg.h> -#endif #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE #include <linux/stackleak.h> #endif
@@ -2089,15 +2086,6 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_dostring, },#endif -#ifdef CONFIG_CHR_DEV_SG - { - .procname = "sg-big-buff", - .data = &sg_big_buff, - .maxlen = sizeof (int), - .mode = 0444, - .proc_handler = proc_dointvec, - }, -#endif#ifdef CONFIG_BSD_PROCESS_ACCT { .procname = "acct",
Signature · 1 line
2.33.0
Luis Chamberlain
maintainerPATCH v2 5/8 printk: move printk sysctl to printk/sysctl.c
In reply to Luis ChamberlainFrom: Xiaoming Ni <[email protected]>
The kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain.
To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic.
So move printk sysctl from kernel/sysctl.c to kernel/printk/sysctl.c. Use register_sysctl() to register the sysctl interface.
--- kernel/printk/Makefile | 5 ++- kernel/printk/internal.h | 6 +++ kernel/printk/printk.c | 1 + kernel/printk/sysctl.c | 85 ++++++++++++++++++++++++++++++++++++++++ kernel/sysctl.c | 68 -------------------------------- 5 files changed, 96 insertions(+), 69 deletions(-) create mode 100644 kernel/printk/sysctl.c
kernel/printk/Makefile +4 -1
@@ -2,5 +2,8 @@ obj-y = printk.o obj-$(CONFIG_PRINTK) += printk_safe.o obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o -obj-$(CONFIG_PRINTK) += printk_ringbuffer.o obj-$(CONFIG_PRINTK_INDEX) += index.o + +obj-$(CONFIG_PRINTK) += printk_support.o +printk_support-y := printk_ringbuffer.o +printk_support-$(CONFIG_SYSCTL) += sysctl.o
kernel/printk/internal.h +6 -0
@@ -4,6 +4,12 @@*/ #include <linux/percpu.h> +#if defined(CONFIG_PRINTK ) && defined(CONFIG_SYSCTL ) +void __init printk_sysctl_init (void ); +#else +#define printk_sysctl_init () do { } while (0) +#endif +#ifdef CONFIG_PRINTK /* Flags for a single printk record. */
kernel/printk/printk.c +1 -0
@@ -3202,6 +3202,7 @@ static int __init printk_late_init(void) ret =cpuhp_setup_state_nocalls (CPUHP_AP_ONLINE_DYN ,"printk:online" , console_cpu_notify,NULL );WARN_ON (ret <0 ); +printk_sysctl_init ();return 0 ; }late_initcall (printk_late_init);
kernel/printk/sysctl.c new file +85 -0
85 lines not on this page · raw message
kernel/sysctl.c +0 -68
80 lines not on this page · raw message
Signature · 1 line
2.33.0
Luis Chamberlain
maintainerPATCH v2 8/8 sysctl: share unsigned long const values
In reply to Luis ChamberlainProvide a way to share unsigned long values.
This will allow others to not have to re-invent
these values.
--- fs/proc/proc_sysctl.c | 3 +++ include/linux/sysctl.h | 6 ++++++ kernel/sysctl.c | 9 +++------ 3 files changed, 12 insertions(+), 6 deletions(-)
fs/proc/proc_sysctl.c +3 -0
@@ -29,6 +29,9 @@ static const struct inode_operations proc_sys_dir_operations;const int sysctl_vals[] = {-1 ,0 ,1 ,2 ,4 ,100 ,200 ,1000 ,INT_MAX };EXPORT_SYMBOL (sysctl_vals); +const unsigned long sysctl_long_vals[] = {0 ,1 ,LONG_MAX }; +EXPORT_SYMBOL_GPL (sysctl_long_vals); +/* Support for permanently empty directories */ struct ctl_table sysctl_mount_point[] = {
include/linux/sysctl.h +6 -0
@@ -50,6 +50,12 @@ struct ctl_dir;extern const int sysctl_vals[]; +#define SYSCTL_LONG_ZERO ((void *)&sysctl_long_vals[0]) +#define SYSCTL_LONG_ONE ((void *)&sysctl_long_vals[1]) +#define SYSCTL_LONG_MAX ((void *)&sysctl_long_vals[2]) + +extern const unsigned long sysctl_long_vals[]; +typedef int proc_handler (struct ctl_table *ctl,int write,void *buffer,size_t *lenp,loff_t *ppos);
kernel/sysctl.c +3 -6
@@ -99,9 +99,6 @@/* Constants used for minimum and maximum */ -static const unsigned long zero_ul; -static const unsigned long one_ul =1 ; -static const unsigned long long_max =LONG_MAX ;#ifdef CONFIG_PRINTK static const int ten_thousand =10000 ;#endif
@@ -2512,7 +2509,7 @@ static struct ctl_table vm_table[] = { .maxlen = sizeof(dirty_background_bytes), .mode = 0644, .proc_handler = dirty_background_bytes_handler, - .extra1 = (void *)&one_ul, + .extra1 = SYSCTL_LONG_ONE, }, { .procname = "dirty_ratio",
@@ -2930,8 +2927,8 @@ static struct ctl_table fs_table[] = { .maxlen = sizeof(files_stat.max_files), .mode = 0644, .proc_handler = proc_doulongvec_minmax, - .extra1 = (void *)&zero_ul, - .extra2 = (void *)&long_max, + .extra1 = SYSCTL_LONG_ZERO, + .extra2 = SYSCTL_LONG_MAX, }, { .procname = "nr_open",
Signature · 1 line
2.33.0
Luis Chamberlain
maintainerPATCH v2 3/8 sysctl: add helper to register a sysctl mount point
In reply to Luis ChamberlainThe way to create a subdirectory on top of sysctl_mount_point is a bit obscure, and *why* we do that even so more. Provide a helper which makes it clear why we do this.
--- fs/proc/proc_sysctl.c | 13 +++++++++++++ include/linux/sysctl.h | 7 +++++++ 2 files changed, 20 insertions(+)
fs/proc/proc_sysctl.c +13 -0
@@ -35,6 +35,19 @@ struct ctl_table sysctl_mount_point[] = { { } }; +/** +* register_sysctl_mount_point() - registers a sysctl mount point +* @path: path for the mount point +* +* Used to create a permanently empty directory to serve as mount point. +* There are some subtle but important permission checks this allows in the +* case of unprivileged mounts. +*/ +struct ctl_table_header *register_sysctl_mount_point (const char *path) +{ +return register_sysctl (path, sysctl_mount_point); +} +static bool is_empty_dir (struct ctl_table_header *head) {return head->ctl_table[0 ].child == sysctl_mount_point;
include/linux/sysctl.h +7 -0
@@ -208,6 +208,8 @@ extern int sysctl_init(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) +extern struct ctl_table_header *register_sysctl_mount_point (const char *path); +void do_sysctl_args (void );extern int pwrsw_enabled;
@@ -223,6 +225,11 @@ static inline struct ctl_table_header *register_sysctl_table(struct ctl_table *return NULL ; } +static inline struct sysctl_header *register_sysctl_mount_point (const char *path) +{ +return NULL ; +} +static inline struct ctl_table_header *register_sysctl_paths (const struct ctl_path *path,struct ctl_table *table) {
Signature · 1 line
2.33.0
Luis Chamberlain
maintainerPATCH v2 4/8 fs: move binfmt_misc sysctl to its own file
In reply to Luis ChamberlainThe kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain.
To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic.
This moves the binfmt_misc sysctl to its own file to help remove clutter from kernel/sysctl.c.
--- fs/binfmt_misc.c | 6 +++++- kernel/sysctl.c | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-)
fs/binfmt_misc.c +5 -1
@@ -822,7 +822,11 @@ static int __init init_misc_binfmt(void)int err =register_filesystem (&bm_fs_type);if (!err)insert_binfmt (&misc_format); -return err; +if (!register_sysctl_mount_point ("fs/binfmt_misc" )) { +pr_warn ("Failed to create fs/binfmt_misc sysctl mount point" ); +return -ENOMEM ; + } +return 0 ; } static void __exit exit_misc_binfmt(void)
kernel/sysctl.c +0 -7
@@ -3126,13 +3126,6 @@ static struct ctl_table fs_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_TWO, }, -#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) - { - .procname = "binfmt_misc", - .mode = 0555, - .child = sysctl_mount_point, - }, -#endif { .procname = "pipe-max-size", .data = &pipe_max_size,
Signature · 1 line
2.33.0
Petr Mladek
maintainerRe: [PATCH v2 5/8] printk: move printk sysctl to printk/sysctl.c
In reply to Luis ChamberlainQuoted 18 lines · Luis Chamberlain
From: Xiaoming Ni <[email protected]>
The
kernel/sysctl.cis a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain.To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic.
So move printk sysctl from
kernel/sysctl.ctokernel/printk/sysctl.c. Useregister_sysctl()to register the sysctl interface.kernel/printk/Makefile +0
-0
kernel/printk/Makefile line 9
Quoted 9 lines
kernel/printk/Makefile +4
-1@@ -2,5 +2,8 @@ obj-y = printk.o obj-$(CONFIG_PRINTK) += printk_safe.o obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o -obj-$(CONFIG_PRINTK) += printk_ringbuffer.o obj-$(CONFIG_PRINTK_INDEX) += index.o + +obj-$(CONFIG_PRINTK) += printk_support.o +printk_support-y := printk_ringbuffer.o +printk_support-$(CONFIG_SYSCTL) += sysctl.o
I have never seen this trick. It looks like a dirty hack ;-) Anyway, I do not see it described in the documentation. I wonder if it works only by chance.
IMHO, a cleaner solution would be to add the following into init/Kconfig:
config BUILD_PRINTK_SYSCTL
bool default (PRINTK && SYSCTL)
and then use:
obj-$(CONFIG_BUILD_PRINTK_SYSCTL) += sysctl.o
Quoted 8 lines
kernel/printk/sysctl.c new file +2
-0@@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0-only +/*
kernel/printk/sysctl.c line 12
Quoted 10 lines
kernel/printk/sysctl.c new file +10
-0+* sysctl.c: General linux system control interface +*/ + +#include <linux/sysctl.h> +#include <linux/printk.h> +#include <linux/capability.h> +#include <linux/ratelimit.h> +#include "internal.h" + +static const int ten_thousand =10000 ;
The patch should also remove the variable in kernel/sysctl.c.
Otherwise, it looks like a really nice clean up.
Best Regards,
Petr
Luis Chamberlain
maintainerRe: [PATCH v2 5/8] printk: move printk sysctl to printk/sysctl.c
Quoted 14 lines · Petr Mladek
Quoted 13 lines · Luis Chamberlain
From: Xiaoming Ni <[email protected]>
The
kernel/sysctl.cis a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain.To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic.
So move printk sysctl from
kernel/sysctl.ctokernel/printk/sysctl.c. Useregister_sysctl()to register the sysctl interface.
Quoted 16 lines
Quoted 5 lines
kernel/printk/Makefile +0
-0kernel/printk/Makefile line 9
Quoted 9 lines
kernel/printk/Makefile +4
-1@@ -2,5 +2,8 @@ obj-y = printk.o obj-$(CONFIG_PRINTK) += printk_safe.o obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o -obj-$(CONFIG_PRINTK) += printk_ringbuffer.o obj-$(CONFIG_PRINTK_INDEX) += index.o + +obj-$(CONFIG_PRINTK) += printk_support.o +printk_support-y := printk_ringbuffer.o +printk_support-$(CONFIG_SYSCTL) += sysctl.oI have never seen this trick. It looks like a dirty hack ;-)
It has been used in mac80211 for over a decade now :) See net/mac80211/Makefile
Quoted 6 lines
Anyway, I do not see it described in the documentation. I wonder if it works only by chance.
IMHO, a cleaner solution would be to add the following into init/Kconfig:
Quoted 7 lines
config
BUILD_PRINTK_SYSCTLbool default (PRINTK && SYSCTL)and then use:
obj-$(CONFIG_BUILD_PRINTK_SYSCTL) += sysctl.o
I suppose it is a matter of taste, either way works with me, but I think less kconfig logic is better here.
Quoted 21 lines
Quoted 8 lines
kernel/printk/sysctl.c new file +2
-0@@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* kernel/printk/sysctl.c line 12
Quoted 10 lines
kernel/printk/sysctl.c new file +10
-0+* sysctl.c: General linux system control interface +*/ + +#include <linux/sysctl.h> +#include <linux/printk.h> +#include <linux/capability.h> +#include <linux/ratelimit.h> +#include "internal.h" + +static const int ten_thousand =10000 ;The patch should also remove the variable in
kernel/sysctl.c.
Quoted 1 line
Otherwise, it looks like a really nice clean up.
Ah yes that variable is now unused there. Thanks
Luis