From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Leo Yan <leo.yan@arm.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf kvm stat: Fix build error
Date: Thu, 26 Feb 2026 23:32:17 -0800 [thread overview]
Message-ID: <aaFIgR29wGYvHnVp@google.com> (raw)
In-Reply-To: <CAP-5=fUAK=vzeZWDXuun+wptSeBwUMhZuVqdh4zwLoXoV32VPA@mail.gmail.com>
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
next prev parent reply other threads:[~2026-02-27 7:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-02-27 17:30 ` Ian Rogers
2026-03-01 17:45 ` Leo Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aaFIgR29wGYvHnVp@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.