On Wed, Aug 5, 2020 at 4:20 AM Marc Zyngier maz@kernel.org wrote:
I came up with yet another "quality" hack, which gets the job done, see below. It is obviously much simpler, but also terribly ugly.
This is effectively what the approach of commit c0842fbc1b18 ("random32: move the pseudo-random 32-bit definitions to prandom.h") was too. It has the prandom include in the middle of random.h - which makes sense in the context of that patch (because it's where all the prandom stuff used to live there), but the real secret is that as it does that, it basically moves the percpu.h include down there too.
This mess has caused me to seriously look at making sparse generate a "defined here, used here" list, and do a topo-sort on it all, and warn about unused includes but also about stupidities like this.
But I won't have time to do that until after the merge window, and it may turn out nastier than expected. But I did add all the include chaining information to the sparse position logic recently in a fairly easy to digest form, so my gut feel is that something that doesn't try to actually optimize or solve the problem - just point out the obvious errors - might be more reasonably doable than doing something that is theoretically the RightThing(tm) to do.
IOW, a tool only to help find and figure these things out, rather than a tool to do all the minimization for you automatically.
We'll see. No promises. And if somebody else beats me to it, I won't complain.
Linus