kernel.h further split
Subsystems (5)
v4 cover kernel.h further split
v3: https://lore.kernel.org/linux-media/[email protected]/T/#u
v2: https://lore.kernel.org/linux-media/[email protected]/T/#u
The kernel.h is a set of something which is not related to each other and often used in non-crossed compilation units, especially when drivers need only one or two macro definitions from it.
Here is the split of container_of(). The goals are the following:
- untwist the dependency hell a bit
- drop kernel.h inclusion where it's only used for container_of()
- speed up C preprocessing.
The build speedup is
1.83% (ccache approach, see v2 cover letter for the details) 0.5% (kcbench approach, see v3 cover letter for the details)
In v4:
- dropped kobject.h change (Greg)
- Cc'ed more people (as per v1)
In v3:
- split patch 2 to more patches (Greg)
- excluded C changes (Herbert, Greg)
- measured with kcbench, see below (Greg)
Andy Shevchenko (7):
kernel.h: Drop unneeded <linux/kernel.h> inclusion from other headers kernel.h: Split out container_of() and typeof_member() macros
kunit: Replace kernel.h with the necessary inclusions list.h: Replace kernel.h with the necessary inclusions
llist: Replace kernel.h with the necessary inclusions
plist: Replace kernel.h with the necessary inclusions
media: entity: Replace kernel.h with the necessary inclusions
include/kunit/test.h | 14 ++++++++++++-- include/linux/container_of.h | 37 ++++++++++++++++++++++++++++++++++++ include/linux/kernel.h | 31 +----------------------------- include/linux/list.h | 6 ++++-- include/linux/llist.h | 4 +++- include/linux/plist.h | 5 ++++- include/linux/rwsem.h | 1 - include/linux/spinlock.h | 1 - include/media/media-entity.h | 3 ++- 9 files changed, 63 insertions(+), 39 deletions(-) create mode 100644 include/linux/container_of.h
Signature · 1 line
2.33.0
PATCH v4 1/7 kernel.h: Drop unneeded <linux/kernel.h> inclusion from other headers
There is no evidence we need kernel.h inclusion in certain headers. Drop unneeded <linux/kernel.h> inclusion from other headers.
--- include/linux/rwsem.h | 1 - include/linux/spinlock.h | 1 - 2 files changed, 2 deletions(-)
include/linux/rwsem.h +0 -1
@@ -11,7 +11,6 @@#include <linux/linkage.h> #include <linux/types.h> -#include <linux/kernel.h> #include <linux/list.h> #include <linux/spinlock.h> #include <linux/atomic.h>
include/linux/spinlock.h +0 -1
@@ -57,7 +57,6 @@#include <linux/compiler.h> #include <linux/irqflags.h> #include <linux/thread_info.h> -#include <linux/kernel.h> #include <linux/stringify.h> #include <linux/bottom_half.h> #include <linux/lockdep.h>
Signature · 1 line
2.33.0
PATCH v4 2/7 kernel.h: Split out container_of() and typeof_member() macros
In reply to Andy Shevchenkokernel.h is being used as a dump for all kinds of stuff for a long time. Here is the attempt cleaning it up by splitting out container_of() and typeof_member() macros.
For time being include new header back to kernel.h to avoid twisted indirected includes for existing users.
Note, there are _a lot_ of headers and modules that include kernel.h solely for one of these macros and this allows to unburden compiler for the twisted inclusion paths and to make new code cleaner in the future.
--- include/linux/container_of.h | 37 ++++++++++++++++++++++++++++++++++++ include/linux/kernel.h | 31 +----------------------------- 2 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 include/linux/container_of.h
include/linux/container_of.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_CONTAINER_OF_H +#define _LINUX_CONTAINER_OF_H + +#define typeof_member (T , m) typeof(((T*)0)->m) + +/** +* container_of - cast a member of a structure out to the containing structure +* @ptr: the pointer to the member. +* @type: the type of the container struct this is embedded in. +* @member: the name of the member within the struct. +* +*/ +#define container_of (ptr, type, member) ({ \ + void *__mptr = (void *)(ptr); \ + BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ + !__same_type(*(ptr), void), \ + "pointer type mismatch in container_of()"); \ + ((type *)(__mptr - offsetof(type, member))); }) + +/** +* container_of_safe - cast a member of a structure out to the containing structure +* @ptr: the pointer to the member. +* @type: the type of the container struct this is embedded in. +* @member: the name of the member within the struct. +* +* If IS_ERR_OR_NULL(ptr), ptr is returned unchanged. +*/ +#define container_of_safe (ptr, type, member) ({ \ + void *__mptr = (void *)(ptr); \ + BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ + !__same_type(*(ptr), void), \ + "pointer type mismatch in container_of()"); \ + IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \ + ((type *)(__mptr - offsetof(type, member))); }) + +#endif /* _LINUX_CONTAINER_OF_H */
include/linux/kernel.h +1 -30
@@ -9,6 +9,7 @@#include <linux/stddef.h> #include <linux/types.h> #include <linux/compiler.h> +#include <linux/container_of.h> #include <linux/bitops.h> #include <linux/kstrtox.h> #include <linux/log2.h>
@@ -482,36 +483,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }#define __CONCAT (a, b) a ## b#define CONCATENATE (a, b) __CONCAT(a, b) -/** -* container_of - cast a member of a structure out to the containing structure -* @ptr: the pointer to the member. -* @type: the type of the container struct this is embedded in. -* @member: the name of the member within the struct. -* -*/ -#define container_of (ptr, type, member) ({ \ - void *__mptr = (void *)(ptr); \ - BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ - !__same_type(*(ptr), void), \ - "pointer type mismatch in container_of()"); \ - ((type *)(__mptr - offsetof(type, member))); }) - -/** -* container_of_safe - cast a member of a structure out to the containing structure -* @ptr: the pointer to the member. -* @type: the type of the container struct this is embedded in. -* @member: the name of the member within the struct. -* -* If IS_ERR_OR_NULL(ptr), ptr is returned unchanged. -*/ -#define container_of_safe (ptr, type, member) ({ \ - void *__mptr = (void *)(ptr); \ - BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ - !__same_type(*(ptr), void), \ - "pointer type mismatch in container_of()"); \ - IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \ - ((type *)(__mptr - offsetof(type, member))); }) -/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ #ifdef CONFIG_FTRACE_MCOUNT_RECORD # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
Signature · 1 line
2.33.0
Re: [PATCH v4 2/7] kernel.h: Split out container_of() and typeof_member() macros
Quoted 2 lines · Andy Shevchenko
+#define
typeof_member(T, m)typeof(((T*)0)->m)
Is the patch missing the removal from the other place?
Cheers,
Miguel
Re: [PATCH v4 2/7] kernel.h: Split out container_of() and typeof_member() macros
Quoted 6 lines · Miguel Ojeda
Quoted 2 lines · Andy Shevchenko
+#define
typeof_member(T, m)typeof(((T*)0)->m)Is the patch missing the removal from the other place?
Possibly, but I leave it for now for builders to place with the series and people having chance to comment.
Thanks for review!
Maybe Andrew can fix this when applying?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 2/7] kernel.h: Split out container_of() and typeof_member() macros
In reply to Andy ShevchenkoQuoted 6 lines · Andy Shevchenko
kernel.his being used as a dump for all kinds of stuff for a long time. Here is the attempt cleaning it up by splitting outcontainer_of()andtypeof_member()macros.For time being include new header back to
kernel.hto avoid twisted indirected includes for existing users.
IMO: this new file is missing 2 #include directives.
include/linux/container_of.h
Quoted 1 line
include/linux/container_of.h +0
-0
[]
include/linux/container_of.h line 1
Quoted 2 lines
include/linux/container_of.h +1
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */
And trivially: I'd prefer GPL-2.0-only
Quoted 7 lines
include/linux/container_of.h +7
-0+#ifndef _LINUX_CONTAINER_OF_H +#define _LINUX_CONTAINER_OF_H + +#define typeof_member (T , m) typeof(((T*)0)->m) + +/** +* container_of - cast a member of a structure out to the containing structure
include/linux/container_of.h line 18
Quoted 10 lines
include/linux/container_of.h +10
-0+* @ptr: the pointer to the member. +* @type: the type of the container struct this is embedded in. +* @member: the name of the member within the struct. +* +*/ +#define container_of (ptr, type, member) ({ \ + void *__mptr = (void *)(ptr); \ + BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ + !__same_type(*(ptr), void), \ + "pointer type mismatch in container_of()"); \
This is not a self-contained header as it requires #include <linux/build_bug.h>
which should be at the top of this file.
Quoted 7 lines
include/linux/container_of.h +7
-0+ ((type *)(__mptr - offsetof(type, member))); }) + +/** +* container_of_safe - cast a member of a structure out to the containing structure +* @ptr: the pointer to the member. +* @type: the type of the container struct this is embedded in. +* @member: the name of the member within the struct.
include/linux/container_of.h line 35
Quoted 10 lines
include/linux/container_of.h +10
-0+* +* If IS_ERR_OR_NULL(ptr), ptr is returned unchanged. +*/ +#define container_of_safe (ptr, type, member) ({ \ + void *__mptr = (void *)(ptr); \ + BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ + !__same_type(*(ptr), void), \ + "pointer type mismatch in container_of()"); \ + IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \ + ((type *)(__mptr - offsetof(type, member))); })
And this requires
#include <linux/err.h>
Quoted 2 lines
include/linux/container_of.h +2
-0+ +#endif /* _LINUX_CONTAINER_OF_H */
Re: [PATCH v4 2/7] kernel.h: Split out container_of() and typeof_member() macros
Quoted 9 lines · Joe Perches
Quoted 6 lines · Andy Shevchenko
kernel.his being used as a dump for all kinds of stuff for a long time. Here is the attempt cleaning it up by splitting outcontainer_of()andtypeof_member()macros.For time being include new header back to
kernel.hto avoid twisted indirected includes for existing users.IMO: this new file is missing 2 #include directives.
Thanks, Joe, I'll address this in v5.
Signature · 2 lines
With Best Regards, Andy Shevchenko
RE: [PATCH v4 2/7] kernel.h: Split out container_of() and typeof_member() macros
In reply to Joe PerchesFrom: Joe Perches
Quoted 1 line
Sent: 07 October 2021 17:28
...
Quoted 1 line
IMO: this new file is missing 2 #include directives.
...
Quoted 3 lines
This is not a self-contained header as it requires #include <
linux/build_bug.h>
which should be at the top of this file.
...
Quoted 3 lines
And this requires
#include <
linux/err.h>
And I bet the biggest problem is the time spent by the compiler searching down the -I path for headers.
If you count system calls during a build I suspect that failed opens of .h files dominate.
To see how much this really costs try running a build with a (traditional) NFS mounted source tree - where every directory name in a filename requires an NFS file handle lookup.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
PATCH v4 3/7 kunit: Replace kernel.h with the necessary inclusions
In reply to Andy ShevchenkoWhen kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.
Replace kernel.h inclusion with the list of what is really being used.
--- include/kunit/test.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
include/kunit/test.h +12 -2
@@ -11,11 +11,21 @@#include <kunit/assert.h> #include <kunit/try-catch.h> -#include <linux/kernel.h> + +#include <linux/compiler_attributes.h> +#include <linux/container_of.h> +#include <linux/err.h> +#include <linux/init.h> +#include <linux/kconfig.h> +#include <linux/kref.h> +#include <linux/list.h> #include <linux/module.h> #include <linux/slab.h> +#include <linux/spinlock.h> +#include <linux/string.h> #include <linux/types.h> -#include <linux/kref.h> + +#include <asm/rwonce.h> struct kunit_resource ;
Signature · 1 line
2.33.0
PATCH v4 4/7 list.h: Replace kernel.h with the necessary inclusions
In reply to Andy ShevchenkoWhen kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.
Replace kernel.h inclusion with the list of what is really being used.
--- include/linux/list.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
include/linux/list.h +4 -2
@@ -2,11 +2,13 @@#ifndef _LINUX_LIST_H#define _LINUX_LIST_H +#include <linux/container_of.h> +#include <linux/const.h> #include <linux/types.h> #include <linux/stddef.h> #include <linux/poison.h> -#include <linux/const.h> -#include <linux/kernel.h> + +#include <asm/barrier.h> /* * Circular doubly linked list implementation.
Signature · 1 line
2.33.0
Re: [PATCH v4 4/7] list.h: Replace kernel.h with the necessary inclusions
Quoted 15 lines · On Thu, 7 Oct 2021 18:44:04 +0300 Andy Shevchenko…
When
kernel.his used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.Replace
kernel.hinclusion with the list of what is really being used.Signed-off-by Andy Shevchenko <[email protected]>--- include/linux/list.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)include/linux/list.h +0
-0
include/linux/list.h line 9
Quoted 8 lines
include/linux/list.h +2
-0@@ -2,11 +2,13 @@#ifndef _LINUX_LIST_H#define _LINUX_LIST_H +#include <linux/container_of.h> +#include <linux/const.h> #include <linux/types.h> #include <linux/stddef.h> #include <linux/poison.h>
Is there a reason you didn't quite sort this into alphabetical order?
Quoted 7 lines
include/linux/list.h +2
-2-#include <linux/const.h> -#include <linux/kernel.h> + +#include <asm/barrier.h> /* * Circular doubly linked list implementation.
Re: [PATCH v4 4/7] list.h: Replace kernel.h with the necessary inclusions
Quoted 2 lines · Jonathan Cameron
On Thu, 7 Oct 2021 18:44:04 +0300
Andy Shevchenko <[email protected]> wrote:
...
Quoted 1 line
Is there a reason you didn't quite sort this into alphabetical order?
Glad you asked! Yes. Greg and possibly others will come and tell me that I mustn't do two things in one change.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 4/7] list.h: Replace kernel.h with the necessary inclusions
Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Jonathan Cameron
On Thu, 7 Oct 2021 18:44:04 +0300
Andy Shevchenko <[email protected]> wrote:...
Quoted 1 line
Is there a reason you didn't quite sort this into alphabetical order?
Glad you asked! Yes. Greg and possibly others will come and tell me that I mustn't do two things in one change.
Actually I have to avoid moving const.h. I will change this in v5.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Laurent Pinchart
maintainerRe: [PATCH v4 4/7] list.h: Replace kernel.h with the necessary inclusions
In reply to Jonathan CameronQuoted 20 lines · Jonathan Cameron
Quoted 18 lines · On Thu, 7 Oct 2021 18:44:04 +0300 Andy Shevchenko wrote:
When
kernel.his used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.Replace
kernel.hinclusion with the list of what is really being used.Signed-off-by Andy Shevchenko <[email protected]>--- include/linux/list.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)include/linux/list.h +0
-0@@ -2,11 +2,13 @@#ifndef _LINUX_LIST_H#define _LINUX_LIST_H
Quoted 7 lines
include/linux/list.h line 9
Quoted 5 lines
include/linux/list.h +2
-0+#include <linux/container_of.h> +#include <linux/const.h> #include <linux/types.h> #include <linux/stddef.h> #include <linux/poison.h> Is there a reason you didn't quite sort this into alphabetical order?
On a side note, if someone with perle knowledge could add a checkpatch warning for this, I think it would be very nice. I'm a bit tired of asking for alphabetical order in reviews :-)
Quoted 7 lines
Quoted 7 lines
include/linux/list.h +2
-2-#include <linux/const.h> -#include <linux/kernel.h> + +#include <asm/barrier.h> /* * Circular doubly linked list implementation.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v4 4/7] list.h: Replace kernel.h with the necessary inclusions
Quoted 6 lines · Laurent Pinchart
Quoted 5 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 7 Oct 2021 18:44:04 +0300 Andy Shevchenko wrote:
When
kernel.his used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.Replace
kernel.hinclusion with the list of what is really being used.
[]
Quoted 1 line
Quoted 1 line
include/linux/list.h
Quoted 1 line
include/linux/list.h +0
-0
[]
Quoted 12 lines
Quoted 11 lines
include/linux/list.h line 9
Quoted 9 lines
include/linux/list.h +2
-0@@ -2,11 +2,13 @@ #ifndef _LINUX_LIST_H #define _LINUX_LIST_H +#include <linux/container_of.h> +#include <linux/const.h> #include <linux/types.h> #include <linux/stddef.h> #include <linux/poison.h>Is there a reason you didn't quite sort this into alphabetical order?
Quoted 3 lines
On a side note, if someone with perle knowledge could add a checkpatch warning for this, I think it would be very nice. I'm a bit tired of asking for alphabetical order in reviews :-)
As are people that want reverse christmas tree.
Neither of which I will do as I think both are poor form at best.
If you want, this was a checkpatch reverse christmas tree attempt, as that was more common to some.
Laurent Pinchart
maintainerRe: [PATCH v4 4/7] list.h: Replace kernel.h with the necessary inclusions
Quoted 22 lines · Joe Perches
Quoted 6 lines · Laurent Pinchart
Quoted 5 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 7 Oct 2021 18:44:04 +0300 Andy Shevchenko wrote:
When
kernel.his used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.Replace
kernel.hinclusion with the list of what is really being used.[]
Quoted 1 line
Quoted 1 line
include/linux/list.h
Quoted 1 line
include/linux/list.h +0
-0[]
Quoted 12 lines
Quoted 11 lines
include/linux/list.h line 9
Quoted 9 lines
include/linux/list.h +2
-0@@ -2,11 +2,13 @@ #ifndef _LINUX_LIST_H #define _LINUX_LIST_H +#include <linux/container_of.h> +#include <linux/const.h> #include <linux/types.h> #include <linux/stddef.h> #include <linux/poison.h>Is there a reason you didn't quite sort this into alphabetical order?
Quoted 6 lines
Quoted 3 lines
On a side note, if someone with perle knowledge could add a checkpatch warning for this, I think it would be very nice. I'm a bit tired of asking for alphabetical order in reviews :-)
As are people that want reverse christmas tree.
Neither of which I will do as I think both are poor form at best.
Reverse xmas tree order is just a matter of style, while alphabetical ordering of headers helps catching duplicate, including when merging branches that both add the same header in different locations. I thus think there's a technical value to it.
Quoted 4 lines
If you want, this was a checkpatch reverse christmas tree attempt, as that was more common to some.
Signature · 3 lines
Regards, Laurent Pinchart
PATCH v4 5/7 llist: Replace kernel.h with the necessary inclusions
In reply to Andy ShevchenkoWhen kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.
Replace kernel.h inclusion with the list of what is really being used.
--- include/linux/llist.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/linux/llist.h +3 -1
@@ -49,7 +49,9 @@*/ #include <linux/atomic.h> -#include <linux/kernel.h> +#include <linux/container_of.h> +#include <linux/stddef.h> +#include <linux/types.h> struct llist_head {struct llist_node *first;
Signature · 1 line
2.33.0
PATCH v4 6/7 plist: Replace kernel.h with the necessary inclusions
In reply to Andy ShevchenkoWhen kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.
Replace kernel.h inclusion with the list of what is really being used.
--- include/linux/plist.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/linux/plist.h +4 -1
@@ -73,8 +73,11 @@ #ifndef _LINUX_PLIST_H_ #define _LINUX_PLIST_H_ -#include <linux/kernel.h> +#include <linux/container_of.h> #include <linux/list.h> +#include <linux/types.h> + +#include <asm/bug.h> struct plist_head { struct list_head node_list;
Signature · 1 line
2.33.0
Re: [PATCH v4 6/7] plist: Replace kernel.h with the necessary inclusions
Quoted 4 lines · Andy Shevchenko
When
kernel.his used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.Replace
kernel.hinclusion with the list of what is really being used.
[]
include/linux/plist.h
Quoted 1 line
include/linux/plist.h +0
-0
[]
include/linux/plist.h
Quoted 1 line
include/linux/plist.h +0
-0@@ -73,8 +73,11 @@
[]
include/linux/plist.h line 80
Quoted 1 line
include/linux/plist.h +1
-0+#include <asm/bug.h>
why asm/bug.h and not linux/bug.h ?
Re: [PATCH v4 6/7] plist: Replace kernel.h with the necessary inclusions
Quoted 5 lines · Joe Perches
Quoted 4 lines · Andy Shevchenko
When
kernel.his used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.Replace
kernel.hinclusion with the list of what is really being used.
Quoted 8 lines
[]
include/linux/plist.h
Quoted 1 line
include/linux/plist.h +0
-0[]
include/linux/plist.h
Quoted 1 line
include/linux/plist.h +0
-0@@ -73,8 +73,11 @@[]
include/linux/plist.h line 80
Quoted 1 line
include/linux/plist.h +1
-0+#include <asm/bug.h> why
asm/bug.hand notlinux/bug.h?
The direct inclusion is from that one. Why linux/bug? What are we going to use from it?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 6/7] plist: Replace kernel.h with the necessary inclusions
Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Joe Perches
Quoted 4 lines · Andy Shevchenko
When
kernel.his used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.Replace
kernel.hinclusion with the list of what is really being used.[]
include/linux/plist.h
Quoted 1 line
include/linux/plist.h +0
-0[]
Quoted 7 lines
Quoted 5 lines
include/linux/plist.h
Quoted 1 line
include/linux/plist.h +0
-0@@ -73,8 +73,11 @@[]
include/linux/plist.h line 80
Quoted 1 line
include/linux/plist.h +1
-0+#include <asm/bug.h> why
asm/bug.hand notlinux/bug.h?The direct inclusion is from that one. Why linux/bug?
A general guideline is to avoid asm includes.
Re: [PATCH v4 6/7] plist: Replace kernel.h with the necessary inclusions
Quoted 12 lines · Joe Perches
Quoted 11 lines · Andy Shevchenko
Quoted 10 lines · Joe Perches
Quoted 4 lines · Andy Shevchenko
When
kernel.his used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.Replace
kernel.hinclusion with the list of what is really being used.[]
include/linux/plist.h
Quoted 1 line
include/linux/plist.h +0
-0[]
include/linux/plist.h
Quoted 1 line
include/linux/plist.h +0
-0@@ -73,8 +73,11 @@[]
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
include/linux/plist.h line 80
Quoted 1 line
include/linux/plist.h +1
-0+#include <asm/bug.h> why
asm/bug.hand notlinux/bug.h?The direct inclusion is from that one. Why linux/bug?
A general guideline is to avoid asm includes.
It's fine when it has any useful background. Doing cargo cult is not always a good idea. I plead for common sense.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 6/7] plist: Replace kernel.h with the necessary inclusions
Quoted 15 lines · Andy Shevchenko
Quoted 14 lines · Joe Perches
Quoted 13 lines · Andy Shevchenko
Quoted 12 lines · Joe Perches
Quoted 4 lines · Andy Shevchenko
When
kernel.his used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.Replace
kernel.hinclusion with the list of what is really being used.[]
include/linux/plist.h
Quoted 1 line
include/linux/plist.h +0
-0[]
include/linux/plist.h
Quoted 1 line
include/linux/plist.h +0
-0@@ -73,8 +73,11 @@[]
Quoted 1 line
include/linux/plist.h +1
-0+#include <asm/bug.h>
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
why
asm/bug.hand notlinux/bug.h?The direct inclusion is from that one. Why linux/bug?
A general guideline is to avoid asm includes.
It's fine when it has any useful background. Doing cargo cult is not always a good idea. I plead for common sense.
Common sense isn't particularly common.
Someone is going to run checkpatch on it and submit a patch one day. Maybe add a comment for the less common.
cheers, Joe
PATCH v4 7/7 media: entity: Replace kernel.h with the necessary inclusions
In reply to Andy ShevchenkoWhen kernel.h is used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.
Replace kernel.h inclusion with the list of what is really being used.
--- include/media/media-entity.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/media/media-entity.h +2 -1
@@ -13,10 +13,11 @@#include <linux/bitmap.h> #include <linux/bug.h> +#include <linux/container_of.h> #include <linux/fwnode.h> -#include <linux/kernel.h> #include <linux/list.h> #include <linux/media.h> +#include <linux/types.h> /* Enums used internally at the media controller to represent graphs */
Signature · 1 line
2.33.0
Re: [PATCH v4 7/7] media: entity: Replace kernel.h with the necessary inclusions
Quoted 6 lines · Andy Shevchenko
When
kernel.his used in the headers it adds a lot into dependency hell, especially when there are circular dependencies are involved.Replace
kernel.hinclusion with the list of what is really being used.Signed-off-by Andy Shevchenko <[email protected]>
Signature · 1 line
Sakari Ailus