Re: [PATCH 00/28] Fast kernel headers: reduce header dependencies

From: Nick Desaulniers
Date: Thu Feb 01 2024 - 13:12:54 EST


On Wed, Jan 31, 2024 at 11:00:27PM +0100, Max Kellermann wrote:
> On Wed, Jan 31, 2024 at 10:44 PM Randy Dunlap <rdunlap@xxxxxxxxxxxxx> wrote:
> > How were these (a) missing and (b) unnecessary includes
> > found or determined?
> > Did you use some tool for that? If so, which one?
>
> No tool, just stgit to edit the patches (in arbitrary order). I
> reduced header dependencies, but got lots of build errors because
> symbols were missing in different sources, which were previously
> fulfilled by indirect includes that were now removed. I fixed all
> those build errors by adding missing includes to those headers, moving
> those changes to the first patch.
>
> I found the unnecessary includes manually along the way by using "git
> grep" to find all include directives for a certain header; I checked
> the source for the reason why this header was included, and whether
> the include could be replaced with "X_types.h" instead. Sometimes, I
> found that not even "X_types.h" was necessary, but no include at all,
> so I removed the include completely and had those changes in the
> second patch.
>
> The first two patches grew along the way. It was refreshed over and
> over (with stgit), while I was editing the other patches.
>
> I know there's the "iwyu" tool, and it may be helpful eventually, but
> there's so much low-hanging fruit in the kernel, iwyu is not useful
> yet I think.

We just wrapped up an internship where Tanzir was looking into getting IWYU
working on the kernel. He presented about it at Linux Plumbers Conf '23
recently.

https://youtu.be/eFq_oqLiXPM?si=0VhuMnwjHnMPJeaR
https://youtu.be/XMVLSEzbpQ8?si=_2DQpS7JBlEC4FK1
https://github.com/ClangBuiltLinux/IWYUScripts
https://lore.kernel.org/lkml/?q=f%3Atanzirh%40google.com

Some of his patches have landed, others had requests from maintainers that
weren't reasonable to satisfy in the short duration of an internship. But still
worth pursuing. Happy to chat more about the general problem sometime.

>
> Max