Message ID | 20231216033552.3553579-3-kent.overstreet@linux.dev (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | big header dependency cleanup targeting sched.h | expand |
On Fri, Dec 15, 2023 at 10:35:47PM -0500, Kent Overstreet wrote: > - INIT_HLIST_NODE(¬ifier->link); > + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ > + notifier->link.next = NULL; > + notifier->link.pprev = NULL; Arguably INIT_HLIST_NODE() belongs in types.h -- we already have RCUREF_INIT() and ATOMIC_INIT() in there.
On 12/15/23 22:13, Matthew Wilcox wrote: > On Fri, Dec 15, 2023 at 10:35:47PM -0500, Kent Overstreet wrote: >> - INIT_HLIST_NODE(¬ifier->link); >> + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ >> + notifier->link.next = NULL; >> + notifier->link.pprev = NULL; > > Arguably INIT_HLIST_NODE() belongs in types.h -- we already have > RCUREF_INIT() and ATOMIC_INIT() in there. > That would be far better than open-coding it.
On Sat, Dec 16, 2023 at 06:13:41AM +0000, Matthew Wilcox wrote: > On Fri, Dec 15, 2023 at 10:35:47PM -0500, Kent Overstreet wrote: > > - INIT_HLIST_NODE(¬ifier->link); > > + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ > > + notifier->link.next = NULL; > > + notifier->link.pprev = NULL; > > Arguably INIT_HLIST_NODE() belongs in types.h -- we already have > RCUREF_INIT() and ATOMIC_INIT() in there. I think I'd prefer to keep types.h as minimal as possible - as soon as we start putting non type stuff in there people won't know what the distinction is and it'll grow. preempt.h is a bit unusual too, normally we'd just split out a _types.h header there but it's not so easy to split up usefully.
On 12/16/23 14:35, Kent Overstreet wrote: > On Sat, Dec 16, 2023 at 06:13:41AM +0000, Matthew Wilcox wrote: >> On Fri, Dec 15, 2023 at 10:35:47PM -0500, Kent Overstreet wrote: >>> - INIT_HLIST_NODE(¬ifier->link); >>> + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ >>> + notifier->link.next = NULL; >>> + notifier->link.pprev = NULL; >> >> Arguably INIT_HLIST_NODE() belongs in types.h -- we already have >> RCUREF_INIT() and ATOMIC_INIT() in there. > > I think I'd prefer to keep types.h as minimal as possible - as soon as > we start putting non type stuff in there people won't know what the > distinction is and it'll grow. > > preempt.h is a bit unusual too, normally we'd just split out a _types.h > header there but it's not so easy to split up usefully. > I don't feel like I have NAK power, but if I did, I would NAK open coding of INIT_HLIST_HEAD() or anything like it. I would expect some $maintainer to do likewise, but I could be surprised.
On Sat, Dec 16, 2023 at 04:04:43PM -0800, Randy Dunlap wrote: > > > On 12/16/23 14:35, Kent Overstreet wrote: > > On Sat, Dec 16, 2023 at 06:13:41AM +0000, Matthew Wilcox wrote: > >> On Fri, Dec 15, 2023 at 10:35:47PM -0500, Kent Overstreet wrote: > >>> - INIT_HLIST_NODE(¬ifier->link); > >>> + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ > >>> + notifier->link.next = NULL; > >>> + notifier->link.pprev = NULL; > >> > >> Arguably INIT_HLIST_NODE() belongs in types.h -- we already have > >> RCUREF_INIT() and ATOMIC_INIT() in there. > > > > I think I'd prefer to keep types.h as minimal as possible - as soon as > > we start putting non type stuff in there people won't know what the > > distinction is and it'll grow. > > > > preempt.h is a bit unusual too, normally we'd just split out a _types.h > > header there but it's not so easy to split up usefully. > > > > I don't feel like I have NAK power, but if I did, I would NAK > open coding of INIT_HLIST_HEAD() or anything like it. > I would expect some $maintainer to do likewise, but I could be > surprised. There is another solution here (although I prefer moving INIT_HLIST_HEAD into types.h). The preprocessor allows redefinitions as long as the two definitions match exactly. So you can copy INIT_HLIST_HEAD into preempt.h and if the definition ever changes, we'll notice.
On Sat, Dec 16, 2023 at 04:04:43PM -0800, Randy Dunlap wrote: > > > On 12/16/23 14:35, Kent Overstreet wrote: > > On Sat, Dec 16, 2023 at 06:13:41AM +0000, Matthew Wilcox wrote: > >> On Fri, Dec 15, 2023 at 10:35:47PM -0500, Kent Overstreet wrote: > >>> - INIT_HLIST_NODE(¬ifier->link); > >>> + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ > >>> + notifier->link.next = NULL; > >>> + notifier->link.pprev = NULL; > >> > >> Arguably INIT_HLIST_NODE() belongs in types.h -- we already have > >> RCUREF_INIT() and ATOMIC_INIT() in there. > > > > I think I'd prefer to keep types.h as minimal as possible - as soon as > > we start putting non type stuff in there people won't know what the > > distinction is and it'll grow. > > > > preempt.h is a bit unusual too, normally we'd just split out a _types.h > > header there but it's not so easy to split up usefully. > > > > I don't feel like I have NAK power, but if I did, I would NAK > open coding of INIT_HLIST_HEAD() or anything like it. > I would expect some $maintainer to do likewise, but I could be > surprised. It's INIT_HLIST_HEAD(), there's approximately zero chance of the implementation changing, and there's a comment.
On Sun, Dec 17, 2023 at 12:18:17AM +0000, Matthew Wilcox wrote: > On Sat, Dec 16, 2023 at 04:04:43PM -0800, Randy Dunlap wrote: > > > > > > On 12/16/23 14:35, Kent Overstreet wrote: > > > On Sat, Dec 16, 2023 at 06:13:41AM +0000, Matthew Wilcox wrote: > > >> On Fri, Dec 15, 2023 at 10:35:47PM -0500, Kent Overstreet wrote: > > >>> - INIT_HLIST_NODE(¬ifier->link); > > >>> + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ > > >>> + notifier->link.next = NULL; > > >>> + notifier->link.pprev = NULL; > > >> > > >> Arguably INIT_HLIST_NODE() belongs in types.h -- we already have > > >> RCUREF_INIT() and ATOMIC_INIT() in there. > > > > > > I think I'd prefer to keep types.h as minimal as possible - as soon as > > > we start putting non type stuff in there people won't know what the > > > distinction is and it'll grow. > > > > > > preempt.h is a bit unusual too, normally we'd just split out a _types.h > > > header there but it's not so easy to split up usefully. > > > > > > > I don't feel like I have NAK power, but if I did, I would NAK > > open coding of INIT_HLIST_HEAD() or anything like it. > > I would expect some $maintainer to do likewise, but I could be > > surprised. > > There is another solution here (although I prefer moving INIT_HLIST_HEAD > into types.h). The preprocessor allows redefinitions as long as the two > definitions match exactly. So you can copy INIT_HLIST_HEAD into > preempt.h and if the definition ever changes, we'll notice. I like it.
On 12/16/23 16:18, Kent Overstreet wrote: > On Sat, Dec 16, 2023 at 04:04:43PM -0800, Randy Dunlap wrote: >> >> >> On 12/16/23 14:35, Kent Overstreet wrote: >>> On Sat, Dec 16, 2023 at 06:13:41AM +0000, Matthew Wilcox wrote: >>>> On Fri, Dec 15, 2023 at 10:35:47PM -0500, Kent Overstreet wrote: >>>>> - INIT_HLIST_NODE(¬ifier->link); >>>>> + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ >>>>> + notifier->link.next = NULL; >>>>> + notifier->link.pprev = NULL; >>>> >>>> Arguably INIT_HLIST_NODE() belongs in types.h -- we already have >>>> RCUREF_INIT() and ATOMIC_INIT() in there. >>> >>> I think I'd prefer to keep types.h as minimal as possible - as soon as >>> we start putting non type stuff in there people won't know what the >>> distinction is and it'll grow. >>> >>> preempt.h is a bit unusual too, normally we'd just split out a _types.h >>> header there but it's not so easy to split up usefully. >>> >> >> I don't feel like I have NAK power, but if I did, I would NAK >> open coding of INIT_HLIST_HEAD() or anything like it. >> I would expect some $maintainer to do likewise, but I could be >> surprised. > > It's INIT_HLIST_HEAD(), there's approximately zero chance of the > implementation changing, and there's a comment. s/_HEAD/_NODE/ for both of us. :)
On 12/16/23 16:20, Kent Overstreet wrote: > On Sun, Dec 17, 2023 at 12:18:17AM +0000, Matthew Wilcox wrote: >> On Sat, Dec 16, 2023 at 04:04:43PM -0800, Randy Dunlap wrote: >>> >>> >>> On 12/16/23 14:35, Kent Overstreet wrote: >>>> On Sat, Dec 16, 2023 at 06:13:41AM +0000, Matthew Wilcox wrote: >>>>> On Fri, Dec 15, 2023 at 10:35:47PM -0500, Kent Overstreet wrote: >>>>>> - INIT_HLIST_NODE(¬ifier->link); >>>>>> + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ >>>>>> + notifier->link.next = NULL; >>>>>> + notifier->link.pprev = NULL; >>>>> >>>>> Arguably INIT_HLIST_NODE() belongs in types.h -- we already have >>>>> RCUREF_INIT() and ATOMIC_INIT() in there. >>>> >>>> I think I'd prefer to keep types.h as minimal as possible - as soon as >>>> we start putting non type stuff in there people won't know what the >>>> distinction is and it'll grow. >>>> >>>> preempt.h is a bit unusual too, normally we'd just split out a _types.h >>>> header there but it's not so easy to split up usefully. >>>> >>> >>> I don't feel like I have NAK power, but if I did, I would NAK >>> open coding of INIT_HLIST_HEAD() or anything like it. >>> I would expect some $maintainer to do likewise, but I could be >>> surprised. >> >> There is another solution here (although I prefer moving INIT_HLIST_HEAD >> into types.h). The preprocessor allows redefinitions as long as the two >> definitions match exactly. So you can copy INIT_HLIST_HEAD into >> preempt.h and if the definition ever changes, we'll notice. > > I like it. Possible to revert 490d6ab170c9 ? although with something list this inserted: struct hlist_node *_p = h; and then use _p instead of h (or the old macro's 'ptr') The code looks the same to me, although I could have mucked something up: https://godbolt.org/z/z76nsqGx3 although Andrew prefers inlines for type checking.
On Sat, Dec 16, 2023 at 06:03:36PM -0800, Randy Dunlap wrote: > > > On 12/16/23 16:20, Kent Overstreet wrote: > > On Sun, Dec 17, 2023 at 12:18:17AM +0000, Matthew Wilcox wrote: > >> On Sat, Dec 16, 2023 at 04:04:43PM -0800, Randy Dunlap wrote: > >>> > >>> > >>> On 12/16/23 14:35, Kent Overstreet wrote: > >>>> On Sat, Dec 16, 2023 at 06:13:41AM +0000, Matthew Wilcox wrote: > >>>>> On Fri, Dec 15, 2023 at 10:35:47PM -0500, Kent Overstreet wrote: > >>>>>> - INIT_HLIST_NODE(¬ifier->link); > >>>>>> + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ > >>>>>> + notifier->link.next = NULL; > >>>>>> + notifier->link.pprev = NULL; > >>>>> > >>>>> Arguably INIT_HLIST_NODE() belongs in types.h -- we already have > >>>>> RCUREF_INIT() and ATOMIC_INIT() in there. > >>>> > >>>> I think I'd prefer to keep types.h as minimal as possible - as soon as > >>>> we start putting non type stuff in there people won't know what the > >>>> distinction is and it'll grow. > >>>> > >>>> preempt.h is a bit unusual too, normally we'd just split out a _types.h > >>>> header there but it's not so easy to split up usefully. > >>>> > >>> > >>> I don't feel like I have NAK power, but if I did, I would NAK > >>> open coding of INIT_HLIST_HEAD() or anything like it. > >>> I would expect some $maintainer to do likewise, but I could be > >>> surprised. > >> > >> There is another solution here (although I prefer moving INIT_HLIST_HEAD > >> into types.h). The preprocessor allows redefinitions as long as the two > >> definitions match exactly. So you can copy INIT_HLIST_HEAD into > >> preempt.h and if the definition ever changes, we'll notice. > > > > I like it. > > Possible to revert 490d6ab170c9 ? although with something list > this inserted: > > struct hlist_node *_p = h; > and then use _p instead of h (or the old macro's 'ptr') > > The code looks the same to me, although I could have mucked something > up: https://godbolt.org/z/z76nsqGx3 > > although Andrew prefers inlines for type checking. I prefer inlines whenever possible too, a macro should really be a signal that 'something interesting is going on here'. I'm just going with my original version.
diff --git a/include/linux/preempt.h b/include/linux/preempt.h index 9aa6358a1a16..7233e9cf1bab 100644 --- a/include/linux/preempt.h +++ b/include/linux/preempt.h @@ -9,7 +9,7 @@ #include <linux/linkage.h> #include <linux/cleanup.h> -#include <linux/list.h> +#include <linux/types.h> /* * We put the hardirq and softirq counter into the preemption @@ -360,7 +360,9 @@ void preempt_notifier_unregister(struct preempt_notifier *notifier); static inline void preempt_notifier_init(struct preempt_notifier *notifier, struct preempt_ops *ops) { - INIT_HLIST_NODE(¬ifier->link); + /* INIT_HLIST_NODE() open coded, to avoid dependency on list.h */ + notifier->link.next = NULL; + notifier->link.pprev = NULL; notifier->ops = ops; }
We really only need types.h, list.h is big. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> --- include/linux/preempt.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)