View Issue Details

IDProjectCategoryView StatusLast Update
0005149Rocky-Linux-8kernelpublic2024-03-26 01:41
ReporterJason Vas Dias Assigned ToLouis Abel  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionunable to reproduce 
Platformx86_64OSRocky EL8OS Version8.9
Summary0005149: build hangs during perf build owing to broken tools/perf/trace/beauty/mmap_flags.sh
DescriptionSince v4.18.0-513.5.1.el8_9, and including latest v4.18.0-513.9.1.el8_9 ,
the kernel is unable to build without redirection of standard input to /dev/null -
it hangs during the perf build, running the
   tools/perf/trace/beauty/mmap_flags.sh
script.

Normally, I run my kernel builds with a command like:

 $ nohup bash -c 'rpmbuild --define "'"optflags $RPM_OPT_FLAGS"'" -ba SPECS/kernel.spec --without debug --without kabichk --with release --with headers --with perf --with verbose >LOGS/kernel-4.18.0-513.5.1.el8_9.log 2>&1' </dev/null >/dev/null 2>&1 & disown; sleep 4; tail -f LOGS/kernel-4.18.0-513.5.1.el8_9.log

This works, because I specify '</dev/null' .

However, today I did not use 'nohup ... </dev/null' , now I have these stuck processes (no log message written for nearly a hour now ) :

   [root@devbox01 perf]# ps -ef | egrep 'make|gcc'
adm-jas+ 244699 2856203 0 18:51 pts/1 00:00:02 rpmbuild --define optflags -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -march=x86-64 -mtune=native -O3 -DPIC -fPIC -g -ba SPECS/kernel.spec --without debug --without kabichk --with release --with headers --with perf --with verbose
adm-jas+ 642042 249352 0 19:23 pts/1 00:00:00 make EXTRA_CFLAGS=-std=gnu17 -march=x86-64 -mtune=native -O3 -DPIC -fPIC -Wall -Wextra -Wno-error -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -march=x86-64 -mtune=native -O3 -DPIC -fPIC -g -Wno-error LDFLAGS=-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -C tools/perf V=1 NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 DISABLE_WERROR=1 WERROR=0 NO_LIBUNWIND=1 HAVE_CPLUS_DEMANGLE=1 NO_GTK2=1 NO_STRLCPY=1 NO_BIONIC=1 LIBBPF_DYNAMIC=1 prefix=/usr PYTHON=/usr/libexec/platform-python DESTDIR=/home/adm-jason/rpmbuild/BUILDROOT/kernel-4.18.0-513.9.1.el8_8.x86_64 all
adm-jas+ 642047 642042 0 19:23 pts/1 00:00:00 make -f Makefile.perf --no-print-directory -j8 O= all
adm-jas+ 642165 642047 0 19:23 pts/1 00:00:00 make FIXDEP=1 -f Makefile.perf
root 646947 9386 0 19:59 pts/2 00:00:00 grep -E --color=auto make|gcc
[root@devbox01 perf]# ps --ppid 642165
    PID TTY TIME CMD
 643531 pts/1 00:00:00 sh
[root@devbox01 perf]# tr '\0' ' ' </proc/643531/cmdline
/bin/sh -c /bin/sh '/home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/perf/trace/beauty/mmap_flags.sh' /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/include/uapi/asm-generic /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm/ > trace/beauty/generated/mmap_flags_array.c [root@devbox01 perf]#

[root@devbox01 perf]# cat /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/perf/trace/beauty/generated/mmap_flags_array.c
static const char *mmap_flags[] = {
    [ilog2(0x40) + 1] = "32BIT",
#ifndef MAP_32BIT
#define MAP_32BIT 0x40
#endif


This file's contents have not changed in the last hour or so.

Indeed, if I run the command manually, without redirection of stdin to /dev/null, it hangs :


[root@devbox01 perf]# /bin/sh -x trace/beauty/mmap_flags.sh /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/include/uapi/asm-generic /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm/
+ '[' 2 -ne 2 ']'
+ header_dir=/home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/include/uapi/asm-generic
+ arch_header_dir=/home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm/
+ arch_mman=/home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm//mman.h
+ printf 'static const char *mmap_flags[] = {\n'
static const char *mmap_flags[] = {
+ regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
+ egrep -q '^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm//mman.h
+ egrep '^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm//mman.h
+ sed -r 's/^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*/\2 \1 \1 \1 \2/g'
+ xargs printf '\t[ilog2(%s) + 1] = "%s",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n'
    [ilog2(0x40) + 1] = "32BIT",
#ifndef MAP_32BIT
#define MAP_32BIT 0x40
#endif
+ egrep -q '^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'


The egrep command has no FILE argument, so reads stdin (/dev/fd/0).

Indeed, when I redirect stdin to /dev/null, the command succeeds:

[root@devbox01 perf]# /bin/sh -x trace/beauty/mmap_flags.sh /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/include/uapi/asm-generic /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm/ </dev/null
+ '[' 2 -ne 2 ']'
+ header_dir=/home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/include/uapi/asm-generic
+ arch_header_dir=/home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm/
+ arch_mman=/home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm//mman.h
+ printf 'static const char *mmap_flags[] = {\n'
static const char *mmap_flags[] = {
+ regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
+ egrep -q '^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm//mman.h
+ sed -r 's/^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*/\2 \1 \1 \1 \2/g'
+ egrep '^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm//mman.h
+ xargs printf '\t[ilog2(%s) + 1] = "%s",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n'
    [ilog2(0x40) + 1] = "32BIT",
#ifndef MAP_32BIT
#define MAP_32BIT 0x40
#endif
+ egrep -q '^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
+ '[' '!' -f /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm//mman.h ']'
+ egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm//mman.h
+ egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)'
+ egrep '^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/include/uapi/asm-generic/mman-common.h
+ sed -r 's/^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*/\2 \1 \1 \1 \2/g'
+ xargs printf '\t[ilog2(%s) + 1] = "%s",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n'
    [ilog2(0x01) + 1] = "SHARED",
#ifndef MAP_SHARED
#define MAP_SHARED 0x01
#endif
    [ilog2(0x02) + 1] = "PRIVATE",
#ifndef MAP_PRIVATE
#define MAP_PRIVATE 0x02
#endif
    [ilog2(0x10) + 1] = "FIXED",
#ifndef MAP_FIXED
#define MAP_FIXED 0x10
#endif
    [ilog2(0x20) + 1] = "ANONYMOUS",
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS 0x20
#endif
    [ilog2(0x008000) + 1] = "POPULATE",
#ifndef MAP_POPULATE
#define MAP_POPULATE 0x008000
#endif
    [ilog2(0x010000) + 1] = "NONBLOCK",
#ifndef MAP_NONBLOCK
#define MAP_NONBLOCK 0x010000
#endif
    [ilog2(0x020000) + 1] = "STACK",
#ifndef MAP_STACK
#define MAP_STACK 0x020000
#endif
    [ilog2(0x040000) + 1] = "HUGETLB",
#ifndef MAP_HUGETLB
#define MAP_HUGETLB 0x040000
#endif
    [ilog2(0x080000) + 1] = "SYNC",
#ifndef MAP_SYNC
#define MAP_SYNC 0x080000
#endif
    [ilog2(0x100000) + 1] = "FIXED_NOREPLACE",
#ifndef MAP_FIXED_NOREPLACE
#define MAP_FIXED_NOREPLACE 0x100000
#endif
+ '[' '!' -f /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm//mman.h ']'
+ egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/arch/x86/include/uapi/asm//mman.h
+ egrep '^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' /home/adm-jason/rpmbuild/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8_8.x86_64/tools/include/uapi/asm-generic/mman.h
+ sed -r 's/^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*/\2 \1 \1 \1 \2/g'
+ xargs printf '\t[ilog2(%s) + 1] = "%s",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n'
    [ilog2(0x0100) + 1] = "GROWSDOWN",
#ifndef MAP_GROWSDOWN
#define MAP_GROWSDOWN 0x0100
#endif
    [ilog2(0x0800) + 1] = "DENYWRITE",
#ifndef MAP_DENYWRITE
#define MAP_DENYWRITE 0x0800
#endif
    [ilog2(0x1000) + 1] = "EXECUTABLE",
#ifndef MAP_EXECUTABLE
#define MAP_EXECUTABLE 0x1000
#endif
    [ilog2(0x2000) + 1] = "LOCKED",
#ifndef MAP_LOCKED
#define MAP_LOCKED 0x2000
#endif
    [ilog2(0x4000) + 1] = "NORESERVE",
#ifndef MAP_NORESERVE
#define MAP_NORESERVE 0x4000
#endif
+ printf '};\n'
};
[root@devbox01 perf]#


Please ensure all runs of tools/perf/trace/beauty/mman_flags.sh have stdin redirected to /dev/null, or fix
the script to not be prone to this error .

Now I have to cancel the kernel build and start it again with input redirected to /dev/null .
Steps To ReproduceSee above
TagsNo tags attached.

Activities

Jason Vas Dias

Jason Vas Dias

2023-12-27 20:42

reporter   ~0005446

The problem occurs in mmap_flags.sh because $arch_mman is not exported, so in these statements :

  egrep -q $regex ${arch_mman} && \
 (egrep $regex ${arch_mman} | \

$arch_mman is set in the parent shell, so the first egrep succeeds, but because arch_mman is not exported,
it is not set in the sub-process , so the second egrep hangs because ${arch_mman} expands to nothing .

Suggested patch attached .
mmap_flags.sh.patch (1,222 bytes)   
--- mmap_flags.sh~	2023-12-27 20:41:23.859114015 +0000
+++ mmap_flags.sh	2023-12-27 20:37:01.835640773 +0000
@@ -14,2 +14,14 @@
 
+export arch_mman
+
+if [x != "x$header_dir" ] ; then
+   export header_dir
+fi
+if [x != "x$arch_header_dir" ] ; then
+   export arch_header_dir
+fi
+if [ x != "x$linux_mman" ]; then
+   export linux_mman;
+fi
+
 # those in egrep -vw are flags, we want just the bits
@@ -22,4 +34,6 @@
 	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
-egrep -q $regex ${linux_mman} && \
-(egrep $regex ${linux_mman} | \
+if [ x != "$linux_mman" ]; then
+   export linux_mman;
+   egrep -q $regex ${linux_mman} && \
+      (egrep $regex ${linux_mman} | \
 	egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
@@ -27,2 +41,3 @@
 	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
+fi
 ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
@@ -32,2 +47,3 @@
 	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
+
 ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) &&
mmap_flags.sh.patch (1,222 bytes)   
Jason Vas Dias

Jason Vas Dias

2023-12-27 20:44

reporter   ~0005447

complete modified mmap_flags.sh. Will test on next build.
Jason Vas Dias

Jason Vas Dias

2023-12-27 20:45

reporter   ~0005448

Oops, actually attach complete modified mmap_flags.sh. Will test on next build.
Jason Vas Dias

Jason Vas Dias

2023-12-27 20:47

reporter   ~0005449

OK, this website does not allow 'mmap_flags.sh' to be attached - here is the complete modified file:

<BEGIN MODIFIED mmap_flags.sh>
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1

if [ $# -ne 2 ] ; then
    [ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/`
    header_dir=tools/include/uapi/asm-generic
    arch_header_dir=tools/arch/${hostarch}/include/uapi/asm
else
    header_dir=$1
    arch_header_dir=$2
fi

arch_mman=${arch_header_dir}/mman.h

export arch_mman

if [x != "x$header_dir" ] ; then
   export header_dir
fi
if [x != "x$arch_header_dir" ] ; then
   export arch_header_dir
fi
if [ x != "x$linux_mman" ]; then
   export linux_mman;
fi

# those in egrep -vw are flags, we want just the bits

printf "static const char *mmap_flags[] = {\n"
regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
egrep -q $regex ${arch_mman} && \
(egrep $regex ${arch_mman} | \
    sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
    xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
if [ x != "$linux_mman" ]; then
   export linux_mman;
   egrep -q $regex ${linux_mman} && \
      (egrep $regex ${linux_mman} | \
    egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
    sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
    xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
fi
([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
(egrep $regex ${header_dir}/mman-common.h | \
    egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
    sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
    xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")

([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) &&
(egrep $regex ${header_dir}/mman.h | \
    sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
    xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
printf "};\n"
</END MODIFIED mmap_flags.sh>
Jason Vas Dias

Jason Vas Dias

2023-12-27 21:20

reporter   ~0005450

Oops, better, WORKING patch attached.

The problem was with $linux_mman , which is not set by the script, and evidently not set by its invoking environment either.
mmap_flags.sh-2.patch (1,649 bytes)   
--- mmap_flags.sh~	2023-12-27 20:41:23.859114015 +0000
+++ mmap_flags.sh	2023-12-27 21:16:57.577904419 +0000
@@ -10,7 +10,17 @@
 	arch_header_dir=$2
 fi
 
-arch_mman=${arch_header_dir}/mman.h
+export arch_mman=${arch_header_dir}/mman.h
+
+if [ x != "x$header_dir" ] ; then
+   export header_dir="$header_dir";
+fi
+if [ x != "x$arch_header_dir" ] ; then
+   export arch_header_dir="$arch_header_dir";
+fi
+if [ x != "x$linux_mman" ]; then
+   export linux_mman="$linux_mman";
+fi
 
 # those in egrep -vw are flags, we want just the bits
 
@@ -20,16 +30,19 @@
 (egrep $regex ${arch_mman} | \
 	sed -r "s/$regex/\2 \1 \1 \1 \2/g"	| \
 	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
-egrep -q $regex ${linux_mman} && \
-(egrep $regex ${linux_mman} | \
+if [ x != "x$linux_mman" ]; then
+   egrep -q $regex ${linux_mman} && \
+      (egrep $regex ${linux_mman} | \
 	egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
 	sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
 	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
+fi
 ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
 (egrep $regex ${header_dir}/mman-common.h | \
 	egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
 	sed -r "s/$regex/\2 \1 \1 \1 \2/g"	| \
 	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
+
 ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) &&
 (egrep $regex ${header_dir}/mman.h | \
 	sed -r "s/$regex/\2 \1 \1 \1 \2/g"	| \
mmap_flags.sh-2.patch (1,649 bytes)   
Jason Vas Dias

Jason Vas Dias

2023-12-27 21:23

reporter   ~0005451

Since once again the website does not allow 'mmap_flags.sh' to be attached, here it is in full :

<BEGIN MODIFIED mmap_flags.sh>
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1

if [ $# -ne 2 ] ; then
    [ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/`
    header_dir=tools/include/uapi/asm-generic
    arch_header_dir=tools/arch/${hostarch}/include/uapi/asm
else
    header_dir=$1
    arch_header_dir=$2
fi

export arch_mman=${arch_header_dir}/mman.h

if [ x != "x$header_dir" ] ; then
   export header_dir="$header_dir";
fi
if [ x != "x$arch_header_dir" ] ; then
   export arch_header_dir="$arch_header_dir";
fi
if [ x != "x$linux_mman" ]; then
   export linux_mman="$linux_mman";
fi

# those in egrep -vw are flags, we want just the bits

printf "static const char *mmap_flags[] = {\n"
regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MAP_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
egrep -q $regex ${arch_mman} && \
(egrep $regex ${arch_mman} | \
    sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
    xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
if [ x != "x$linux_mman" ]; then
   egrep -q $regex ${linux_mman} && \
      (egrep $regex ${linux_mman} | \
    egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
    sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
    xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
fi
([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.*' ${arch_mman}) &&
(egrep $regex ${header_dir}/mman-common.h | \
    egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
    sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
    xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")

([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+.*uapi/asm-generic/mman.h>.*' ${arch_mman}) &&
(egrep $regex ${header_dir}/mman.h | \
    sed -r "s/$regex/\2 \1 \1 \1 \2/g" | \
    xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n#ifndef MAP_%s\n#define MAP_%s %s\n#endif\n")
printf "};\n"
</END MODIFIED mmap_flags.sh>
Louis Abel

Louis Abel

2023-12-27 22:34

administrator   ~0005452

Using mock[1], the supported method of building RPM packages for Rocky Linux, is recommended for any and all package builds.

% dnf install epel-release -y
% dnf install mock -y
% usermod -aG mock user
% su - user
$ wget https://kojidev.rockylinux.org/kojifiles/packages/kernel/4.18.0/513.9.1.el8_9/src/kernel-4.18.0-513.9.1.el8_9.src.rpm
## (Don't know what you're using for $RPM_OPT_FLAGS)
$ mock -r rocky-8-x86_64 --without debug --without kabichk --with release --with headers --with perf --with verbose kernel-4.18.0-513.9.1.el8_9.src.rpm

The result:

. . .
Wrote: /builddir/build/RPMS/kernel-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-headers-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-cross-headers-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-debuginfo-common-x86_64-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/perf-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/perf-debuginfo-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/python3-perf-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/python3-perf-debuginfo-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-tools-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-tools-libs-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-tools-libs-devel-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-tools-debuginfo-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/bpftool-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/bpftool-debuginfo-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-selftests-internal-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-core-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-devel-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-modules-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-modules-extra-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-modules-internal-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-debuginfo-4.18.0-513.9.1.el8.x86_64.rpm
Wrote: /builddir/build/RPMS/kernel-ipaclones-internal-4.18.0-513.9.1.el8.x86_64.rpm
Finish: rpmbuild kernel-4.18.0-513.9.1.el8_9.src.rpm
Finish: build phase for kernel-4.18.0-513.9.1.el8_9.src.rpm
INFO: Done(kernel-4.18.0-513.9.1.el8_9.src.rpm) Config(rocky-8-x86_64) 45 minutes 35 seconds
INFO: Results and/or logs in: /var/lib/mock/rocky-8-x86_64/result
Finish: run
$ grep mmap_flags /var/lib/mock/rocky-8-x86_64/result/build.log
/var/lib/mock/rocky-8-x86_64/result/build.log:/bin/sh '/builddir/build/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8.x86_64/tools/perf/trace/beauty/mmap_flags.sh' /builddir/build/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8.x86_64/tools/include/uapi/asm-generic /builddir/build/BUILD/kernel-4.18.0-513.9.1.el8_9/linux-4.18.0-513.9.1.el8.x86_64/tools/arch/x86/include/uapi/asm/ > trace/beauty/generated/mmap_flags_array.c

--

On the surface this issue appears to be environmental to your system setup and configuration. It is highly likely that it is due to:

1) The use of rpmbuild in a non-clean environment rather than mock[1] which is what we (and upstream) use for all of our package builds. You are highly encouraged (and recommended) to do the same.
2) The use of shell redirects which are unnecessary using the standard recommended method of building packages (mock)

Please replicate your issue using mock to build the kernel package. If this still fails for you, attempt to replicate this in RHEL 8.9 and then CentOS Stream 8. If you are able to successfully replicate your issue in all cases using mock, you are encouraged to report this to issues.redhat.com.

Setting to needinfo.

## Footnotes

[1] https://rpm-software-management.github.io/mock/ - We and upstream use mock in our build systems and everyone is encouraged to use this tool when building packages.
[2] Please re-review the bug tracker guidelines in account services. It clearly states that arbitrary scripts will be rejected. If you feel that this is an issue, please state your case here: https://git.resf.org/infrastructure/meta
Jason Vas Dias

Jason Vas Dias

2023-12-28 14:54

reporter   ~0005453

If the kernel RPM cannot be built by 'rpmbuild', you should not distribute the kernel.spec file (keep it secret) .

Use of Mock should not be an excuse to allow BROKEN SCRIPTS like mmap_flags.sh in the build .

You have not reproduced the test conditions I was operating under in your test shown above -
I was not using Mock .

When you do not use Mock, but use 'rpmbuild', as all .spec files are meant to be built with,
you see that the broken mmap_flags.sh script is exposed and fails the build .

If a distribution does not support building the kernel RPM from source, from the command line,
by running a command like 'rpmbuild' that is the handler of the build .spec file,
I would not be using such a distribution at all .

I will also raise this as a RHEL-8 bug - they do seem to care about so obviously
 broken kernel build scripts - you will doubtless get the fixed script in an update.
Neil Hanlon

Neil Hanlon

2023-12-28 15:14

administrator   ~0005454

rpmbuild is but a tool used to build the distribution. In fact, rpmbuild is called inside of mock.

The functionality of the script in a pure rpmbuild environment (i.e., not a clean build root) is not considered a bug. Obviously the build works--otherwise how would we complete the build?

We are, of course, concerned about build failures, but as it stands, your issue is purely environmental as it cannot be reproduced in a clean mock environment, which is how this package is intended to be built.
Louis Abel

Louis Abel

2024-03-26 01:41

administrator   ~0006535

Closing due to 8.10 beta releasing soon and the issue is not reproducible using the standard, recommended toolset used to build packages for Rocky Linux.

If you are able to reliably reproduce your issue using the recommended toolset on Rocky Linux and are not able to on CentOS Stream 8 and RHEL 8, please open a new bug report.

Issue History

Date Modified Username Field Change
2023-12-27 20:18 Jason Vas Dias New Issue
2023-12-27 20:42 Jason Vas Dias Note Added: 0005446
2023-12-27 20:42 Jason Vas Dias File Added: mmap_flags.sh.patch
2023-12-27 20:44 Jason Vas Dias Note Added: 0005447
2023-12-27 20:45 Jason Vas Dias Note Added: 0005448
2023-12-27 20:47 Jason Vas Dias Note Added: 0005449
2023-12-27 21:20 Jason Vas Dias Note Added: 0005450
2023-12-27 21:20 Jason Vas Dias File Added: mmap_flags.sh-2.patch
2023-12-27 21:23 Jason Vas Dias Note Added: 0005451
2023-12-27 22:34 Louis Abel Assigned To => Louis Abel
2023-12-27 22:34 Louis Abel Status new => needinfo
2023-12-27 22:34 Louis Abel Note Added: 0005452
2023-12-28 14:54 Jason Vas Dias Note Added: 0005453
2023-12-28 15:14 Neil Hanlon Note Added: 0005454
2024-03-26 01:41 Louis Abel Status needinfo => closed
2024-03-26 01:41 Louis Abel Resolution open => unable to reproduce
2024-03-26 01:41 Louis Abel Note Added: 0006535