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

From: Greg KH
Date: Tue Dec 05 2023 - 22:09:33 EST


On Wed, Dec 06, 2023 at 03:00:47AM +0000, Al Viro wrote:
> On Wed, Dec 06, 2023 at 12:55:42AM +0000, Al Viro wrote:
> > On Wed, Dec 06, 2023 at 08:46:50AM +0900, Greg KH wrote:
> > > > >
> > > > > 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.
> >
> > FWIW, the most common (by far - about 13% of such includes, over drivers/, fs/,
> > mm/, net/ and sound/) is asm/unaligned.h.
>
> Why the hell is unaligned.h in asm/*, anyway?
>
> We have 3 variants: arc, parisc and generic (== everything else).
> Both arc and parisc instances have an explicit include of
> asm-generic/unaligned.h (i.e. the generic variant).
>
> On arc there's also misaligned_fixup() extern or stub, with exactly
> one user (in arch/arc/kernel/traps.c). On parisc there are
> externs for handle_unaligned() and check_unaligned() (3 call sites,
> all in arch/parisc/kernel/traps.c).
>
> How about we take those into arch/{arc,parisc}/kernel/unaligned.h,
> slap #include "unaligned.h" into their traps.c and unaligned.c
> (callers and definitions resp.) and strip those from asm/unaligned.h?
> At that point we can remove arch/{arc,parisc}/asm/unaligned.h - everything
> will pick include/asm-generic/unaligned.h.
>
> Then the next cycle we ask Linus to run the following:
> for i in `git grep -l -w asm/unaligned.h`; do
> sed -i -e "s/asm\/unaligned.h/linux\/unaligned.h/" $i
> done
> git mv include/asm-generic/unaligned.h include/linux/unaligned.h
> sed -i -e "/unaligned.h/d" include/asm-generic/Kbuild
> right before releasing -rc1 and asm/unaligned.h is gone...

Please do, it's really annoying and would be great to fix up.

thanks,

greg k-h