Re: [PATCH v3] arch/x86: port I/O tracing on x86

From: Dan Raymond
Date: Fri Oct 06 2023 - 17:29:26 EST


On 10/4/2023 5:50 PM, Steven Rostedt wrote:
>> I've copied Steven Rostedt who is the maintainer of tracefs to see if he
>> has any comment. I just noticed arch/x86/boot/msr.h and I see that it
>> redefines rdmsr() and wrmsr() and omits the tracepoints. A comment there
>> explains:
>>
>> /*
>> * The kernel proper already defines rdmsr()/wrmsr(), but they are not for the
>> * boot kernel since they rely on tracepoint/exception handling infrastructure
>> * that's not available here.
>> */
>>
>> We could do something similar for inb()/outb() and redefine them in
>> arch/x86/boot/io.h instead of including <asm/shared/io.h> there.
>
> That would be a saner approach.
>
> -- Steve

I tried this but it is problematic because there are include chains that
define inb()/outb() without including arch/x86/boot/io.h at all. For example:

arch/x86/boot/compressed/misc.c ->
arch/x86/boot/compressed/misc.h ->
include/linux/acpi.h ->
include/acpi/acpi_io.h ->
include/linux/io.h ->
arch/x86/include/asm/io.h ->
arch/x86/include/asm/shared/io.h

What we need is to disable tracepoints altogether in arch/x86/boot/* so I
added -DDISABLE_TRACEPOINTS to the relevant Makefiles and I added a check for
that symbol in tracepoint-defs.h. I will submit a v4 version of my patch
with these changes shortly.

This resolves the problem with <asm/msr.h> as well. After applying the v4
patch I was able to call rdmsr()/wrmsr() from arch/x86/boot/misc.c.
Theoretically we can now remove arch/x86/boot/msr.h but I had trouble with
that due to compiler warnings and errors. The include files in arch/x86/boot
are a mess. Maybe this can be cleaned up in another patch.