Skip to contentSkip to conversation

x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c

PATCH In review Vincent Mailhol 5 participants 10 messages Nov 27, 2022 – Nov 29, 2022 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c

Following [1], the macro COMPILE_OFFSETS becomes unused:

  $ make W=2 arch/x86/kernel/asm-offsets.o
  <...>
  arch/x86/kernel/asm-offsets.c:7: warning: macro "COMPILE_OFFSETS" is not used [-Wunused-macros]
  <...>

Remove COMPILE_OFFSETS macro.

[1] commit debc5a1ec0d1 ("KVM: x86: use a separate asm-offsets.c file")

Fixes debc5a1ec0d1 ("KVM: x86: use a separate asm-offsets.c file")
---
 arch/x86/kernel/asm-offsets.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kernel/asm-offsets.c +0 -1
index 437308004ef2..cf2e02bafbef 100644
@@ -4,7 +4,6 @@
  * This code generates raw asm output which is post-processed to extract
  * and format the required data.
  */
-#define COMPILE_OFFSETS
 
 #include <linux/crypto.h>
 #include <linux/sched.h>
Signature · 1 line
2.37.4
#1 lore raw
Quoted 1 line · Vincent Mailhol

Following [1], the macro COMPILE_OFFSETS becomes unused:

Really? I see #ifdef COMPILE_OFFSETS in ftrace.h. Hm?

Have you tested your patch with CONFIG_FTRACE_SYSCALLS=y and CONFIG_IA32_EMULATION=y?

Quoted 31 lines
  $ make W=2 arch/x86/kernel/asm-offsets.o
  <...>
  arch/x86/kernel/asm-offsets.c:7: warning: macro "COMPILE_OFFSETS" is not used [-Wunused-macros]
  <...>

Remove COMPILE_OFFSETS macro.

[1] commit debc5a1ec0d1 ("KVM: x86: use a separate asm-offsets.c file")

Fixes debc5a1ec0d1 ("KVM: x86: use a separate asm-offsets.c file")
---
 arch/x86/kernel/asm-offsets.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kernel/asm-offsets.c +0 -1
index 437308004ef2..cf2e02bafbef 100644
@@ -4,7 +4,6 @@
  * This code generates raw asm output which is post-processed to extract
  * and format the required data.
  */
-#define COMPILE_OFFSETS
 
 #include <linux/crypto.h>
 #include <linux/sched.h>
Signature · 1 line
2.37.4
Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov
#2 lore raw
Quoted 7 lines · Kirill A. Shutemov
Quoted 1 line · Vincent Mailhol

Following [1], the macro COMPILE_OFFSETS becomes unused:

Really? I see #ifdef COMPILE_OFFSETS in ftrace.h. Hm?

Have you tested your patch with CONFIG_FTRACE_SYSCALLS=y and CONFIG_IA32_EMULATION=y?

Even if I activate those two configurations, the compiler still tells me it is unused:

  $ grep -E "CONFIG_FTRACE_SYSCALLS|CONFIG_IA32_EMULATION" .config
  CONFIG_IA32_EMULATION=y
  CONFIG_FTRACE_SYSCALLS=y
  $ make W=2 arch/x86/kernel/asm-offsets.o
  <...>
  arch/x86/kernel/asm-offsets.c:7: warning: macro "COMPILE_OFFSETS" is not used [-Wunused-macros]
  <...>
Quoted 28 lines
Quoted 28 lines
  $ make W=2 arch/x86/kernel/asm-offsets.o
  <...>
  arch/x86/kernel/asm-offsets.c:7: warning: macro "COMPILE_OFFSETS" is not used [-Wunused-macros]
  <...>

Remove COMPILE_OFFSETS macro.

[1] commit debc5a1ec0d1 ("KVM: x86: use a separate asm-offsets.c file")

Fixes debc5a1ec0d1 ("KVM: x86: use a separate asm-offsets.c file")
---
 arch/x86/kernel/asm-offsets.c | 1 -
 1 file changed, 1 deletion(-)
arch/x86/kernel/asm-offsets.c +0 -1
index 437308004ef2..cf2e02bafbef 100644
@@ -4,7 +4,6 @@
  * This code generates raw asm output which is post-processed to extract
  * and format the required data.
  */
-#define COMPILE_OFFSETS
 
 #include <linux/crypto.h>
 #include <linux/sched.h>
#3 lore raw
Quoted 12 lines · Vincent Mailhol
Quoted 7 lines · Kirill A. Shutemov
Quoted 1 line · Vincent Mailhol

Following [1], the macro COMPILE_OFFSETS becomes unused:

Really? I see #ifdef COMPILE_OFFSETS in ftrace.h. Hm?

Have you tested your patch with CONFIG_FTRACE_SYSCALLS=y and CONFIG_IA32_EMULATION=y?

Even if I activate those two configurations, the compiler still tells me it is unused:

Quoted 8 lines
  $ grep -E "CONFIG_FTRACE_SYSCALLS|CONFIG_IA32_EMULATION" .config
  CONFIG_IA32_EMULATION=y
  CONFIG_FTRACE_SYSCALLS=y
  $ make W=2 arch/x86/kernel/asm-offsets.o
  <...>
  arch/x86/kernel/asm-offsets.c:7: warning: macro "COMPILE_OFFSETS" is not used [-Wunused-macros]
  <...>

If you are sure <asm/ftrace.h> is never included from asm-offsets.c, remove #ifndef COMPILE_OFFSETS too.

Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov
#4 lore raw
Quoted 17 lines · On Mon. 28 Nov. 2022 at 20:11, <[email protected]> wrote:
Quoted 16 lines · Vincent Mailhol
Quoted 7 lines · Kirill A. Shutemov
Quoted 1 line · Vincent Mailhol

Following [1], the macro COMPILE_OFFSETS becomes unused:

Really? I see #ifdef COMPILE_OFFSETS in ftrace.h. Hm?

Have you tested your patch with CONFIG_FTRACE_SYSCALLS=y and CONFIG_IA32_EMULATION=y?

Even if I activate those two configurations, the compiler still tells me it is unused:

  $ grep -E "CONFIG_FTRACE_SYSCALLS|CONFIG_IA32_EMULATION" .config
  CONFIG_IA32_EMULATION=y
  CONFIG_FTRACE_SYSCALLS=y
Quoted 7 lines
Quoted 4 lines
  $ make W=2 arch/x86/kernel/asm-offsets.o
  <...>
  arch/x86/kernel/asm-offsets.c:7: warning: macro "COMPILE_OFFSETS" is not used [-Wunused-macros]
  <...>

If you are sure <asm/ftrace.h> is never included from asm-offsets.c, remove #ifndef COMPILE_OFFSETS too.

It is never included from asm-offsets.c but it is still used by kvm-asm-offsets.c:
https://elixir.bootlin.com/linux/v6.1-rc7/source/arch/x86/kvm/kvm-asm-offsets.c#L7

#5 lore raw
Quoted 6 lines · On Mon, 28 Nov 2022 20:30:35 +0900 Vincent MAILHOL…
Quoted 2 lines

If you are sure <asm/ftrace.h> is never included from asm-offsets.c, remove #ifndef COMPILE_OFFSETS too.

It is never included from asm-offsets.c but it is still used by kvm-asm-offsets.c:
https://elixir.bootlin.com/linux/v6.1-rc7/source/arch/x86/kvm/kvm-asm-offsets.c#L7

IIRC, the reason for adding that was because that logic was screwing up asm-offsets.c. I'm not sure it screws up kvm-asm-offsets.c though.

This is one of those cases I wish I commented that code better :-/

-- Steve

#6 lore raw
Quoted 10 lines · Steven Rostedt
Quoted 6 lines
Quoted 3 lines

If you are sure <asm/ftrace.h> is never included from asm-offsets.c, remove #ifndef COMPILE_OFFSETS too.

It is never included from asm-offsets.c but it is still used by kvm-asm-offsets.c:
https://elixir.bootlin.com/linux/v6.1-rc7/source/arch/x86/kvm/kvm-asm-offsets.c#L7

IIRC, the reason for adding that was because that logic was screwing up asm-offsets.c. I'm not sure it screws up kvm-asm-offsets.c though.

This is one of those cases I wish I commented that code better :-/

I don't think KVM includes linux/ftrace.h or asm/ftrace.h at all.

Paolo

#7 lore raw
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Steven Rostedt
Quoted 6 lines
Quoted 3 lines

If you are sure <asm/ftrace.h> is never included from asm-offsets.c, remove #ifndef COMPILE_OFFSETS too.

It is never included from asm-offsets.c but it is still used by kvm-asm-offsets.c:
https://elixir.bootlin.com/linux/v6.1-rc7/source/arch/x86/kvm/kvm-asm-offsets.c#L7

Quoted 6 lines
Quoted 4 lines

IIRC, the reason for adding that was because that logic was screwing up asm-offsets.c. I'm not sure it screws up kvm-asm-offsets.c though.

This is one of those cases I wish I commented that code better :-/

I don't think KVM includes linux/ftrace.h or asm/ftrace.h at all.

From include/linux/kvm_host.h

  #include <linux/ftrace.h>

Even if that didn't exist, saying that XYZ never includes a header is a dangerous business, it's all too easy to indirectly include headers in the kernel, now or in the future.

#8 lore raw
Quoted 7 lines · On Mon, 28 Nov 2022 18:06:18 +0000 Sean Christopherson <[email protected]>…
Quoted 6 lines
Quoted 4 lines

IIRC, the reason for adding that was because that logic was screwing up asm-offsets.c. I'm not sure it screws up kvm-asm-offsets.c though.

This is one of those cases I wish I commented that code better :-/

I don't think KVM includes linux/ftrace.h or asm/ftrace.h at all.

Quoted 7 lines
Quoted 1 line

From include/linux/kvm_host.h

  #include <linux/ftrace.h>

Even if that didn't exist, saying that XYZ never includes a header is a dangerous business, it's all too easy to indirectly include headers in the kernel, now or in the future.

But going back to the original intent of COMPILE_OFFSETS. I believe it was because some code that did not work with the auto generation of compiler offsets and was a way to hide them.

I do not know if it is still an issue or not today.

-- Steve

#9 lore raw
Quoted 10 lines · Steven Rostedt
Quoted 7 lines · On Mon, 28 Nov 2022 18:06:18 +0000 Sean Christopherson <[email protected]>…
Quoted 6 lines
Quoted 4 lines

IIRC, the reason for adding that was because that logic was screwing up asm-offsets.c. I'm not sure it screws up kvm-asm-offsets.c though.

This is one of those cases I wish I commented that code better :-/

I don't think KVM includes linux/ftrace.h or asm/ftrace.h at all.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

From include/linux/kvm_host.h

  #include <linux/ftrace.h>

Even if that didn't exist, saying that XYZ never includes a header is a dangerous business, it's all too easy to indirectly include headers in the kernel, now or in the future.

ACK. This is why I relied on the compiler's -Wunused-macros to assert that COMPILE_OFFSETS can be removed from asm-offsets.c but not from kvm-asm-offsets.c.
I also asserted that it is
https://git.kernel.org/torvalds/linux/c/debc5a1ec0d1 which removed the dependency.

Quoted 5 lines

But going back to the original intent of COMPILE_OFFSETS. I believe it was because some code that did not work with the auto generation of compiler offsets and was a way to hide them.

I do not know if it is still an issue or not today.

This I do not know. I only have the confidence to remove COMPILE_OFFSETS from asm-offsets.c. Nothing more.