Re: [PATCH v4 01/15] x86/msr: Add missing includes of

Ilpo Järvinen
2025-04-30T09:17:23Z

[-- Attachment #1: Type: text/plain, Size: 2377 bytes --]

On Wed, 30 Apr 2025, Xin Li wrote:

> On 4/29/2025 2:45 AM, Ilpo Järvinen wrote:
> > > arch/x86/events/msr.c | 3 +++
> > > arch/x86/events/perf_event.h | 1 +
> > > arch/x86/events/probe.c | 2 ++
> > Under arch/x86/events/ a few files seem to be missing the include?
>
>
> Most C files in arch/x86/events/ include arch/x86/events/perf_event.h,
> thus they don't need to include <asm/msr.h> directly once
> arch/x86/events/perf_event.h includes <asm/msr.h>, and this patch does
> that.
>
>
> The following files include arch/x86/events/intel/uncore.h which includes
> arch/x86/events/perf_event.h, thus no change needed:
> arch/x86/events/intel/uncore.c
> arch/x86/events/intel/uncore_discovery.c
> arch/x86/events/intel/uncore_nhmex.c
> arch/x86/events/intel/uncore_snb.c
> arch/x86/events/intel/uncore_snbep.c
>
> The following 2 files don't include arch/x86/events/perf_event.h so they
> include <asm/msr.h> directly with this patch:
> arch/x86/events/msr.c
> arch/x86/events/probe.c
>
> arch/x86/events/amd/uncore.c doesn't include
> arch/x86/events/perf_event.h but includes <asm/msr.h> already.
>
>
> So we are good in this directory, but it should be a separate patch with
> the above explanation then.

Hi,

While this is not my subsystem so don't have the final say here, you had
to explain quite much to prove that (and reviewer would have to go through
the same places to check). Wouldn't it be much simpler for all if all
those .c files would just include <asm/msr.h> directly? No need to explain
anything then.

Also, similar to what you're doing for some tsc related things in this
series, somebody could in the future decide that hey, these static inline
functions (that use .*msr.*) belong to some other file, allowing msr.h to
be removed from arch/x86/events/perf_event.h. Again, we'd need to add
asm/msr.h into more .c files. This is the problem with relying on indirect
includes, they create hard to track dependencies for #includes done in .h
files. If we actively encourage to depend on indirect #include
dependencies like that, it makes it very hard to _remove_ any #include
from a header file (as you have yourself discovered).

--
i.