diff mbox series

perf: fix build with latest kernel

Message ID 20231106195219.3851918-1-max.oss.09@gmail.com
State Accepted, archived
Commit 432b4ac20dadb9c08596266fce4f3941d4856c7e
Headers show
Series perf: fix build with latest kernel | expand

Commit Message

Max Krummenacher Nov. 6, 2023, 7:52 p.m. UTC
From: Max Krummenacher <max.krummenacher@toradex.com>

Kernel 6.7-rc1 commit 02e85f74668e ("tools: arm64: Add a Makefile for
generating sysreg-defs.h") uses files from arch/arm64/tools/,
gen-sysreg.awk and sysreg.
Without the files the build of perf fails independent of the used
architecture (confirmed with armv7 and qemux86_64).

As arch/arm64/tools/ has been added with 5.13 allow perf to build
even it that directory does not exist.

Add arch/arm64/tools/ to PERF_SRC.

Fixes:
| make[3]: *** No rule to make target '.../qemux86_64-tdx-linux/perf/1.0/perf-1.0/arch/arm64/tools/gen-sysreg.awk', needed by '.../qemux86_64-tdx-linux/perf/1.0/perf-1.0/tools/arch/arm64/include/generated/asm/sysreg-defs.h'.  Stop.
| make[2]: *** [Makefile.perf:456: arm64-sysreg-defs] Error 2

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
---
 meta/recipes-kernel/perf/perf.bb | 5 +++++
 1 file changed, 5 insertions(+)

Hi all

I see some other options:
- drop perf support for kernels<5.13 and simply add to PERF_SRC
- drop the bb.fatal in favour of continue and simply add to PERF_SRC

Any comments?

Thanks.
Max

Comments

Bruce Ashfield Nov. 6, 2023, 8:04 p.m. UTC | #1
On Mon, Nov 6, 2023 at 2:53 PM Max Krummenacher <max.oss.09@gmail.com> wrote:
>
> From: Max Krummenacher <max.krummenacher@toradex.com>
>
> Kernel 6.7-rc1 commit 02e85f74668e ("tools: arm64: Add a Makefile for
> generating sysreg-defs.h") uses files from arch/arm64/tools/,
> gen-sysreg.awk and sysreg.
> Without the files the build of perf fails independent of the used
> architecture (confirmed with armv7 and qemux86_64).
>
> As arch/arm64/tools/ has been added with 5.13 allow perf to build
> even it that directory does not exist.
>
> Add arch/arm64/tools/ to PERF_SRC.
>
> Fixes:
> | make[3]: *** No rule to make target '.../qemux86_64-tdx-linux/perf/1.0/perf-1.0/arch/arm64/tools/gen-sysreg.awk', needed by '.../qemux86_64-tdx-linux/perf/1.0/perf-1.0/tools/arch/arm64/include/generated/asm/sysreg-defs.h'.  Stop.
> | make[2]: *** [Makefile.perf:456: arm64-sysreg-defs] Error 2
>
> Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
> ---
>  meta/recipes-kernel/perf/perf.bb | 5 +++++
>  1 file changed, 5 insertions(+)
>
> Hi all
>
> I see some other options:
> - drop perf support for kernels<5.13 and simply add to PERF_SRC
> - drop the bb.fatal in favour of continue and simply add to PERF_SRC
>
> Any comments?

I just ran into this myself while updating linux-yocto-dev

What you have is better than either of those options, but different
from what I was working on.

perf already uses KERNEL_VERSION, so I was adding some KERNEL_VERSION
specific sources and only copying them when they match.

I'm concerned that skipping or always allowing files to not exist will
lead us to more subtle errors with invalid/incorrect kernel source trees.

Another idea I had is to just skip if sources don't exist (like we do in
devsrc), but bb.warn so the user is aware.

Bruce

>
> Thanks.
> Max
>
>
> diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
> index 675acfaf26..dae9320169 100644
> --- a/meta/recipes-kernel/perf/perf.bb
> +++ b/meta/recipes-kernel/perf/perf.bb
> @@ -117,6 +117,7 @@ EXTRA_OEMAKE += "\
>  # honour a JOBS variable.
>  EXTRA_OEMAKE:append:task-configure = " JOBS=1"
>
> +PERF_SRC_OPTIONAL ?= "arch/arm64/tools"
>  PERF_SRC ?= "Makefile \
>               tools/arch \
>               tools/build \
> @@ -127,6 +128,7 @@ PERF_SRC ?= "Makefile \
>               tools/scripts \
>               scripts/ \
>               arch/${ARCH}/Makefile \
> +             ${PERF_SRC_OPTIONAL} \
>  "
>
>  PERF_EXTRA_LDFLAGS = ""
> @@ -162,6 +164,7 @@ do_install() {
>
>  do_configure[prefuncs] += "copy_perf_source_from_kernel"
>  python copy_perf_source_from_kernel() {
> +    sources_opt = (d.getVar("PERF_SRC_OPTIONAL") or "").split()
>      sources = (d.getVar("PERF_SRC") or "").split()
>      src_dir = d.getVar("STAGING_KERNEL_DIR")
>      dest_dir = d.getVar("S")
> @@ -171,6 +174,8 @@ python copy_perf_source_from_kernel() {
>          src = oe.path.join(src_dir, s)
>          dest = oe.path.join(dest_dir, s)
>          if not os.path.exists(src):
> +            if s in sources_opt:
> +                continue
>              bb.fatal("Path does not exist: %s. Maybe PERF_SRC does not match the kernel version." % src)
>          if os.path.isdir(src):
>              oe.path.copyhardlinktree(src, dest)
> --
> 2.35.3
>
Max Krummenacher Nov. 6, 2023, 8:40 p.m. UTC | #2
On Mon, Nov 6, 2023 at 9:04 PM Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
>
> On Mon, Nov 6, 2023 at 2:53 PM Max Krummenacher <max.oss.09@gmail.com> wrote:
> >
> > From: Max Krummenacher <max.krummenacher@toradex.com>
> >
> > Kernel 6.7-rc1 commit 02e85f74668e ("tools: arm64: Add a Makefile for
> > generating sysreg-defs.h") uses files from arch/arm64/tools/,
> > gen-sysreg.awk and sysreg.
> > Without the files the build of perf fails independent of the used
> > architecture (confirmed with armv7 and qemux86_64).
> >
> > As arch/arm64/tools/ has been added with 5.13 allow perf to build
> > even it that directory does not exist.
> >
> > Add arch/arm64/tools/ to PERF_SRC.
> >
> > Fixes:
> > | make[3]: *** No rule to make target '.../qemux86_64-tdx-linux/perf/1.0/perf-1.0/arch/arm64/tools/gen-sysreg.awk', needed by '.../qemux86_64-tdx-linux/perf/1.0/perf-1.0/tools/arch/arm64/include/generated/asm/sysreg-defs.h'.  Stop.
> > | make[2]: *** [Makefile.perf:456: arm64-sysreg-defs] Error 2
> >
> > Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
> > ---
> >  meta/recipes-kernel/perf/perf.bb | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > Hi all
> >
> > I see some other options:
> > - drop perf support for kernels<5.13 and simply add to PERF_SRC
> > - drop the bb.fatal in favour of continue and simply add to PERF_SRC
> >
> > Any comments?
>
> I just ran into this myself while updating linux-yocto-dev
>
> What you have is better than either of those options, but different
> from what I was working on.
>
> perf already uses KERNEL_VERSION, so I was adding some KERNEL_VERSION
> specific sources and only copying them when they match.
>
> I'm concerned that skipping or always allowing files to not exist will
> lead us to more subtle errors with invalid/incorrect kernel source trees.
>
> Another idea I had is to just skip if sources don't exist (like we do in
> devsrc), but bb.warn so the user is aware.

I can change the commit to:
- just add to PERF_SRC
- change the bb.fatal to bb.warn with the existing error string
- add a 'continue' after the bb.warn

Does that sound like a plan?

Max
>
> Bruce
>
> >
> > Thanks.
> > Max
> >
> >
> > diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
> > index 675acfaf26..dae9320169 100644
> > --- a/meta/recipes-kernel/perf/perf.bb
> > +++ b/meta/recipes-kernel/perf/perf.bb
> > @@ -117,6 +117,7 @@ EXTRA_OEMAKE += "\
> >  # honour a JOBS variable.
> >  EXTRA_OEMAKE:append:task-configure = " JOBS=1"
> >
> > +PERF_SRC_OPTIONAL ?= "arch/arm64/tools"
> >  PERF_SRC ?= "Makefile \
> >               tools/arch \
> >               tools/build \
> > @@ -127,6 +128,7 @@ PERF_SRC ?= "Makefile \
> >               tools/scripts \
> >               scripts/ \
> >               arch/${ARCH}/Makefile \
> > +             ${PERF_SRC_OPTIONAL} \
> >  "
> >
> >  PERF_EXTRA_LDFLAGS = ""
> > @@ -162,6 +164,7 @@ do_install() {
> >
> >  do_configure[prefuncs] += "copy_perf_source_from_kernel"
> >  python copy_perf_source_from_kernel() {
> > +    sources_opt = (d.getVar("PERF_SRC_OPTIONAL") or "").split()
> >      sources = (d.getVar("PERF_SRC") or "").split()
> >      src_dir = d.getVar("STAGING_KERNEL_DIR")
> >      dest_dir = d.getVar("S")
> > @@ -171,6 +174,8 @@ python copy_perf_source_from_kernel() {
> >          src = oe.path.join(src_dir, s)
> >          dest = oe.path.join(dest_dir, s)
> >          if not os.path.exists(src):
> > +            if s in sources_opt:
> > +                continue
> >              bb.fatal("Path does not exist: %s. Maybe PERF_SRC does not match the kernel version." % src)
> >          if os.path.isdir(src):
> >              oe.path.copyhardlinktree(src, dest)
> > --
> > 2.35.3
> >
>
>
> --
> - Thou shalt not follow the NULL pointer, for chaos and madness await
> thee at its end
> - "Use the force Harry" - Gandalf, Star Trek II
Bruce Ashfield Nov. 7, 2023, 12:19 a.m. UTC | #3
On Mon, Nov 6, 2023 at 3:40 PM Max Krummenacher <max.oss.09@gmail.com> wrote:
>
> On Mon, Nov 6, 2023 at 9:04 PM Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
> >
> > On Mon, Nov 6, 2023 at 2:53 PM Max Krummenacher <max.oss.09@gmail.com> wrote:
> > >
> > > From: Max Krummenacher <max.krummenacher@toradex.com>
> > >
> > > Kernel 6.7-rc1 commit 02e85f74668e ("tools: arm64: Add a Makefile for
> > > generating sysreg-defs.h") uses files from arch/arm64/tools/,
> > > gen-sysreg.awk and sysreg.
> > > Without the files the build of perf fails independent of the used
> > > architecture (confirmed with armv7 and qemux86_64).
> > >
> > > As arch/arm64/tools/ has been added with 5.13 allow perf to build
> > > even it that directory does not exist.
> > >
> > > Add arch/arm64/tools/ to PERF_SRC.
> > >
> > > Fixes:
> > > | make[3]: *** No rule to make target '.../qemux86_64-tdx-linux/perf/1.0/perf-1.0/arch/arm64/tools/gen-sysreg.awk', needed by '.../qemux86_64-tdx-linux/perf/1.0/perf-1.0/tools/arch/arm64/include/generated/asm/sysreg-defs.h'.  Stop.
> > > | make[2]: *** [Makefile.perf:456: arm64-sysreg-defs] Error 2
> > >
> > > Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
> > > ---
> > >  meta/recipes-kernel/perf/perf.bb | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > >
> > > Hi all
> > >
> > > I see some other options:
> > > - drop perf support for kernels<5.13 and simply add to PERF_SRC
> > > - drop the bb.fatal in favour of continue and simply add to PERF_SRC
> > >
> > > Any comments?
> >
> > I just ran into this myself while updating linux-yocto-dev
> >
> > What you have is better than either of those options, but different
> > from what I was working on.
> >
> > perf already uses KERNEL_VERSION, so I was adding some KERNEL_VERSION
> > specific sources and only copying them when they match.
> >
> > I'm concerned that skipping or always allowing files to not exist will
> > lead us to more subtle errors with invalid/incorrect kernel source trees.
> >
> > Another idea I had is to just skip if sources don't exist (like we do in
> > devsrc), but bb.warn so the user is aware.
>
> I can change the commit to:
> - just add to PERF_SRC
> - change the bb.fatal to bb.warn with the existing error string
> - add a 'continue' after the bb.warn
>
> Does that sound like a plan?

That matches my 2nd idea to fix it, so I'm good with it.

It'll really only just be someone using an old kernel against master
that will ever see a warning, so I have no issues with it.

Bruce

>
> Max
> >
> > Bruce
> >
> > >
> > > Thanks.
> > > Max
> > >
> > >
> > > diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
> > > index 675acfaf26..dae9320169 100644
> > > --- a/meta/recipes-kernel/perf/perf.bb
> > > +++ b/meta/recipes-kernel/perf/perf.bb
> > > @@ -117,6 +117,7 @@ EXTRA_OEMAKE += "\
> > >  # honour a JOBS variable.
> > >  EXTRA_OEMAKE:append:task-configure = " JOBS=1"
> > >
> > > +PERF_SRC_OPTIONAL ?= "arch/arm64/tools"
> > >  PERF_SRC ?= "Makefile \
> > >               tools/arch \
> > >               tools/build \
> > > @@ -127,6 +128,7 @@ PERF_SRC ?= "Makefile \
> > >               tools/scripts \
> > >               scripts/ \
> > >               arch/${ARCH}/Makefile \
> > > +             ${PERF_SRC_OPTIONAL} \
> > >  "
> > >
> > >  PERF_EXTRA_LDFLAGS = ""
> > > @@ -162,6 +164,7 @@ do_install() {
> > >
> > >  do_configure[prefuncs] += "copy_perf_source_from_kernel"
> > >  python copy_perf_source_from_kernel() {
> > > +    sources_opt = (d.getVar("PERF_SRC_OPTIONAL") or "").split()
> > >      sources = (d.getVar("PERF_SRC") or "").split()
> > >      src_dir = d.getVar("STAGING_KERNEL_DIR")
> > >      dest_dir = d.getVar("S")
> > > @@ -171,6 +174,8 @@ python copy_perf_source_from_kernel() {
> > >          src = oe.path.join(src_dir, s)
> > >          dest = oe.path.join(dest_dir, s)
> > >          if not os.path.exists(src):
> > > +            if s in sources_opt:
> > > +                continue
> > >              bb.fatal("Path does not exist: %s. Maybe PERF_SRC does not match the kernel version." % src)
> > >          if os.path.isdir(src):
> > >              oe.path.copyhardlinktree(src, dest)
> > > --
> > > 2.35.3
> > >
> >
> >
> > --
> > - Thou shalt not follow the NULL pointer, for chaos and madness await
> > thee at its end
> > - "Use the force Harry" - Gandalf, Star Trek II
diff mbox series

Patch

diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
index 675acfaf26..dae9320169 100644
--- a/meta/recipes-kernel/perf/perf.bb
+++ b/meta/recipes-kernel/perf/perf.bb
@@ -117,6 +117,7 @@  EXTRA_OEMAKE += "\
 # honour a JOBS variable.
 EXTRA_OEMAKE:append:task-configure = " JOBS=1"
 
+PERF_SRC_OPTIONAL ?= "arch/arm64/tools"
 PERF_SRC ?= "Makefile \
              tools/arch \
              tools/build \
@@ -127,6 +128,7 @@  PERF_SRC ?= "Makefile \
              tools/scripts \
              scripts/ \
              arch/${ARCH}/Makefile \
+             ${PERF_SRC_OPTIONAL} \
 "
 
 PERF_EXTRA_LDFLAGS = ""
@@ -162,6 +164,7 @@  do_install() {
 
 do_configure[prefuncs] += "copy_perf_source_from_kernel"
 python copy_perf_source_from_kernel() {
+    sources_opt = (d.getVar("PERF_SRC_OPTIONAL") or "").split()
     sources = (d.getVar("PERF_SRC") or "").split()
     src_dir = d.getVar("STAGING_KERNEL_DIR")
     dest_dir = d.getVar("S")
@@ -171,6 +174,8 @@  python copy_perf_source_from_kernel() {
         src = oe.path.join(src_dir, s)
         dest = oe.path.join(dest_dir, s)
         if not os.path.exists(src):
+            if s in sources_opt:
+                continue
             bb.fatal("Path does not exist: %s. Maybe PERF_SRC does not match the kernel version." % src)
         if os.path.isdir(src):
             oe.path.copyhardlinktree(src, dest)