public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf kvm stat: Fix build error
@ 2026-02-06 11:00 Leo Yan
  2026-02-26  1:56 ` Namhyung Kim
  0 siblings, 1 reply; 8+ messages in thread
From: Leo Yan @ 2026-02-06 11:00 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark
  Cc: Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel, Leo Yan

Since commit ceea279f9376 ("perf kvm stat: Remove use of the arch
directory"), a native build on Arm64 machine reports:

  util/kvm-stat-arch/kvm-stat-x86.c:7:10: fatal error: asm/svm.h: No such file or directory
    7 | #include <asm/svm.h>
      |          ^~~~~~~~~~~
  compilation terminated.

The build fails to find x86's asm headers when building for Arm64.  Fix
this by including asm headers with relative path instead.

Fixes: ceea279f9376 ("perf kvm stat: Remove use of the arch directory")
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
index 1cf541385a4bdee4930b67a054906ccade7301fd..43275d25b6cbccc477ba45a901d69c67422847ae 100644
--- a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
+++ b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
@@ -4,9 +4,9 @@
 #include "../kvm-stat.h"
 #include "../evsel.h"
 #include "../env.h"
-#include <asm/svm.h>
-#include <asm/vmx.h>
-#include <asm/kvm.h>
+#include "../../arch/x86/include/uapi/asm/svm.h"
+#include "../../arch/x86/include/uapi/asm/vmx.h"
+#include "../../arch/x86/include/uapi/asm/kvm.h"
 #include <subcmd/parse-options.h>
 
 define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS);

---
base-commit: 84cb36da81413c2dff805150b9f4db1524460269
change-id: 20260206-perf_fix_kvm_stat_error-a795a1dd67a2

Best regards,
-- 
Leo Yan <leo.yan@arm.com>


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

* Re: [PATCH] perf kvm stat: Fix build error
  2026-02-06 11:00 [PATCH] perf kvm stat: Fix build error Leo Yan
@ 2026-02-26  1:56 ` Namhyung Kim
  2026-02-26  6:36   ` Ian Rogers
  0 siblings, 1 reply; 8+ messages in thread
From: Namhyung Kim @ 2026-02-26  1:56 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter, James Clark,
	Arnaldo Carvalho de Melo, Leo Yan, linux-perf-users, linux-kernel

Hi Ian,

On Fri, Feb 06, 2026 at 11:00:20AM +0000, Leo Yan wrote:
> Since commit ceea279f9376 ("perf kvm stat: Remove use of the arch
> directory"), a native build on Arm64 machine reports:
> 
>   util/kvm-stat-arch/kvm-stat-x86.c:7:10: fatal error: asm/svm.h: No such file or directory
>     7 | #include <asm/svm.h>
>       |          ^~~~~~~~~~~
>   compilation terminated.
> 
> The build fails to find x86's asm headers when building for Arm64.  Fix
> this by including asm headers with relative path instead.
> 
> Fixes: ceea279f9376 ("perf kvm stat: Remove use of the arch directory")
> Signed-off-by: Leo Yan <leo.yan@arm.com>

Probably not from this patch, but this change seems to introduce this
error on my i386.

  In file included from util/kvm-stat-arch/kvm-stat-x86.c:4:                      
  /linux/tools/include/../../arch/x86/include/uapi/asm/svm.h:137:32: error: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' [-Werror=overflow]
    137 | #define SVM_EXIT_ERR           -1ull                                    
        |                                ^                                        
  util/kvm-stat-arch/kvm-stat-x86.c:13:1: note: in expansion of macro 'define_exit_reasons_table'
     13 | define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS);          
        | ^~~~~~~~~~~~~~~~~~~~~~~~~                                               
  /linux/tools/include/../../arch/x86/include/uapi/asm/svm.h:249:11: note: in expansion of macro 'SVM_EXIT_ERR'
    249 |         { SVM_EXIT_ERR,         "invalid_guest_state" }                 
        |           ^~~~~~~~~~~~                                                  
  util/kvm-stat-arch/kvm-stat-x86.c:13:45: note: in expansion of macro 'SVM_EXIT_REASONS'
     13 | define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS);          
        |                                             ^~~~~~~~~~~~~~~~     

Thanks,
Namhyung

> ---
>  tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
> index 1cf541385a4bdee4930b67a054906ccade7301fd..43275d25b6cbccc477ba45a901d69c67422847ae 100644
> --- a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
> +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
> @@ -4,9 +4,9 @@
>  #include "../kvm-stat.h"
>  #include "../evsel.h"
>  #include "../env.h"
> -#include <asm/svm.h>
> -#include <asm/vmx.h>
> -#include <asm/kvm.h>
> +#include "../../arch/x86/include/uapi/asm/svm.h"
> +#include "../../arch/x86/include/uapi/asm/vmx.h"
> +#include "../../arch/x86/include/uapi/asm/kvm.h"
>  #include <subcmd/parse-options.h>
>  
>  define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS);
> 
> ---
> base-commit: 84cb36da81413c2dff805150b9f4db1524460269
> change-id: 20260206-perf_fix_kvm_stat_error-a795a1dd67a2
> 
> Best regards,
> -- 
> Leo Yan <leo.yan@arm.com>
> 

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

* Re: [PATCH] perf kvm stat: Fix build error
  2026-02-26  1:56 ` Namhyung Kim
@ 2026-02-26  6:36   ` Ian Rogers
  2026-02-26  9:52     ` Leo Yan
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Rogers @ 2026-02-26  6:36 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter, James Clark,
	Arnaldo Carvalho de Melo, Leo Yan, linux-perf-users, linux-kernel

On Wed, Feb 25, 2026 at 5:56 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hi Ian,
>
> On Fri, Feb 06, 2026 at 11:00:20AM +0000, Leo Yan wrote:
> > Since commit ceea279f9376 ("perf kvm stat: Remove use of the arch
> > directory"), a native build on Arm64 machine reports:
> >
> >   util/kvm-stat-arch/kvm-stat-x86.c:7:10: fatal error: asm/svm.h: No such file or directory
> >     7 | #include <asm/svm.h>
> >       |          ^~~~~~~~~~~
> >   compilation terminated.
> >
> > The build fails to find x86's asm headers when building for Arm64.  Fix
> > this by including asm headers with relative path instead.
> >
> > Fixes: ceea279f9376 ("perf kvm stat: Remove use of the arch directory")
> > Signed-off-by: Leo Yan <leo.yan@arm.com>
>
> Probably not from this patch, but this change seems to introduce this
> error on my i386.
>
>   In file included from util/kvm-stat-arch/kvm-stat-x86.c:4:
>   /linux/tools/include/../../arch/x86/include/uapi/asm/svm.h:137:32: error: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' [-Werror=overflow]
>     137 | #define SVM_EXIT_ERR           -1ull
>         |                                ^
>   util/kvm-stat-arch/kvm-stat-x86.c:13:1: note: in expansion of macro 'define_exit_reasons_table'
>      13 | define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS);
>         | ^~~~~~~~~~~~~~~~~~~~~~~~~
>   /linux/tools/include/../../arch/x86/include/uapi/asm/svm.h:249:11: note: in expansion of macro 'SVM_EXIT_ERR'
>     249 |         { SVM_EXIT_ERR,         "invalid_guest_state" }
>         |           ^~~~~~~~~~~~
>   util/kvm-stat-arch/kvm-stat-x86.c:13:45: note: in expansion of macro 'SVM_EXIT_REASONS'
>      13 | define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS);
>         |                                             ^~~~~~~~~~~~~~~~

Hmm.. it looks like something has gone screwy with the include paths.
The header you've gotten is:
https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/arch/x86/include/uapi/asm/svm.h#n137
rather than:
https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/arch/x86/include/uapi/asm/svm.h#n137
where the value differs between -1ull and -1.

In Leo's change he has the include path as:
  #include "../../arch/x86/include/uapi/asm/svm.h"

but I think that is off by one and should be:
  #include "../../../arch/x86/include/uapi/asm/svm.h"

Making the include path this should prioritize finding the tool's
version of the file over using the include paths. Could you try adding
the missing "../" to the paths, I wasn't able to reproduce locally
building with -m32.

Longer term maybe a macro like UINT64_C should be used to avoid these
kinds of long long vs long problems.

Thanks,
Ian


> Thanks,
> Namhyung
>
> > ---
> >  tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
> > index 1cf541385a4bdee4930b67a054906ccade7301fd..43275d25b6cbccc477ba45a901d69c67422847ae 100644
> > --- a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
> > +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
> > @@ -4,9 +4,9 @@
> >  #include "../kvm-stat.h"
> >  #include "../evsel.h"
> >  #include "../env.h"
> > -#include <asm/svm.h>
> > -#include <asm/vmx.h>
> > -#include <asm/kvm.h>
> > +#include "../../arch/x86/include/uapi/asm/svm.h"
> > +#include "../../arch/x86/include/uapi/asm/vmx.h"
> > +#include "../../arch/x86/include/uapi/asm/kvm.h"
> >  #include <subcmd/parse-options.h>
> >
> >  define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS);
> >
> > ---
> > base-commit: 84cb36da81413c2dff805150b9f4db1524460269
> > change-id: 20260206-perf_fix_kvm_stat_error-a795a1dd67a2
> >
> > Best regards,
> > --
> > Leo Yan <leo.yan@arm.com>
> >

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

* Re: [PATCH] perf kvm stat: Fix build error
  2026-02-26  6:36   ` Ian Rogers
@ 2026-02-26  9:52     ` Leo Yan
  2026-02-26 16:44       ` Ian Rogers
  0 siblings, 1 reply; 8+ messages in thread
From: Leo Yan @ 2026-02-26  9:52 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Namhyung Kim, Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter,
	James Clark, Arnaldo Carvalho de Melo, linux-perf-users,
	linux-kernel

On Wed, Feb 25, 2026 at 10:36:26PM -0800, Ian Rogers wrote:

[...]

> Hmm.. it looks like something has gone screwy with the include paths.
> The header you've gotten is:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/arch/x86/include/uapi/asm/svm.h#n137
> rather than:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/arch/x86/include/uapi/asm/svm.h#n137
> where the value differs between -1ull and -1.
> 
> In Leo's change he has the include path as:
>   #include "../../arch/x86/include/uapi/asm/svm.h"
> 
> but I think that is off by one and should be:
>   #include "../../../arch/x86/include/uapi/asm/svm.h"

Sorry I did not check the header path carefully.  A bit thoughts:

The perf build will not include headers in relative paths as we
expected.

It tries to find headers with appending search paths.  As Ian said,
I saw .kvm-stat-x86.o.cmd that includes kernel headers:

  /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/svm.h \
  /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/vmx.h \
  /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/kvm.h \

I'd suggest a fix in Makefile as below.  The idea is to give priority to
the lower level folders under perf, so that headers in the deeper perf
directories are searched first.  This avoids searching any kernel headers.

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index a8dc72cfe48e..47359f672b6a 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -388,8 +388,10 @@ ifeq ($(DEBUG),0)
   endif
 endif

-INC_FLAGS += -I$(src-perf)/util/include
 INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
+INC_FLAGS += -I$(src-perf)/util/include
+INC_FLAGS += -I$(src-perf)/util
+INC_FLAGS += -I$(src-perf)
 INC_FLAGS += -I$(srctree)/tools/include/
 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
 INC_FLAGS += -I$(srctree)/tools/include/uapi
@@ -403,9 +405,6 @@ INC_FLAGS += -I$(obj-perf)/util
 INC_FLAGS += -I$(obj-perf)
 endif

-INC_FLAGS += -I$(src-perf)/util
-INC_FLAGS += -I$(src-perf)
-
 CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_

As a result, I can get the search paths in .kvm-stat-x86.o.cmd:

  /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/svm.h \
  /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/vmx.h \
  /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/kvm.h \

Please let me know if this makes sense.

Thanks,
Leo

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

* Re: [PATCH] perf kvm stat: Fix build error
  2026-02-26  9:52     ` Leo Yan
@ 2026-02-26 16:44       ` Ian Rogers
  2026-02-27  7:32         ` Namhyung Kim
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Rogers @ 2026-02-26 16:44 UTC (permalink / raw)
  To: Leo Yan
  Cc: Namhyung Kim, Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter,
	James Clark, Arnaldo Carvalho de Melo, linux-perf-users,
	linux-kernel

On Thu, Feb 26, 2026 at 1:52 AM Leo Yan <leo.yan@arm.com> wrote:
>
> On Wed, Feb 25, 2026 at 10:36:26PM -0800, Ian Rogers wrote:
>
> [...]
>
> > Hmm.. it looks like something has gone screwy with the include paths.
> > The header you've gotten is:
> > https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/arch/x86/include/uapi/asm/svm.h#n137
> > rather than:
> > https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/arch/x86/include/uapi/asm/svm.h#n137
> > where the value differs between -1ull and -1.
> >
> > In Leo's change he has the include path as:
> >   #include "../../arch/x86/include/uapi/asm/svm.h"
> >
> > but I think that is off by one and should be:
> >   #include "../../../arch/x86/include/uapi/asm/svm.h"
>
> Sorry I did not check the header path carefully.  A bit thoughts:
>
> The perf build will not include headers in relative paths as we
> expected.
>
> It tries to find headers with appending search paths.  As Ian said,
> I saw .kvm-stat-x86.o.cmd that includes kernel headers:
>
>   /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/svm.h \
>   /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/vmx.h \
>   /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/kvm.h \
>
> I'd suggest a fix in Makefile as below.  The idea is to give priority to
> the lower level folders under perf, so that headers in the deeper perf
> directories are searched first.  This avoids searching any kernel headers.

I'm not opposed to the change but I still think we should make the
relative include be to the correct files. Some other thoughts below.

> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index a8dc72cfe48e..47359f672b6a 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -388,8 +388,10 @@ ifeq ($(DEBUG),0)
>    endif
>  endif
>
> -INC_FLAGS += -I$(src-perf)/util/include

Not clear to me why we need a util/include on top of everything else.
It seems somewhat random what is in util/include rather than just in
util.

>  INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include

Hopefully with the removal of the arch directory (and fixing of
cross-platform profiling) in slow chunks by changes like:
https://lore.kernel.org/lkml/20260224142938.26088-1-irogers@google.com/
we can get rid of this one.

> +INC_FLAGS += -I$(src-perf)/util/include
> +INC_FLAGS += -I$(src-perf)/util
> +INC_FLAGS += -I$(src-perf)

This:

>  INC_FLAGS += -I$(srctree)/tools/include/
>  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
>  INC_FLAGS += -I$(srctree)/tools/include/uapi

to here means that we prefer linux headers over uapi headers, which I
think is the opposite of what a user-land process would expect. I
think we should move these headers into two libraries, build them with
an `install_headers` rule, and make the include path pick up the
headers from where they are installed. As the linux and uapi headers
are licensed differently, this would clarify the dependencies and
licensing implications.

There's another can of worms regarding whether libperf is something
useful, outside of declarations in event.h.

Thanks,
Ian

> @@ -403,9 +405,6 @@ INC_FLAGS += -I$(obj-perf)/util
>  INC_FLAGS += -I$(obj-perf)
>  endif
>
> -INC_FLAGS += -I$(src-perf)/util
> -INC_FLAGS += -I$(src-perf)
> -
>  CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_
>
> As a result, I can get the search paths in .kvm-stat-x86.o.cmd:
>
>   /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/svm.h \
>   /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/vmx.h \
>   /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/kvm.h \
>
> Please let me know if this makes sense.
>
> Thanks,
> Leo

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

* Re: [PATCH] perf kvm stat: Fix build error
  2026-02-26 16:44       ` Ian Rogers
@ 2026-02-27  7:32         ` Namhyung Kim
  2026-02-27 17:30           ` Ian Rogers
  0 siblings, 1 reply; 8+ messages in thread
From: Namhyung Kim @ 2026-02-27  7:32 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Leo Yan, Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter,
	James Clark, Arnaldo Carvalho de Melo, linux-perf-users,
	linux-kernel

On Thu, Feb 26, 2026 at 08:44:51AM -0800, Ian Rogers wrote:
> On Thu, Feb 26, 2026 at 1:52 AM Leo Yan <leo.yan@arm.com> wrote:
> >
> > On Wed, Feb 25, 2026 at 10:36:26PM -0800, Ian Rogers wrote:
> >
> > [...]
> >
> > > Hmm.. it looks like something has gone screwy with the include paths.
> > > The header you've gotten is:
> > > https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/arch/x86/include/uapi/asm/svm.h#n137
> > > rather than:
> > > https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/arch/x86/include/uapi/asm/svm.h#n137
> > > where the value differs between -1ull and -1.
> > >
> > > In Leo's change he has the include path as:
> > >   #include "../../arch/x86/include/uapi/asm/svm.h"
> > >
> > > but I think that is off by one and should be:
> > >   #include "../../../arch/x86/include/uapi/asm/svm.h"
> >
> > Sorry I did not check the header path carefully.  A bit thoughts:
> >
> > The perf build will not include headers in relative paths as we
> > expected.
> >
> > It tries to find headers with appending search paths.  As Ian said,
> > I saw .kvm-stat-x86.o.cmd that includes kernel headers:
> >
> >   /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/svm.h \
> >   /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/vmx.h \
> >   /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/kvm.h \
> >
> > I'd suggest a fix in Makefile as below.  The idea is to give priority to
> > the lower level folders under perf, so that headers in the deeper perf
> > directories are searched first.  This avoids searching any kernel headers.

It fixes the problem, thanks!

Tested-by: Namhyung Kim <namhyung@kernel.org>

More comments below.

> 
> I'm not opposed to the change but I still think we should make the
> relative include be to the correct files. Some other thoughts below.
> 
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index a8dc72cfe48e..47359f672b6a 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -388,8 +388,10 @@ ifeq ($(DEBUG),0)
> >    endif
> >  endif
> >
> > -INC_FLAGS += -I$(src-perf)/util/include
> 
> Not clear to me why we need a util/include on top of everything else.
> It seems somewhat random what is in util/include rather than just in
> util.

It seems it tries to override some kernel headers but I'm curious we can
move the files to the tools/include and get rid of the directory.

> 
> >  INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
> 
> Hopefully with the removal of the arch directory (and fixing of
> cross-platform profiling) in slow chunks by changes like:
> https://lore.kernel.org/lkml/20260224142938.26088-1-irogers@google.com/
> we can get rid of this one.
> 
> > +INC_FLAGS += -I$(src-perf)/util/include
> > +INC_FLAGS += -I$(src-perf)/util

I also hope to remove $(src-perf)/util too and use path relative to
$(src-perf) always for perf-specific headers.  But this is a separate
topic.


> > +INC_FLAGS += -I$(src-perf)
> 
> This:
> 
> >  INC_FLAGS += -I$(srctree)/tools/include/
> >  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
> >  INC_FLAGS += -I$(srctree)/tools/include/uapi
> 
> to here means that we prefer linux headers over uapi headers, which I
> think is the opposite of what a user-land process would expect. I
> think we should move these headers into two libraries, build them with
> an `install_headers` rule, and make the include path pick up the
> headers from where they are installed. As the linux and uapi headers
> are licensed differently, this would clarify the dependencies and
> licensing implications.

Sounds good.

Thanks,
Namhyung

> 
> There's another can of worms regarding whether libperf is something
> useful, outside of declarations in event.h.
> 
> Thanks,
> Ian
> 
> > @@ -403,9 +405,6 @@ INC_FLAGS += -I$(obj-perf)/util
> >  INC_FLAGS += -I$(obj-perf)
> >  endif
> >
> > -INC_FLAGS += -I$(src-perf)/util
> > -INC_FLAGS += -I$(src-perf)
> > -
> >  CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_
> >
> > As a result, I can get the search paths in .kvm-stat-x86.o.cmd:
> >
> >   /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/svm.h \
> >   /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/vmx.h \
> >   /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/kvm.h \
> >
> > Please let me know if this makes sense.
> >
> > Thanks,
> > Leo

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

* Re: [PATCH] perf kvm stat: Fix build error
  2026-02-27  7:32         ` Namhyung Kim
@ 2026-02-27 17:30           ` Ian Rogers
  2026-03-01 17:45             ` Leo Yan
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Rogers @ 2026-02-27 17:30 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Leo Yan, Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter,
	James Clark, Arnaldo Carvalho de Melo, linux-perf-users,
	linux-kernel

On Thu, Feb 26, 2026 at 11:32 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Thu, Feb 26, 2026 at 08:44:51AM -0800, Ian Rogers wrote:
> > On Thu, Feb 26, 2026 at 1:52 AM Leo Yan <leo.yan@arm.com> wrote:
> > >
> > > On Wed, Feb 25, 2026 at 10:36:26PM -0800, Ian Rogers wrote:
> > >
> > > [...]
> > >
> > > > Hmm.. it looks like something has gone screwy with the include paths.
> > > > The header you've gotten is:
> > > > https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/arch/x86/include/uapi/asm/svm.h#n137
> > > > rather than:
> > > > https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/arch/x86/include/uapi/asm/svm.h#n137
> > > > where the value differs between -1ull and -1.
> > > >
> > > > In Leo's change he has the include path as:
> > > >   #include "../../arch/x86/include/uapi/asm/svm.h"
> > > >
> > > > but I think that is off by one and should be:
> > > >   #include "../../../arch/x86/include/uapi/asm/svm.h"
> > >
> > > Sorry I did not check the header path carefully.  A bit thoughts:
> > >
> > > The perf build will not include headers in relative paths as we
> > > expected.
> > >
> > > It tries to find headers with appending search paths.  As Ian said,
> > > I saw .kvm-stat-x86.o.cmd that includes kernel headers:
> > >
> > >   /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/svm.h \
> > >   /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/vmx.h \
> > >   /home/niayan01/Work/linux/tools/include/../../arch/x86/include/uapi/asm/kvm.h \
> > >
> > > I'd suggest a fix in Makefile as below.  The idea is to give priority to
> > > the lower level folders under perf, so that headers in the deeper perf
> > > directories are searched first.  This avoids searching any kernel headers.
>
> It fixes the problem, thanks!
>
> Tested-by: Namhyung Kim <namhyung@kernel.org>

So it is still the wrong fix. The relative include paths is the real
issue, just add the missing "../". I'm not a fan of changing the
include order as it has the potential to break things due to the
subtle way that includes are picked up, tools/include isn't hermetic,
etc. While it may fix one build failure we are likely creating build
failures for others - well me, with bazel, for sure.

Thanks,
Ian


> More comments below.
>
> >
> > I'm not opposed to the change but I still think we should make the
> > relative include be to the correct files. Some other thoughts below.
> >
> > > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > > index a8dc72cfe48e..47359f672b6a 100644
> > > --- a/tools/perf/Makefile.config
> > > +++ b/tools/perf/Makefile.config
> > > @@ -388,8 +388,10 @@ ifeq ($(DEBUG),0)
> > >    endif
> > >  endif
> > >
> > > -INC_FLAGS += -I$(src-perf)/util/include
> >
> > Not clear to me why we need a util/include on top of everything else.
> > It seems somewhat random what is in util/include rather than just in
> > util.
>
> It seems it tries to override some kernel headers but I'm curious we can
> move the files to the tools/include and get rid of the directory.
>
> >
> > >  INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include
> >
> > Hopefully with the removal of the arch directory (and fixing of
> > cross-platform profiling) in slow chunks by changes like:
> > https://lore.kernel.org/lkml/20260224142938.26088-1-irogers@google.com/
> > we can get rid of this one.
> >
> > > +INC_FLAGS += -I$(src-perf)/util/include
> > > +INC_FLAGS += -I$(src-perf)/util
>
> I also hope to remove $(src-perf)/util too and use path relative to
> $(src-perf) always for perf-specific headers.  But this is a separate
> topic.
>
>
> > > +INC_FLAGS += -I$(src-perf)
> >
> > This:
> >
> > >  INC_FLAGS += -I$(srctree)/tools/include/
> > >  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
> > >  INC_FLAGS += -I$(srctree)/tools/include/uapi
> >
> > to here means that we prefer linux headers over uapi headers, which I
> > think is the opposite of what a user-land process would expect. I
> > think we should move these headers into two libraries, build them with
> > an `install_headers` rule, and make the include path pick up the
> > headers from where they are installed. As the linux and uapi headers
> > are licensed differently, this would clarify the dependencies and
> > licensing implications.
>
> Sounds good.
>
> Thanks,
> Namhyung
>
> >
> > There's another can of worms regarding whether libperf is something
> > useful, outside of declarations in event.h.
> >
> > Thanks,
> > Ian
> >
> > > @@ -403,9 +405,6 @@ INC_FLAGS += -I$(obj-perf)/util
> > >  INC_FLAGS += -I$(obj-perf)
> > >  endif
> > >
> > > -INC_FLAGS += -I$(src-perf)/util
> > > -INC_FLAGS += -I$(src-perf)
> > > -
> > >  CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_
> > >
> > > As a result, I can get the search paths in .kvm-stat-x86.o.cmd:
> > >
> > >   /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/svm.h \
> > >   /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/vmx.h \
> > >   /home/niayan01/Work/linux/tools/perf/util/../../arch/x86/include/uapi/asm/kvm.h \
> > >
> > > Please let me know if this makes sense.
> > >
> > > Thanks,
> > > Leo

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

* Re: [PATCH] perf kvm stat: Fix build error
  2026-02-27 17:30           ` Ian Rogers
@ 2026-03-01 17:45             ` Leo Yan
  0 siblings, 0 replies; 8+ messages in thread
From: Leo Yan @ 2026-03-01 17:45 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Namhyung Kim, Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter,
	James Clark, Arnaldo Carvalho de Melo, linux-perf-users,
	linux-kernel

On Fri, Feb 27, 2026 at 09:30:56AM -0800, Ian Rogers wrote:

[...]

> So it is still the wrong fix. The relative include paths is the real
> issue, just add the missing "../". I'm not a fan of changing the
> include order as it has the potential to break things due to the
> subtle way that includes are picked up, tools/include isn't hermetic,
> etc. While it may fix one build failure we are likely creating build
> failures for others - well me, with bazel, for sure.

Thanks for correcting me. I have sent a patch to fix the relative paths.

Leo

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

end of thread, other threads:[~2026-03-01 17:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-06 11:00 [PATCH] perf kvm stat: Fix build error Leo Yan
2026-02-26  1:56 ` Namhyung Kim
2026-02-26  6:36   ` Ian Rogers
2026-02-26  9:52     ` Leo Yan
2026-02-26 16:44       ` Ian Rogers
2026-02-27  7:32         ` Namhyung Kim
2026-02-27 17:30           ` Ian Rogers
2026-03-01 17:45             ` Leo Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox