Skip to contentSkip to conversation

Bring includes in linux/kmod.h up to date

PATCH In review Petr Pavlu 3 participants 9 messages Sep 11 – Sep 22

Subsystems (28)
Networking Network drivers x86 VFS +24 more subsystems
lore
Share & tools
lore

Petr Pavlu

author maintainer
#0 lore raw

v3 cover Bring includes in linux/kmod.h up to date

The usermode helper declarations were previously provided by linux/kmod.h but commit c1f3fa2a4fde ("kmod: split off umh headers into its own file") moved them to linux/umh.h in 2017. Add explicit includes of linux/umh.h to files that use usermode helpers and remove linux/kmod.h where it is no longer needed.

Also add a missing include of linux/sysctl.h to kernel/time/jiffies.c.

Finally, clean up linux/kmod.h so that it includes only the headers that it actually requires, importantly removing the compat linux/umh.h include.

This cleanup is motivated by trying to reduce the preprocessed size of linux/module.h, which includes linux/kmod.h. linux/module.h appears in roughly 15k #include directives across the kernel. This makes it a "hot" header, so it should avoid pulling in unnecessary definitions. Note that this series doesn't immediately improve the situation, since most of the files included by linux/kmod.h are, for now, also included by linux/module.h through other paths.

Apologies for the wide distribution. Acked-bys are appreciated.

---
Changes in v3:
- Rebase on top of v7.3-rc2.
- Clean up commit descriptions.
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Remove the linux/kmod.h include from kernel/cgroup/cgroup-v1.c.
- Add a missing include of linux/sysctl.h to kernel/time/jiffies.c.
- Link to v1: https://patch.msgid.link/[email protected]

---
Petr Pavlu (3):
umh, treewide: Explicitly include linux/umh.h where needed time/jiffies: Include linux/sysctl.h for proc_int_u2k_conv_uop(), ...
module: Bring includes in linux/kmod.h up to date

 arch/x86/kernel/cpu/mce/dev-mcelog.c |  2 +-
 drivers/block/drbd/drbd_nl.c         |  1 +
 drivers/greybus/svc_watchdog.c       |  1 +
 drivers/macintosh/windfarm_core.c    |  1 +
 drivers/pnp/pnpbios/core.c           |  2 +-
 drivers/video/fbdev/uvesafb.c        |  1 +
 fs/coredump.c                        |  2 +-
 fs/nfs/cache_lib.c                   |  2 +-
 fs/nfsd/nfs4layouts.c                |  2 +-
 fs/nfsd/nfs4recover.c                |  1 +
 fs/ocfs2/stackglue.c                 |  1 +
 include/linux/kmod.h                 | 12 ++----------
 kernel/cgroup/cgroup-v1.c            |  2 +-
 kernel/module/kmod.c                 |  1 +
 kernel/power/process.c               |  2 +-
 kernel/reboot.c                      |  2 +-
 kernel/time/jiffies.c                |  1 +
 kernel/umh.c                         |  2 +-
 lib/kobject_uevent.c                 |  2 +-
 net/bridge/br_stp_if.c               |  2 +-
 security/keys/request_key.c          |  2 +-
 security/tomoyo/common.h             |  2 +-
 22 files changed, 23 insertions(+), 23 deletions(-)

---
base-commit: df2908090cda368b01ff43709f51890076c56157
change-id: 20260816-module-include-kmod-14d1a0e19462

author maintainer
#1 lore raw

PATCH v3 1/3 umh, treewide: Explicitly include linux/umh.h where needed

The usermode helper declarations were previously provided by linux/kmod.h but commit c1f3fa2a4fde ("kmod: split off umh headers into its own file") moved them to linux/umh.h in 2017.

Add explicit includes of linux/umh.h to files that use usermode helpers and remove linux/kmod.h where it is no longer needed.

---
 arch/x86/kernel/cpu/mce/dev-mcelog.c | 2 +-
 drivers/block/drbd/drbd_nl.c         | 1 +
 drivers/greybus/svc_watchdog.c       | 1 +
 drivers/macintosh/windfarm_core.c    | 1 +
 drivers/pnp/pnpbios/core.c           | 2 +-
 drivers/video/fbdev/uvesafb.c        | 1 +
 fs/coredump.c                        | 2 +-
 fs/nfs/cache_lib.c                   | 2 +-
 fs/nfsd/nfs4layouts.c                | 2 +-
 fs/nfsd/nfs4recover.c                | 1 +
 fs/ocfs2/stackglue.c                 | 1 +
 kernel/cgroup/cgroup-v1.c            | 2 +-
 kernel/module/kmod.c                 | 1 +
 kernel/power/process.c               | 2 +-
 kernel/reboot.c                      | 2 +-
 kernel/umh.c                         | 2 +-
 lib/kobject_uevent.c                 | 2 +-
 net/bridge/br_stp_if.c               | 2 +-
 security/keys/request_key.c          | 2 +-
 security/tomoyo/common.h             | 2 +-
 20 files changed, 20 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/mce/dev-mcelog.c +1 -1
index 053555206d81..af4e76babe7a 100644
@@ -11,7 +11,7 @@
 
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/poll.h>
 
 #include "internal.h"
drivers/block/drbd/drbd_nl.c +1 -0
index b77f901fc3ef..6f5d059394b3 100644
@@ -14,6 +14,7 @@
 #define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
 
 #include <linux/module.h>
+#include <linux/umh.h>
 #include <linux/drbd.h>
 #include <linux/in.h>
 #include <linux/fs.h>
drivers/greybus/svc_watchdog.c +1 -0
index 16e6de5e9eff..b318eb34bcca 100644
@@ -7,6 +7,7 @@
 
 #include <linux/delay.h>
 #include <linux/suspend.h>
+#include <linux/umh.h>
 #include <linux/workqueue.h>
 #include <linux/greybus.h>
 
drivers/macintosh/windfarm_core.c +1 -0
index 5307b1e34261..e66de11c69a3 100644
@@ -34,6 +34,7 @@
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
 #include <linux/freezer.h>
+#include <linux/umh.h>
 
 #include "windfarm.h"
 
drivers/pnp/pnpbios/core.c +1 -1
index f7e86ae9f72f..46af1f549337 100644
@@ -47,7 +47,7 @@
 #include <linux/delay.h>
 #include <linux/acpi.h>
 #include <linux/freezer.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/kthread.h>
 
 #include <asm/page.h>
drivers/video/fbdev/uvesafb.c +1 -0
index ccc9dbc25813..a13dff332aef 100644
@@ -23,6 +23,7 @@
 #include <linux/io.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
+#include <linux/umh.h>
 #include <video/edid.h>
 #include <video/uvesafb.h>
 #ifdef CONFIG_X86
fs/coredump.c +1 -1
index 6114839f5178..bdef7ec27b0e 100644
@@ -32,7 +32,7 @@
 #include <linux/tsacct_kern.h>
 #include <linux/cn_proc.h>
 #include <linux/audit.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/fsnotify.h>
 #include <linux/fs_struct.h>
 #include <linux/pipe_fs_i.h>
fs/nfs/cache_lib.c +1 -1
index 9738a1ae92ca..ca4e81d4e315 100644
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 2009 Trond Myklebust <[email protected]>
  */
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/mount.h>
fs/nfsd/nfs4layouts.c +1 -1
index 22bcb6d09f70..5739d4d2ed3c 100644
@@ -3,7 +3,7 @@
  * Copyright (c) 2014 Christoph Hellwig.
  */
 #include <linux/exportfs_block.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/file.h>
 #include <linux/jhash.h>
 #include <linux/sched.h>
fs/nfsd/nfs4recover.c +1 -0
index d513971fb119..5bef3f0034d3 100644
@@ -41,6 +41,7 @@
 #include <linux/fs.h>
 #include <linux/hex.h>
 #include <linux/module.h>
+#include <linux/umh.h>
 #include <net/net_namespace.h>
 #include <linux/sunrpc/rpc_pipe_fs.h>
 #include <linux/sunrpc/clnt.h>
fs/ocfs2/stackglue.c +1 -0
index 741d6191d871..0ccaab29426d 100644
@@ -18,6 +18,7 @@
 #include <linux/kobject.h>
 #include <linux/sysfs.h>
 #include <linux/sysctl.h>
+#include <linux/umh.h>
 
 #include "ocfs2_fs.h"
 
kernel/cgroup/cgroup-v1.c +1 -1
index a4337c9b5287..cbcde5c28b18 100644
@@ -2,7 +2,7 @@
 #include "cgroup-internal.h"
 
 #include <linux/ctype.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/sort.h>
 #include <linux/delay.h>
 #include <linux/mm.h>
kernel/module/kmod.c +1 -0
index a25dccdf7aa7..dcaad5d65275 100644
@@ -28,6 +28,7 @@
 #include <linux/ptrace.h>
 #include <linux/async.h>
 #include <linux/uaccess.h>
+#include <linux/umh.h>
 
 #include <trace/events/module.h>
 #include "internal.h"
kernel/power/process.c +1 -1
index dc0dfc349f22..295904ec9a82 100644
@@ -16,7 +16,7 @@
 #include <linux/freezer.h>
 #include <linux/delay.h>
 #include <linux/workqueue.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <trace/events/power.h>
 #include <linux/cpuset.h>
 
kernel/reboot.c +1 -1
index f070c5c1103a..37818be501c0 100644
@@ -11,13 +11,13 @@
 #include <linux/ctype.h>
 #include <linux/export.h>
 #include <linux/kexec.h>
-#include <linux/kmod.h>
 #include <linux/kmsg_dump.h>
 #include <linux/reboot.h>
 #include <linux/suspend.h>
 #include <linux/syscalls.h>
 #include <linux/syscore_ops.h>
 #include <linux/uaccess.h>
+#include <linux/umh.h>
 
 /*
  * this indicates whether you can reboot with ctrl-alt-del: the default is yes
kernel/umh.c +1 -1
index 6e2c7bb315c6..512dc018a50b 100644
@@ -8,7 +8,7 @@
 #include <linux/binfmts.h>
 #include <linux/syscalls.h>
 #include <linux/unistd.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/slab.h>
 #include <linux/completion.h>
 #include <linux/cred.h>
lib/kobject_uevent.c +1 -1
index ddbc4d7482d2..a67129e452a3 100644
@@ -17,7 +17,7 @@
 #include <linux/string.h>
 #include <linux/kobject.h>
 #include <linux/export.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/slab.h>
 #include <linux/socket.h>
 #include <linux/skbuff.h>
net/bridge/br_stp_if.c +1 -1
index a7e5422eb5d1..89bc161a4b47 100644
@@ -8,7 +8,7 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/etherdevice.h>
 #include <linux/rtnetlink.h>
 #include <net/switchdev.h>
security/keys/request_key.c +1 -1
index fa2bb9f2f538..e6ba2d054399 100644
@@ -9,7 +9,7 @@
 
 #include <linux/export.h>
 #include <linux/sched.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/err.h>
 #include <linux/keyctl.h>
 #include <linux/slab.h>
security/tomoyo/common.h +1 -1
index d098cf8aae61..d26034000913 100644
@@ -16,7 +16,7 @@
 #include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/file.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/namei.h>
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH v3 1/3] umh, treewide: Explicitly include linux/umh.h where needed

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines

The usermode helper declarations were previously provided by linux/kmod.h but commit c1f3fa2a4fde ("kmod: split off umh headers into its own file") moved them to linux/umh.h in 2017.

Add explicit includes of linux/umh.h to files that use usermode helpers and remove linux/kmod.h where it is no longer needed.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Acked-by on v3 1/3
#3 lore raw

Re: [PATCH v3 1/3] umh, treewide: Explicitly include linux/umh.h where needed

In reply to Petr Pavlu
Quoted 4 lines · Petr Pavlu

The usermode helper declarations were previously provided by linux/kmod.h but commit c1f3fa2a4fde ("kmod: split off umh headers into its own file") moved them to linux/umh.h in 2017.

Quoted 8 lines

Add explicit includes of linux/umh.h to files that use usermode helpers and remove linux/kmod.h where it is no longer needed.

---
  arch/x86/kernel/cpu/mce/dev-mcelog.c | 2 +-
  drivers/block/drbd/drbd_nl.c         | 1 +
  drivers/greybus/svc_watchdog.c       | 1 +

For Greybus:

Quoted 49 lines
  drivers/macintosh/windfarm_core.c    | 1 +
  drivers/pnp/pnpbios/core.c           | 2 +-
  drivers/video/fbdev/uvesafb.c        | 1 +
  fs/coredump.c                        | 2 +-
  fs/nfs/cache_lib.c                   | 2 +-
  fs/nfsd/nfs4layouts.c                | 2 +-
  fs/nfsd/nfs4recover.c                | 1 +
  fs/ocfs2/stackglue.c                 | 1 +
  kernel/cgroup/cgroup-v1.c            | 2 +-
  kernel/module/kmod.c                 | 1 +
  kernel/power/process.c               | 2 +-
  kernel/reboot.c                      | 2 +-
  kernel/umh.c                         | 2 +-
  lib/kobject_uevent.c                 | 2 +-
  net/bridge/br_stp_if.c               | 2 +-
  security/keys/request_key.c          | 2 +-
  security/tomoyo/common.h             | 2 +-
  20 files changed, 20 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/mce/dev-mcelog.c +1 -1
index 053555206d81..af4e76babe7a 100644
@@ -11,7 +11,7 @@
 
  #include <linux/miscdevice.h>
  #include <linux/slab.h>
-#include <linux/kmod.h>
+#include <linux/umh.h>
  #include <linux/poll.h>
 
  #include "internal.h"
drivers/block/drbd/drbd_nl.c +1 -0
index b77f901fc3ef..6f5d059394b3 100644
@@ -14,6 +14,7 @@
  #define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
 
  #include <linux/module.h>
+#include <linux/umh.h>
  #include <linux/drbd.h>
  #include <linux/in.h>
  #include <linux/fs.h>
drivers/greybus/svc_watchdog.c +0 -0
index 16e6de5e9eff..b318eb34bcca 100644

drivers/greybus/svc_watchdog.c line 13

Quoted 7 lines
drivers/greybus/svc_watchdog.c +1 -0
@@ -7,6 +7,7 @@
 
  #include <linux/delay.h>
  #include <linux/suspend.h>
+#include <linux/umh.h>
  #include <linux/workqueue.h>
  #include <linux/greybus.h>
 

. . .

author maintainer
#4 lore raw

PATCH v3 2/3 time/jiffies: Include linux/sysctl.h for proc_int_u2k_conv_uop(), ...

In reply to Petr Pavlu

jiffies.c uses proc_int_u2k_conv_uop(), proc_int_k2u_conv_kop(), proc_int_conv(), proc_dointvec_conv() and proc_doulongvec_minmax_conv(), which are declared in linux/sysctl.h. It currently gets that header indirectly through linux/module.h -> linux/kmod.h, but the latter no longer needs to include linux/sysctl.h.

Include linux/sysctl.h directly in jiffies.c ahead of removing the unnecessary include from linux/kmod.h.

---
 kernel/time/jiffies.c | 1 +
 1 file changed, 1 insertion(+)
kernel/time/jiffies.c +1 -0
index 213ae1d6a014..9231fea557ce 100644
@@ -8,6 +8,7 @@
 #include <linux/jiffies.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/sysctl.h>
 
 #include "timekeeping.h"
 #include "tick-internal.h"
Signature · 1 line
2.55.0
#5 lore raw

Re: [PATCH v3 2/3] time/jiffies: Include linux/sysctl.h for proc_int_u2k_conv_uop(), ...

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines

jiffies.c uses proc_int_u2k_conv_uop(), proc_int_k2u_conv_kop(), proc_int_conv(), proc_dointvec_conv() and proc_doulongvec_minmax_conv(), which are declared in linux/sysctl.h. It currently gets that header indirectly through linux/module.h -> linux/kmod.h, but the latter no longer needs to include linux/sysctl.h.

Include linux/sysctl.h directly in jiffies.c ahead of removing the unnecessary include from linux/kmod.h.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author maintainer
#6 lore raw

PATCH v3 3/3 module: Bring includes in linux/kmod.h up to date

In reply to Petr Pavlu

Including linux/kmod.h alone results in 1.5 MB of preprocessed output, even though it provides only a few functions and macros.

The header currently depends on:

* __printf() -> linux/compiler_attributes.h,
* ENOSYS -> linux/errno.h,
* bool -> linux/types.h.

Include only these files, reducing the preprocessed output to 10 kB.

---
 include/linux/kmod.h | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
include/linux/kmod.h +2 -10
index 9a07c3215389..b9474a62a568 100644
@@ -2,17 +2,9 @@
 #ifndef __LINUX_KMOD_H__
 #define __LINUX_KMOD_H__
 
-/*
- *	include/linux/kmod.h
- */
-
-#include <linux/umh.h>
-#include <linux/gfp.h>
-#include <linux/stddef.h>
+#include <linux/compiler_attributes.h>
 #include <linux/errno.h>
-#include <linux/compiler.h>
-#include <linux/workqueue.h>
-#include <linux/sysctl.h>
+#include <linux/types.h>
 
 #ifdef CONFIG_MODULES
 /* modprobe exit status on success, -ve on error.  Return value
Signature · 1 line
2.55.0
#7 lore raw

Re: [PATCH v3 3/3] module: Bring includes in linux/kmod.h up to date

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

Including linux/kmod.h alone results in 1.5 MB of preprocessed output, even though it provides only a few functions and macros.

The header currently depends on:

Quoted 7 lines

* __printf() -> linux/compiler_attributes.h,
* ENOSYS -> linux/errno.h,
* bool -> linux/types.h.

Include only these files, reducing the preprocessed output to 10 kB.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
author maintainer
#8 lore raw
In reply to Petr Pavlu
Quoted 19 lines · Petr Pavlu

The usermode helper declarations were previously provided by linux/kmod.h but commit c1f3fa2a4fde ("kmod: split off umh headers into its own file") moved them to linux/umh.h in 2017. Add explicit includes of linux/umh.h to files that use usermode helpers and remove linux/kmod.h where it is no longer needed.

Also add a missing include of linux/sysctl.h to kernel/time/jiffies.c.

Finally, clean up linux/kmod.h so that it includes only the headers that it actually requires, importantly removing the compat linux/umh.h include.

This cleanup is motivated by trying to reduce the preprocessed size of linux/module.h, which includes linux/kmod.h. linux/module.h appears in roughly 15k #include directives across the kernel. This makes it a "hot" header, so it should avoid pulling in unnecessary definitions. Note that this series doesn't immediately improve the situation, since most of the files included by linux/kmod.h are, for now, also included by linux/module.h through other paths.

Quoted 1 line

Apologies for the wide distribution. Acked-bys are appreciated.

I've queued the series on modules-next for 7.4-rc1.

Signature · 2 lines
Thanks,
Petr