Skip to contentSkip to conversation

perf kvm stat: Fix build error

PATCH In review Leo Yan 3 participants 8 messages Feb 6 – Mar 1 perf events

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

PATCH 1/1 perf kvm stat: Fix build error

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")
---
 tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/kvm-stat-arch/kvm-stat-x86.c +3 -3
index 1cf541385a4bdee4930b67a054906ccade7301fd..43275d25b6cbccc477ba45a901d69c67422847ae 100644
@@ -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,

Signature · 1 line
Leo Yan <[email protected]>
maintainer
#1 lore raw

Hi Ian,

Quoted 6 lines · 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>
      |          ^~~~~~~~~~~
Quoted 7 lines

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

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

Quoted 30 lines
---
 tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/kvm-stat-arch/kvm-stat-x86.c +3 -4
index 1cf541385a4bdee4930b67a054906ccade7301fd..43275d25b6cbccc477ba45a901d69c67422847ae 100644
@@ -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,

Signature · 1 line
Leo Yan <[email protected]>
reviewer
#2 lore raw
Quoted 23 lines · Namhyung Kim

Hi Ian,

Quoted 6 lines · 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>
      |          ^~~~~~~~~~~
Quoted 7 lines

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

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]

Quoted 11 lines
    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

Quoted 33 lines

Thanks,
Namhyung

Quoted 30 lines
---
 tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/kvm-stat-arch/kvm-stat-x86.c +3 -4
index 1cf541385a4bdee4930b67a054906ccade7301fd..43275d25b6cbccc477ba45a901d69c67422847ae 100644
@@ -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 <[email protected]>

author
#3 lore raw

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

[...]

Quoted 7 lines

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.

Quoted 5 lines

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.

tools/perf/Makefile.config +3 -4
index a8dc72cfe48e..47359f672b6a 100644
@@ -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

reviewer
#4 lore raw
Quoted 26 lines · Leo Yan

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

[...]

Quoted 7 lines

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.

Quoted 5 lines

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:

Quoted 7 lines
  /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.

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 391

Quoted 9 lines
tools/perf/Makefile.config +0 -1
index a8dc72cfe48e..47359f672b6a 100644
@@ -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.

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 391

Quoted 1 line
tools/perf/Makefile.config +0 -0
 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/[email protected]/
we can get rid of this one.

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 394

Quoted 3 lines
tools/perf/Makefile.config +3 -0
+INC_FLAGS += -I$(src-perf)/util/include
+INC_FLAGS += -I$(src-perf)/util
+INC_FLAGS += -I$(src-perf)

This:

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 397

Quoted 3 lines
tools/perf/Makefile.config +0 -0
 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

Quoted 19 lines
tools/perf/Makefile.config +0 -3
@@ -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

maintainer Tested-by
#5 lore raw
Quoted 27 lines · Ian Rogers
Quoted 26 lines · Leo Yan

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

[...]

Quoted 7 lines

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.

Quoted 5 lines

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:

Quoted 7 lines
Quoted 7 lines
  /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!

More comments below.

Quoted 12 lines

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.

Quoted 8 lines
tools/perf/Makefile.config +0 -0
index a8dc72cfe48e..47359f672b6a 100644
@@ -388,8 +388,10 @@ ifeq ($(DEBUG),0)
   endif
 endif
 
Quoted 5 lines

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 391

Quoted 1 line
tools/perf/Makefile.config +0 -1
-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.

Quoted 10 lines

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 391

Quoted 2 lines
tools/perf/Makefile.config +0 -0
 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/[email protected]/
we can get rid of this one.

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 393

Quoted 2 lines
tools/perf/Makefile.config +2 -0
+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.

Quoted 8 lines

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 394

Quoted 1 line
tools/perf/Makefile.config +1 -0
+INC_FLAGS += -I$(src-perf)

This:

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 397

Quoted 3 lines
tools/perf/Makefile.config +0 -0
 INC_FLAGS += -I$(srctree)/tools/include/
 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
 INC_FLAGS += -I$(srctree)/tools/include/uapi
Quoted 7 lines

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

Quoted 26 lines

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

Thanks,
Ian

Quoted 19 lines
tools/perf/Makefile.config +0 -3
@@ -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

reviewer
#6 lore raw
Quoted 33 lines · Namhyung Kim
Quoted 31 lines · Ian Rogers
Quoted 30 lines · Leo Yan

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

[...]

Quoted 7 lines

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.

Quoted 5 lines

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 \
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

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!

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

Quoted 86 lines

More comments below.

Quoted 12 lines

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.

Quoted 8 lines
tools/perf/Makefile.config +0 -0
index a8dc72cfe48e..47359f672b6a 100644
@@ -388,8 +388,10 @@ ifeq ($(DEBUG),0)
   endif
 endif
 
Quoted 5 lines

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 391

Quoted 1 line
tools/perf/Makefile.config +0 -1
-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.

Quoted 10 lines

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 391

Quoted 2 lines
tools/perf/Makefile.config +0 -0
 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/[email protected]/
we can get rid of this one.

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 393

Quoted 2 lines
tools/perf/Makefile.config +2 -0
+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.

Quoted 8 lines

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 394

Quoted 1 line
tools/perf/Makefile.config +1 -0
+INC_FLAGS += -I$(src-perf)

This:

tools/perf/Makefile.config ifeq ($(DEBUG),0) · line 397

Quoted 3 lines
tools/perf/Makefile.config +0 -0
 INC_FLAGS += -I$(srctree)/tools/include/
 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
 INC_FLAGS += -I$(srctree)/tools/include/uapi
Quoted 7 lines

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

Quoted 26 lines

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

Thanks,
Ian

Quoted 19 lines
tools/perf/Makefile.config +0 -3
@@ -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

author
#7 lore raw

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

[...]

Quoted 6 lines

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