All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c
@ 2022-11-27  6:23 Vincent Mailhol
  2022-11-28  9:15 ` Kirill A . Shutemov
  0 siblings, 1 reply; 10+ messages in thread
From: Vincent Mailhol @ 2022-11-27  6:23 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86
  Cc: H . Peter Anvin, Kirill A . Shutemov, Josh Poimboeuf,
	Kuppuswamy Sathyanarayanan, Al Viro, linux-kernel,
	Vincent Mailhol

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")
    Link: https://git.kernel.org/torvalds/linux/c/debc5a1ec0d1

Fixes: debc5a1ec0d1 ("KVM: x86: use a separate asm-offsets.c file")
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
---
 arch/x86/kernel/asm-offsets.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
index 437308004ef2..cf2e02bafbef 100644
--- a/arch/x86/kernel/asm-offsets.c
+++ b/arch/x86/kernel/asm-offsets.c
@@ -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>
-- 
2.37.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c
  2022-11-27  6:23 [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c Vincent Mailhol
@ 2022-11-28  9:15 ` Kirill A . Shutemov
  2022-11-28 10:11   ` Vincent Mailhol
  0 siblings, 1 reply; 10+ messages in thread
From: Kirill A . Shutemov @ 2022-11-28  9:15 UTC (permalink / raw)
  To: Vincent Mailhol, Steven Rostedt
  Cc: Sean Christopherson, Paolo Bonzini, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H . Peter Anvin,
	Josh Poimboeuf, Kuppuswamy Sathyanarayanan, Al Viro,
	linux-kernel

On Sun, Nov 27, 2022 at 03:23:35PM +0900, Vincent Mailhol wrote:
> 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?

>   $ 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")
>     Link: https://git.kernel.org/torvalds/linux/c/debc5a1ec0d1
> 
> Fixes: debc5a1ec0d1 ("KVM: x86: use a separate asm-offsets.c file")
> Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
> ---
>  arch/x86/kernel/asm-offsets.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
> index 437308004ef2..cf2e02bafbef 100644
> --- a/arch/x86/kernel/asm-offsets.c
> +++ b/arch/x86/kernel/asm-offsets.c
> @@ -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>
> -- 
> 2.37.4
> 

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c
  2022-11-28  9:15 ` Kirill A . Shutemov
@ 2022-11-28 10:11   ` Vincent Mailhol
  2022-11-28 11:11     ` kirill.shutemov
  0 siblings, 1 reply; 10+ messages in thread
From: Vincent Mailhol @ 2022-11-28 10:11 UTC (permalink / raw)
  To: kirill.shutemov
  Cc: bp, dave.hansen, hpa, jpoimboe, linux-kernel, mailhol.vincent,
	mingo, pbonzini, rostedt, sathyanarayanan.kuppuswamy, seanjc,
	tglx, viro, x86

On Mon, 28 Nov 2022 12:15:06 +0300, Kirill A. Shutemov wrote:
> On Sun, Nov 27, 2022 at 03:23:35PM +0900, Vincent Mailhol wrote:
> > 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]
  <...>

> >   $ 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")
> >     Link: https://git.kernel.org/torvalds/linux/c/debc5a1ec0d1
> > 
> > Fixes: debc5a1ec0d1 ("KVM: x86: use a separate asm-offsets.c file")
> > Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
> > ---
> >  arch/x86/kernel/asm-offsets.c | 1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
> > index 437308004ef2..cf2e02bafbef 100644
> > --- a/arch/x86/kernel/asm-offsets.c
> > +++ b/arch/x86/kernel/asm-offsets.c
> > @@ -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>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c
  2022-11-28 10:11   ` Vincent Mailhol
@ 2022-11-28 11:11     ` kirill.shutemov
  2022-11-28 11:30       ` Vincent MAILHOL
  0 siblings, 1 reply; 10+ messages in thread
From: kirill.shutemov @ 2022-11-28 11:11 UTC (permalink / raw)
  To: Vincent Mailhol
  Cc: bp, dave.hansen, hpa, jpoimboe, linux-kernel, mingo, pbonzini,
	rostedt, sathyanarayanan.kuppuswamy, seanjc, tglx, viro, x86

On Mon, Nov 28, 2022 at 07:11:17PM +0900, Vincent Mailhol wrote:
> On Mon, 28 Nov 2022 12:15:06 +0300, Kirill A. Shutemov wrote:
> > On Sun, Nov 27, 2022 at 03:23:35PM +0900, Vincent Mailhol wrote:
> > > 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]
>   <...>

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

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c
  2022-11-28 11:11     ` kirill.shutemov
@ 2022-11-28 11:30       ` Vincent MAILHOL
  2022-11-28 17:45         ` Steven Rostedt
  0 siblings, 1 reply; 10+ messages in thread
From: Vincent MAILHOL @ 2022-11-28 11:30 UTC (permalink / raw)
  To: kirill.shutemov
  Cc: bp, dave.hansen, hpa, jpoimboe, linux-kernel, mingo, pbonzini,
	rostedt, sathyanarayanan.kuppuswamy, seanjc, tglx, viro, x86

On Mon. 28 Nov. 2022 at 20:11, <kirill.shutemov@linux.intel.com> wrote:
> On Mon, Nov 28, 2022 at 07:11:17PM +0900, Vincent Mailhol wrote:
> > On Mon, 28 Nov 2022 12:15:06 +0300, Kirill A. Shutemov wrote:
> > > On Sun, Nov 27, 2022 at 03:23:35PM +0900, Vincent Mailhol wrote:
> > > > 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]
> >   <...>
>
> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c
  2022-11-28 11:30       ` Vincent MAILHOL
@ 2022-11-28 17:45         ` Steven Rostedt
  2022-11-28 18:00           ` Paolo Bonzini
  0 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2022-11-28 17:45 UTC (permalink / raw)
  To: Vincent MAILHOL
  Cc: kirill.shutemov, bp, dave.hansen, hpa, jpoimboe, linux-kernel,
	mingo, pbonzini, sathyanarayanan.kuppuswamy, seanjc, tglx, viro,
	x86

On Mon, 28 Nov 2022 20:30:35 +0900
Vincent MAILHOL <mailhol.vincent@wanadoo.fr> wrote:

> > 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c
  2022-11-28 17:45         ` Steven Rostedt
@ 2022-11-28 18:00           ` Paolo Bonzini
  2022-11-28 18:06             ` Sean Christopherson
  0 siblings, 1 reply; 10+ messages in thread
From: Paolo Bonzini @ 2022-11-28 18:00 UTC (permalink / raw)
  To: Steven Rostedt, Vincent MAILHOL
  Cc: kirill.shutemov, bp, dave.hansen, hpa, jpoimboe, linux-kernel,
	mingo, sathyanarayanan.kuppuswamy, seanjc, tglx, viro, x86

On 11/28/22 18:45, Steven Rostedt wrote:
> 
>>> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c
  2022-11-28 18:00           ` Paolo Bonzini
@ 2022-11-28 18:06             ` Sean Christopherson
  2022-11-28 19:10               ` Steven Rostedt
  0 siblings, 1 reply; 10+ messages in thread
From: Sean Christopherson @ 2022-11-28 18:06 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Steven Rostedt, Vincent MAILHOL, kirill.shutemov, bp,
	dave.hansen, hpa, jpoimboe, linux-kernel, mingo,
	sathyanarayanan.kuppuswamy, tglx, viro, x86

On Mon, Nov 28, 2022, Paolo Bonzini wrote:
> On 11/28/22 18:45, Steven Rostedt wrote:
> > 
> > > > 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.

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c
  2022-11-28 18:06             ` Sean Christopherson
@ 2022-11-28 19:10               ` Steven Rostedt
  2022-11-29 10:14                 ` Vincent MAILHOL
  0 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2022-11-28 19:10 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: Paolo Bonzini, Vincent MAILHOL, kirill.shutemov, bp, dave.hansen,
	hpa, jpoimboe, linux-kernel, mingo, sathyanarayanan.kuppuswamy,
	tglx, viro, x86

On Mon, 28 Nov 2022 18:06:18 +0000
Sean Christopherson <seanjc@google.com> wrote:

> > > 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.

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c
  2022-11-28 19:10               ` Steven Rostedt
@ 2022-11-29 10:14                 ` Vincent MAILHOL
  0 siblings, 0 replies; 10+ messages in thread
From: Vincent MAILHOL @ 2022-11-29 10:14 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Sean Christopherson, Paolo Bonzini, kirill.shutemov, bp,
	dave.hansen, hpa, jpoimboe, linux-kernel, mingo,
	sathyanarayanan.kuppuswamy, tglx, viro, x86

On Tue. 29 Nov. 2022 at 04:10, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Mon, 28 Nov 2022 18:06:18 +0000
> Sean Christopherson <seanjc@google.com> wrote:
>
> > > > 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.

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.

> 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-29 10:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-27  6:23 [PATCH] x86/asm: Remove unused COMPILE_OFFSETS macro from asm-offsets.c Vincent Mailhol
2022-11-28  9:15 ` Kirill A . Shutemov
2022-11-28 10:11   ` Vincent Mailhol
2022-11-28 11:11     ` kirill.shutemov
2022-11-28 11:30       ` Vincent MAILHOL
2022-11-28 17:45         ` Steven Rostedt
2022-11-28 18:00           ` Paolo Bonzini
2022-11-28 18:06             ` Sean Christopherson
2022-11-28 19:10               ` Steven Rostedt
2022-11-29 10:14                 ` Vincent MAILHOL

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.