Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-57823

[RFE] macros.kmp: lookup for latest_kernel is slow and it is always run.

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • kernel-srpm-macros-1.0-14.el9
    • None
    • 1
    • rhel-kernel-maint
    • ssg_core_kernel
    • 0
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • CK Parent Issues In Progress
    • All
    • None

      What were you trying to do that didn't work?

      macros.kmp: lookup for latest_kernel is slow and it is always run.

      If the kernel_version is defined, there is no need to lookup the latest
      kernel*-devel package version. 
      If it's not defined, we can only look for the relevant packages instead of using rpm -qa.

      Customer is using rpmspec to list the generated rpms and generating make target on the fly, so running `rpm -qa` on each kmod spec slows down quite a bit the process.

      Issue is present on RHEL 9.4 as well:
      -------------------------------------

      1. cat /usr/lib/rpm/macros.d/macros.kmp  | grep kernel_version -C2
            %global kmod_release %{-r*}%{!-r:%{release}} \
            %global latest_kernel %({ rpm -q --qf '%% {VERSION}

        -%%{RELEASE}.%%{ARCH}\\\\n' `rpm -qa | egrep "^kernel(-rt|-aarch64)?-devel" | /usr/lib/rpm/redhat/rpmsort -r | head -n 1`; echo '%%%%{nil}'; } | head -n 1) \
            %{!?kernel_version:%

        Unknown macro: {expand}

        \
            %global kverrel %(%{kmodtool} verrel %{?kernel_version} 2>/dev/null) \
            flavors="default" \
            if [ -z "%*" ]; then \
        -------------------------------------

      kernel-rpm-macros-185-13.el9.noarch was used on my test system.

       

      How reproducible:
      Always

      Steps to Reproduce:
      1. Customer is using a spec file with kernel_module_package and kernel_version defined.

      Actual results:
      last_kernel runs because it's a %global
      Also last_kernel uses `rpm -qa` which is pretty slow

      Expected results:
      When kernel_version is defined, last_kernel doesn't run

      Additional info:
      1. We can speed up last_kernel with something like
      ```
      rpm q --qf '%{VERSION}%{RELEASE}.%{ARCH}\n' kernel-rt-devel kernel-aarch64-devel kernel-devel | /usr/lib/rpm/redhat/rpmsort -r 2>/dev/null | head -n1
      ```
      We can also move it and make it a %define instead of a %global so it doesn't run when not used

      2. Customer had filed 2108441 against fedora long back.

              rhn-support-dvlasenk Denys Vlasenko
              rhn-support-aratnapa Akshay Ratnaparkhe
              Ziqian (Zamir) SUN Ziqian (Zamir) SUN
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated: