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

Ilpo Järvinen
2025-05-02T13:13:23Z

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

On Wed, 30 Apr 2025, Xin Li (Intel) wrote:

> For some reason, there are some TSC-related functions in the MSR
> header even though there is a tsc.h header.
>
> To facilitate the relocation of rdtsc{,_ordered}() from <asm/msr.h>
> to <asm/tsc.h> and to eventually eliminate the inclusion of
> <asm/msr.h> in <asm/tsc.h>, add <asm/msr.h> to the source files that
> reference definitions from <asm/msr.h>.
>
> Signed-off-by: Xin Li (Intel) <xin@zytor.com>
> Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>
> Change in v4A:
> *) Use "git grep -l -e $PATTERN | grep -v -f <(git grep -l -e 'asm/msr\.h')"
> to ensure ALL required *direct* inclusion of <asm/msr.h> (Ilpo Järvinen).
>
> Change in v4:
> *) Add missing includes in a different patch (Ilpo Järvinen).
> *) Add all necessary direct inclusions for msr.h (Ilpo Järvinen).
>
> Change in v3:
> * Add a problem statement to the changelog (Dave Hansen).
> ---
> arch/x86/coco/sev/core.c | 1 +
> arch/x86/events/amd/core.c | 1 +
> arch/x86/events/amd/ibs.c | 1 +
> arch/x86/events/amd/iommu.c | 2 ++
> arch/x86/events/amd/lbr.c | 1 +
> arch/x86/events/amd/power.c | 1 +
> arch/x86/events/core.c | 1 +
> arch/x86/events/intel/bts.c | 1 +
> arch/x86/events/intel/core.c | 1 +
> arch/x86/events/intel/cstate.c | 1 +
> arch/x86/events/intel/ds.c | 1 +
> arch/x86/events/intel/knc.c | 1 +
> arch/x86/events/intel/p4.c | 1 +
> arch/x86/events/intel/p6.c | 1 +
> arch/x86/events/intel/pt.c | 1 +
> arch/x86/events/intel/uncore.c | 1 +
> arch/x86/events/intel/uncore_discovery.c | 1 +
> arch/x86/events/intel/uncore_nhmex.c | 1 +
> arch/x86/events/intel/uncore_snb.c | 1 +
> arch/x86/events/intel/uncore_snbep.c | 1 +
> arch/x86/events/msr.c | 2 ++
> arch/x86/events/perf_event.h | 1 +
> arch/x86/events/probe.c | 2 ++
> arch/x86/events/rapl.c | 1 +
> arch/x86/events/utils.c | 1 +
> arch/x86/events/zhaoxin/core.c | 1 +
> arch/x86/hyperv/hv_apic.c | 1 +
> arch/x86/hyperv/hv_init.c | 1 +
> arch/x86/hyperv/hv_spinlock.c | 1 +
> arch/x86/hyperv/hv_vtl.c | 1 +
> arch/x86/hyperv/ivm.c | 1 +
> arch/x86/include/asm/fred.h | 1 +
> arch/x86/include/asm/kvm_host.h | 1 +
> arch/x86/include/asm/microcode.h | 2 ++
> arch/x86/include/asm/mshyperv.h | 1 +
> arch/x86/include/asm/msr.h | 1 +
> arch/x86/include/asm/resctrl.h | 2 ++
> arch/x86/include/asm/suspend_32.h | 1 +
> arch/x86/include/asm/suspend_64.h | 1 +
> arch/x86/include/asm/switch_to.h | 2 ++
> arch/x86/kernel/acpi/sleep.c | 1 +
> arch/x86/kernel/amd_nb.c | 1 +
> arch/x86/kernel/apic/apic.c | 1 +
> arch/x86/kernel/apic/apic_numachip.c | 1 +
> arch/x86/kernel/cet.c | 1 +
> arch/x86/kernel/cpu/amd.c | 1 +
> arch/x86/kernel/cpu/aperfmperf.c | 1 +
> arch/x86/kernel/cpu/bus_lock.c | 1 +
> arch/x86/kernel/cpu/feat_ctl.c | 1 +
> arch/x86/kernel/cpu/hygon.c | 1 +
> arch/x86/kernel/cpu/mce/inject.c | 1 +
> arch/x86/kernel/cpu/microcode/core.c | 1 +
> arch/x86/kernel/cpu/mshyperv.c | 1 +
> arch/x86/kernel/cpu/resctrl/core.c | 1 +
> arch/x86/kernel/cpu/resctrl/monitor.c | 1 +
> arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1 +
> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 1 +
> arch/x86/kernel/cpu/sgx/main.c | 1 +
> arch/x86/kernel/cpu/topology.c | 1 +
> arch/x86/kernel/cpu/topology_amd.c | 1 +
> arch/x86/kernel/cpu/tsx.c | 1 +
> arch/x86/kernel/cpu/zhaoxin.c | 1 +
> arch/x86/kernel/fpu/core.c | 1 +
> arch/x86/kernel/fpu/xstate.c | 1 +
> arch/x86/kernel/fpu/xstate.h | 1 +
> arch/x86/kernel/fred.c | 1 +
> arch/x86/kernel/hpet.c | 1 +
> arch/x86/kernel/kvm.c | 1 +
> arch/x86/kernel/paravirt.c | 1 +
> arch/x86/kernel/process.c | 1 +
> arch/x86/kernel/process_64.c | 1 +
> arch/x86/kernel/trace_clock.c | 2 +-
> arch/x86/kernel/traps.c | 1 +
> arch/x86/kernel/tsc.c | 1 +
> arch/x86/kernel/tsc_sync.c | 1 +
> arch/x86/kvm/svm/avic.c | 1 +
> arch/x86/kvm/svm/sev.c | 1 +
> arch/x86/kvm/svm/svm.c | 1 +
> arch/x86/kvm/vmx/nested.c | 1 +
> arch/x86/kvm/vmx/pmu_intel.c | 1 +
> arch/x86/kvm/vmx/sgx.c | 1 +
> arch/x86/kvm/vmx/vmx.c | 1 +
> arch/x86/lib/insn-eval.c | 1 +
> arch/x86/lib/kaslr.c | 2 +-
> arch/x86/mm/mem_encrypt_identity.c | 1 +
> arch/x86/mm/tlb.c | 1 +
> arch/x86/pci/amd_bus.c | 1 +
> arch/x86/pci/mmconfig-shared.c | 3 ++-
> arch/x86/power/cpu.c | 1 +
> arch/x86/realmode/init.c | 1 +
> arch/x86/virt/svm/sev.c | 1 +
> arch/x86/xen/enlighten_pv.c | 1 +
> arch/x86/xen/pmu.c | 1 +
> arch/x86/xen/suspend.c | 1 +
> drivers/accel/habanalabs/common/habanalabs_ioctl.c | 2 --
> drivers/acpi/acpi_extlog.c | 1 +
> drivers/acpi/processor_perflib.c | 1 +
> drivers/acpi/processor_throttling.c | 6 +++++-
> drivers/char/agp/nvidia-agp.c | 1 +
> drivers/cpufreq/amd-pstate-ut.c | 2 ++
> drivers/cpufreq/elanfreq.c | 1 -
> drivers/cpufreq/sc520_freq.c | 1 -
> drivers/crypto/ccp/sev-dev.c | 1 +
> drivers/edac/amd64_edac.c | 1 +
> drivers/edac/ie31200_edac.c | 1 +
> drivers/edac/mce_amd.c | 1 +
> drivers/hwmon/hwmon-vid.c | 4 ++++
> drivers/idle/intel_idle.c | 1 +
> drivers/misc/cs5535-mfgpt.c | 1 +
> drivers/net/vmxnet3/vmxnet3_drv.c | 4 ++++
> drivers/platform/x86/intel/ifs/core.c | 1 +
> drivers/platform/x86/intel/ifs/load.c | 1 +
> drivers/platform/x86/intel/ifs/runtest.c | 1 +
> drivers/platform/x86/intel/pmc/cnp.c | 1 +
> drivers/platform/x86/intel/speed_select_if/isst_if_common.c | 1 +
> .../platform/x86/intel/speed_select_if/isst_if_mbox_msr.c | 1 +
> drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 1 +
> drivers/platform/x86/intel/turbo_max_3.c | 1 +
> .../platform/x86/intel/uncore-frequency/uncore-frequency.c | 1 +
> drivers/powercap/intel_rapl_common.c | 1 +
> drivers/powercap/intel_rapl_msr.c | 1 +
> .../intel/int340x_thermal/processor_thermal_device.c | 1 +
> drivers/thermal/intel/intel_tcc_cooling.c | 1 +
> drivers/thermal/intel/x86_pkg_temp_thermal.c | 1 +
> drivers/video/fbdev/geode/display_gx.c | 1 +
> drivers/video/fbdev/geode/gxfb_core.c | 1 +
> drivers/video/fbdev/geode/lxfb_ops.c | 1 +
> 127 files changed, 142 insertions(+), 8 deletions(-)
>

> diff --git a/arch/x86/kernel/trace_clock.c b/arch/x86/kernel/trace_clock.c
> index b8e7abe00b06..708d61743d15 100644
> --- a/arch/x86/kernel/trace_clock.c
> +++ b/arch/x86/kernel/trace_clock.c
> @@ -4,7 +4,7 @@
> */
> #include <asm/trace_clock.h>
> #include <asm/barrier.h>
> -#include <asm/msr.h>
> +#include <asm/tsc.h>

Does this change belong to this patch?

It might even cause a build failure until the second patch which moves
the tsc related things to the other file (unless there's indirect include
path to asm/msr.h).

> diff --git a/arch/x86/lib/kaslr.c b/arch/x86/lib/kaslr.c
> index a58f451a7dd3..b5893928d55c 100644
> --- a/arch/x86/lib/kaslr.c
> +++ b/arch/x86/lib/kaslr.c
> @@ -8,7 +8,7 @@
> */
> #include <asm/asm.h>
> #include <asm/kaslr.h>
> -#include <asm/msr.h>
> +#include <asm/tsc.h>

Same thing here.

> #include <asm/archrandom.h>
> #include <asm/e820/api.h>
> #include <asm/shared/io.h>

> diff --git a/drivers/accel/habanalabs/common/habanalabs_ioctl.c b/drivers/accel/habanalabs/common/habanalabs_ioctl.c
> index 8729a0c57d78..dc80ca921d90 100644
> --- a/drivers/accel/habanalabs/common/habanalabs_ioctl.c
> +++ b/drivers/accel/habanalabs/common/habanalabs_ioctl.c
> @@ -17,8 +17,6 @@
> #include <linux/uaccess.h>
> #include <linux/vmalloc.h>
>
> -#include <asm/msr.h>
> -

I suggested making a separate patch out of these removals. Currently you
do them without any clear warning in the changelog which only talks about
adding asm/msr.h.

> diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
> index 00d045e5f524..ecd7fe256153 100644
> --- a/drivers/acpi/processor_throttling.c
> +++ b/drivers/acpi/processor_throttling.c
> @@ -18,9 +18,13 @@
> #include <linux/sched.h>
> #include <linux/cpufreq.h>
> #include <linux/acpi.h>
> +#include <linux/uaccess.h>
> #include <acpi/processor.h>
> #include <asm/io.h>
> -#include <linux/uaccess.h>
> +#include <asm/asm.h>

???

> +#ifdef CONFIG_X86
> +#include <asm/msr.h>
> +#endif

I really appreciate you took the effort to do this change the correct
way! :-)

--
i.