Re: [PATCH] lib/string: shrink lib/string.i via IWYU

From: Greg KH
Date: Tue Dec 05 2023 - 18:47:20 EST


On Tue, Dec 05, 2023 at 02:14:55PM -0800, Nick Desaulniers wrote:
> On Tue, Dec 5, 2023 at 1:59 PM Greg KH <greg@xxxxxxxxx> wrote:
> >
> > On Tue, Dec 05, 2023 at 01:51:10PM -0800, Nick Desaulniers wrote:
> > > On Tue, Dec 5, 2023 at 1:38 PM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
> > > >
> > > > It also breeds includes of asm/*.h, by the look of the output, which is
> > > > not a good thing in general ;-/ E.g. #include <asm/uaccess.h> *anywhere*
> > > > outside of linux/uaccess.h is a bad idea.
> > >
> > > It's not clear to me when it's ok to #include <asm/*.h>. Is there a
> > > convention here that I'm missing?
> >
> > General rule, NEVER include asm/*.h, there should be a include/*.h
> > instead that works. So much so that checkpatch.pl should catch this,
> > right?
>
> ah, shoot, I was showing Tanzir how to use `b4` for patch development,
> and forgot to check this. Indeed it does.
>
> I can see how the check works (scripts/checkpatch.pl L5881). Decoding
> that will probably help us improve the tooling.
>
> >
> > But of course, it doesn't always hold true, there are a few minor
> > exceptions, but they are rare.
>
> $ grep -r \\#include lib | grep asm
>
> shows quite a few exceptions, and just in lib/.
>
> For example, lib/math/int_log.c includes asm/bug.h. Is that a case
> where lib/math/int_log.c should be #include 'ing linux/bug.h rather
> than asm/bug.h?

Probably yes, but we don't normally go back and take coding style fixes
for old files like this as it doesn't make much sense to do so.

But, if you are cleaning up the headers for large portions with the goal
of faster builds, that's a good reason.

Good luck!

greg k-h