uapi: Don't include <linux/sysinfo.h> in <linux/kernel.h>
Subsystems (12)
PATCH 1/1 uapi: Don't include <linux/sysinfo.h> in <linux/kernel.h>
+ update code where needed (include <linux/sysinfo.h> in code which included <linux/kernel.h> only to get struct sysinfo or SI_LOAD_SHIFT).
The reason is to avoid indirect <linux/sysinfo.h> include when using some network headers: <linux/netlink.h> or others [1] -> <linux/kernel.h> -> <linux/sysinfo.h>.
This indirect include causes redefinition of struct sysinfo when included both <sys/sysinfo.h> and some of network headers:
In file included from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/kernel.h:5,
from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/netlink.h:5,
from ../include/tst_netlink.h:14,
from tst_crypto.c:13:
x86_64-buildroot-linux-musl/sysroot/usr/include/linux/sysinfo.h:8:8: error: redefinition of ‘struct sysinfo’
struct sysinfo {
^~~~~~~
In file included from ../include/tst_safe_macros.h:15,
from ../include/tst_test.h:93,
from tst_crypto.c:11:x86_64-buildroot-linux-musl/sysroot/usr/include/sys/sysinfo.h:10:8: note: originally defined here
[1] or <linux/sysctl.h>, <linux/ethtool.h>, <linux/mroute6.h>, <linux/ethtool.h>
---
Hi,
this looks to be long standing problem: python-psutil [2], iproute2 [3], even for glibc in the past [4] and it tried to be solved before [5].
This will require glibc fix after:
+++ sysdeps/unix/sysv/linux/sys/sysinfo.h
@@ -21,7 +21,7 @@
#include <features.h>
/* Get sysinfo structure from kernel header. */
-#include <linux/kernel.h>
+#include <linux/sysinfo.h>
__BEGIN_DECLS
Kind regards,
Petr
[2] https://git.buildroot.net/buildroot/commit/?id=ab930190d7754b7f5fdda115b2069d00f1320861
[3] http://patchwork.ozlabs.org/project/netdev/patch/602128d22db86bd67e11dec8fe40a73832c222c9.1559230347.git.baruch@tkos.co.il/
[4] https://www.mail-archive.com/[email protected]/msg15363.html
[5] https://lore.kernel.org/patchwork/patch/449607/
drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +- fs/eventpoll.c | 2 +- fs/proc/meminfo.c | 2 +- include/linux/mm.h | 1 + include/uapi/linux/kernel.h | 2 -- kernel/debug/kdb/kdb_main.c | 2 +- kernel/sys.c | 2 +- mm/page_alloc.c | 2 +- net/ipv4/inetpeer.c | 2 +- net/rds/ib_recv.c | 2 +- 10 files changed, 9 insertions(+), 10 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +1 -1
@@ -43,7 +43,7 @@* USA. */ -#include <linux/kernel.h> +#include <linux/sysinfo.h> #include <linux/module.h> #include <linux/errno.h> #include <linux/init.h>
fs/eventpoll.c +1 -1
@@ -7,7 +7,7 @@*/ #include <linux/init.h> -#include <linux/kernel.h> +#include <linux/sysinfo.h> #include <linux/sched/signal.h> #include <linux/fs.h> #include <linux/file.h>
fs/proc/meminfo.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/fs.h> #include <linux/init.h> -#include <linux/kernel.h> +#include <linux/sysinfo.h> #include <linux/mm.h> #include <linux/hugetlb.h> #include <linux/mman.h>
include/linux/mm.h +1 -0
@@ -7,6 +7,7 @@#ifdef __KERNEL__#include <linux/mmdebug.h> +#include <linux/sysinfo.h> #include <linux/gfp.h> #include <linux/bug.h> #include <linux/list.h>
include/uapi/linux/kernel.h +0 -2
@@ -2,8 +2,6 @@#ifndef _UAPI_LINUX_KERNEL_H#define _UAPI_LINUX_KERNEL_H -#include <linux/sysinfo.h> -/* * 'kernel.h' contains some often-used function prototypes etc */
kernel/debug/kdb/kdb_main.c +1 -1
@@ -14,7 +14,7 @@#include <linux/ctype.h> #include <linux/types.h> #include <linux/string.h> -#include <linux/kernel.h> +#include <linux/sysinfo.h> #include <linux/kmsg_dump.h> #include <linux/reboot.h> #include <linux/sched.h>
kernel/sys.c +1 -1
@@ -16,7 +16,7 @@#include <linux/kmod.h> #include <linux/perf_event.h> #include <linux/resource.h> -#include <linux/kernel.h> +#include <linux/sysinfo.h> #include <linux/workqueue.h> #include <linux/capability.h> #include <linux/device.h>
mm/page_alloc.c +1 -1
@@ -24,7 +24,7 @@#include <linux/jiffies.h> #include <linux/memblock.h> #include <linux/compiler.h> -#include <linux/kernel.h> +#include <linux/sysinfo.h> #include <linux/kasan.h> #include <linux/module.h> #include <linux/suspend.h>
net/ipv4/inetpeer.c +1 -1
@@ -15,7 +15,7 @@#include <linux/random.h> #include <linux/timer.h> #include <linux/time.h> -#include <linux/kernel.h> +#include <linux/sysinfo.h> #include <linux/mm.h> #include <linux/net.h> #include <linux/workqueue.h>
net/rds/ib_recv.c +1 -1
@@ -30,7 +30,7 @@* SOFTWARE. * */ -#include <linux/kernel.h> +#include <linux/sysinfo.h> #include <linux/slab.h> #include <linux/pci.h> #include <linux/dma-mapping.h>
Signature · 1 line
2.28.0
Quoted 26 lines · Petr Vorel
+ update code where needed (include <
linux/sysinfo.h> in code which included <linux/kernel.h> only to get struct sysinfo orSI_LOAD_SHIFT).The reason is to avoid indirect <
linux/sysinfo.h> include when using some network headers: <linux/netlink.h> or others [1] -> <linux/kernel.h> -> <linux/sysinfo.h>.This indirect include causes redefinition of struct sysinfo when included both <
sys/sysinfo.h> and some of network headers:In file included from
x86_64-buildroot-linux-musl/sysroot/usr/include/linux/kernel.h:5,from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/netlink.h:5, from ../include/tst_netlink.h:14, from tst_crypto.c:13: x86_64-buildroot-linux-musl/sysroot/usr/include/linux/sysinfo.h:8:8: error: redefinition of ‘struct sysinfo’ struct sysinfo { ^~~~~~~ In file included from ../include/tst_safe_macros.h:15, from ../include/tst_test.h:93, from tst_crypto.c:11:
x86_64-buildroot-linux-musl/sysroot/usr/include/sys/sysinfo.h:10:8: note: originally defined here[1] or <
linux/sysctl.h>, <linux/ethtool.h>, <linux/mroute6.h>, <linux/ethtool.h>Suggested-by Rich Felker <[email protected]>Signed-off-by Petr Vorel <[email protected]>
Quoted 7 lines
---
Hi,this looks to be long standing problem: python-psutil [2], iproute2 [3], even for glibc in the past [4] and it tried to be solved before [5].
This will require glibc fix after:
You can't do this; it breaks the existing contract with glibc. New kernel headers can't force a glibc upgrade. You just have to get rid of use of <linux/kernel.h> elsewhere in the uapi headers. It was a mistake that <linux/sysinfo.h> was ever separated out of <linux/kernel.h> since it didn't (and couldn't) fix the contract that <linux/kernel.h> exposes struct sysinfo (and that it's misnamed). But it's no big deal. This can all be fixed without any breakage anywhere just by not using it.
Rich
Hi Rich,
Quoted 30 lines · Petr Vorel
Quoted 28 lines
+ update code where needed (include <
linux/sysinfo.h> in code which included <linux/kernel.h> only to get struct sysinfo orSI_LOAD_SHIFT).The reason is to avoid indirect <
linux/sysinfo.h> include when using some network headers: <linux/netlink.h> or others [1] -> <linux/kernel.h> -> <linux/sysinfo.h>.This indirect include causes redefinition of struct sysinfo when included both <
sys/sysinfo.h> and some of network headers:In file included from
x86_64-buildroot-linux-musl/sysroot/usr/include/linux/kernel.h:5,from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/netlink.h:5, from ../include/tst_netlink.h:14, from tst_crypto.c:13: x86_64-buildroot-linux-musl/sysroot/usr/include/linux/sysinfo.h:8:8: error: redefinition of ‘struct sysinfo’ struct sysinfo { ^~~~~~~ In file included from ../include/tst_safe_macros.h:15, from ../include/tst_test.h:93, from tst_crypto.c:11:
x86_64-buildroot-linux-musl/sysroot/usr/include/sys/sysinfo.h:10:8: note: originally defined here[1] or <
linux/sysctl.h>, <linux/ethtool.h>, <linux/mroute6.h>, <linux/ethtool.h>Suggested-by Rich Felker <[email protected]>Signed-off-by Petr Vorel <[email protected]>---
Hi,
Quoted 7 lines
Quoted 4 lines
this looks to be long standing problem: python-psutil [2], iproute2 [3], even for glibc in the past [4] and it tried to be solved before [5].
This will require glibc fix after:
You can't do this; it breaks the existing contract with glibc. New kernel headers can't force a glibc upgrade.
Right, got that.
Quoted 7 lines
You just have to get rid
of use of <linux/kernel.h> elsewhere in the uapi headers. It was a mistake that <linux/sysinfo.h> was ever separated out of <linux/kernel.h> since it didn't (and couldn't) fix the contract that <linux/kernel.h> exposes struct sysinfo (and that it's misnamed). But it's no big deal. This can all be fixed without any breakage anywhere just by not using it.
Back to your original suggestion to move the alignment macros to a separate header. I was trying to avoid it not sure if introducing new header is acceptable, but we'll see.
Quoted 1 line
Rich
Kind regards,
Petr
Quoted 48 lines · Petr Vorel
Hi Rich,
Quoted 30 lines · Petr Vorel
Quoted 28 lines
+ update code where needed (include <
linux/sysinfo.h> in code which included <linux/kernel.h> only to get struct sysinfo orSI_LOAD_SHIFT).The reason is to avoid indirect <
linux/sysinfo.h> include when using some network headers: <linux/netlink.h> or others [1] -> <linux/kernel.h> -> <linux/sysinfo.h>.This indirect include causes redefinition of struct sysinfo when included both <
sys/sysinfo.h> and some of network headers:In file included from
x86_64-buildroot-linux-musl/sysroot/usr/include/linux/kernel.h:5,from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/netlink.h:5, from ../include/tst_netlink.h:14, from tst_crypto.c:13: x86_64-buildroot-linux-musl/sysroot/usr/include/linux/sysinfo.h:8:8: error: redefinition of ‘struct sysinfo’ struct sysinfo { ^~~~~~~ In file included from ../include/tst_safe_macros.h:15, from ../include/tst_test.h:93, from tst_crypto.c:11:
x86_64-buildroot-linux-musl/sysroot/usr/include/sys/sysinfo.h:10:8: note: originally defined here[1] or <
linux/sysctl.h>, <linux/ethtool.h>, <linux/mroute6.h>, <linux/ethtool.h>Suggested-by Rich Felker <[email protected]>Signed-off-by Petr Vorel <[email protected]>---
Hi,Quoted 7 lines
Quoted 4 lines
this looks to be long standing problem: python-psutil [2], iproute2 [3], even for glibc in the past [4] and it tried to be solved before [5].
This will require glibc fix after:
You can't do this; it breaks the existing contract with glibc. New kernel headers can't force a glibc upgrade.
Right, got that.
Quoted 7 lines
You just have to get rid
of use of <linux/kernel.h> elsewhere in the uapi headers. It was a mistake that <linux/sysinfo.h> was ever separated out of <linux/kernel.h> since it didn't (and couldn't) fix the contract that <linux/kernel.h> exposes struct sysinfo (and that it's misnamed). But it's no big deal. This can all be fixed without any breakage anywhere just by not using it.
Quoted 3 lines
Back to your original suggestion to move the alignment macros to a separate header. I was trying to avoid it not sure if introducing new header is acceptable, but we'll see.
Isn't there already another similar header with that type of macro that they belong in?
Rich
Hi,
Quoted 49 lines · Petr Vorel
Quoted 48 lines
Hi Rich,
Quoted 30 lines · Petr Vorel
Quoted 28 lines
+ update code where needed (include <
linux/sysinfo.h> in code which included <linux/kernel.h> only to get struct sysinfo orSI_LOAD_SHIFT).The reason is to avoid indirect <
linux/sysinfo.h> include when using some network headers: <linux/netlink.h> or others [1] -> <linux/kernel.h> -> <linux/sysinfo.h>.This indirect include causes redefinition of struct sysinfo when included both <
sys/sysinfo.h> and some of network headers:In file included from
x86_64-buildroot-linux-musl/sysroot/usr/include/linux/kernel.h:5,from x86_64-buildroot-linux-musl/sysroot/usr/include/linux/netlink.h:5, from ../include/tst_netlink.h:14, from tst_crypto.c:13: x86_64-buildroot-linux-musl/sysroot/usr/include/linux/sysinfo.h:8:8: error: redefinition of ‘struct sysinfo’ struct sysinfo { ^~~~~~~ In file included from ../include/tst_safe_macros.h:15, from ../include/tst_test.h:93, from tst_crypto.c:11:
x86_64-buildroot-linux-musl/sysroot/usr/include/sys/sysinfo.h:10:8: note: originally defined here[1] or <
linux/sysctl.h>, <linux/ethtool.h>, <linux/mroute6.h>, <linux/ethtool.h>Suggested-by Rich Felker <[email protected]>Signed-off-by Petr Vorel <[email protected]>---
Hi,Quoted 7 lines
Quoted 4 lines
this looks to be long standing problem: python-psutil [2], iproute2 [3], even for glibc in the past [4] and it tried to be solved before [5].
This will require glibc fix after:
You can't do this; it breaks the existing contract with glibc. New kernel headers can't force a glibc upgrade.
Right, got that.
Quoted 7 lines
You just have to get rid
of use of <linux/kernel.h> elsewhere in the uapi headers. It was a mistake that <linux/sysinfo.h> was ever separated out of <linux/kernel.h> since it didn't (and couldn't) fix the contract that <linux/kernel.h> exposes struct sysinfo (and that it's misnamed). But it's no big deal. This can all be fixed without any breakage anywhere just by not using it.
Quoted 6 lines
Quoted 3 lines
Back to your original suggestion to move the alignment macros to a separate header. I was trying to avoid it not sure if introducing new header is acceptable, but we'll see.
Isn't there already another similar header with that type of macro that they belong in?
The only one I've found is const.h. Not sure it'd be better to move things there.
Kind regards,
Petr
Quoted 1 line
Rich