[LU-16662] Linux 5.19+ break configure test compile on CONFIG_KEYS Created: 24/Mar/23  Updated: 20/Dec/23  Resolved: 19/Dec/23

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.16.0, Lustre 2.15.4

Type: Bug Priority: Minor
Reporter: Xinliang Liu Assignee: Xinliang Liu
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Related
is related to LU-16719 ib_xxx symbol mismatch between in-ker... Open
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

Linux 5.19+ break configure test compile on CONFIG_KEYS when run configure without passing Linux src path.

$ ./configure --disable-server
...
checking whether to enable gss keyring backend... yes
checking if Linux kernel was built with CONFIG_KEYS in or as module... no
configure: WARNING: GSS keyring backend requires that CONFIG_KEYS be enabled in your kernel.
checking for keyctl_search in -lkeyutils... yes
configure: error: Cannot enable gss_keyring. See above for details. 
$ grep CONFIG_KEYS -rn /boot/config-*
6884:CONFIG_KEYS=y


 Comments   
Comment by Xinliang Liu [ 24/Mar/23 ]

Looking at the config.log, there are many modpost errors. These errors make conftest.c compile failed.

configure:20676: checking if Linux kernel was built with CONFIG_KEYS in or as module
configure:20716: cp conftest.c build && make -d modules DEQUOTE_CC_VERSION_TEXT=yes LDFLAGS= LD=/usr/bin/ld CC=gcc -f /home/openeuler/lustre-release/build/Makefile LUSTRE_LINUX_CONFIG=/lib/modules/6.1.8-3.0.0.7.oe1.aarch64/build/.config LINUXINCLUDE= -I/lib/modules/6.1.8-3.0.0.7.oe1.aarch64/source/arch/arm64/include -Iinclude -Iarch/arm64/include/generated -I/lib/modules/6.1.8-3.0.0.7.oe1.aarch64/source/include -Iinclude2 -I/lib/modules/6.1.8-3.0.0.7.oe1.aarch64/source/include/uapi -Iinclude/generated -I/lib/modules/6.1.8-3.0.0.7.oe1.aarch64/source/arch/arm64/include/uapi -Iarch/arm64/include/generated/uapi -I/lib/modules/6.1.8-3.0.0.7.oe1.aarch64/source/include/uapi -Iinclude/generated/uapi -include /lib/modules/6.1.8-3.0.0.7.oe1.aarch64/source/include/linux/kconfig.h KBUILD_EXTRA_SYMBOLS= /usr/src/kernels/6.1.8-3.0.0.7.oe1.aarch64/Module.symvers -o tmp_include_depends -o scripts -o include/config/MARKER -C /lib/modules/6.1.8-3.0.0.7.oe1.aarch64/build EXTRA_CFLAGS=-Werror-implicit-function-declaration -g -I/home/openeuler/lustre-release/libcfs/include -I/home/openeuler/lustre-release/libcfs/include/libcfs -I/home/openeuler/lustre-release/lnet/include/uapi -I/home/openeuler/lustre-release/lnet/include -I/home/openeuler/lustre-release/lustre/include/uapi -I/home/openeuler/lustre-release/lustre/include -Wno-format-truncation -Wno-stringop-truncation -Wno-stringop-overflow M=/home/openeuler/lustre-release/build
warning: the compiler differs from the one used to build the kernel
  The kernel was built by:
  You are using:           gcc (GCC) 10.3.1
ERROR: modpost: vmlinux: 'init_uts_ns' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'system_state' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'static_key_initialized' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'reset_devices' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'loops_per_jiffy' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'name_to_dev_t' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'wait_for_initramfs' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'init_task' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'fpsimd_context_busy' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'kernel_neon_begin' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'kernel_neon_end' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'pm_power_off' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: 'profile_pc' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: '__memcpy_fromio' exported twice. Previous export was in vmlinux
ERROR: modpost: vmlinux: '__memcpy_toio' exported twice. Previous export was in vmlinux
 ...
Comment by Patrick Farrell [ 24/Mar/23 ]

yujian - I believe you're looking at this on another ticket

Comment by Xinliang Liu [ 24/Mar/23 ]

The symbols exported twice printing is caused by pass kernel Module.symvers via KBUILD_EXTRA_SYMBOLS option when compiling.

KBUILD_EXTRA_SYMBOLS=/usr/src/kernels/6.1.8-3.0.0.7.oe1.aarch64/Module.symvers 

And after commit "b8422711080f modpost: make multiple export error" which introduced in v5.19 make this symbol exported twice as error from warning.

So here it shouldn't put kernel's Module.symvers  to KBUILD_EXTRA_SYMBOLS option.

Comment by Xinliang Liu [ 24/Mar/23 ]

Thanks paf0186 for the notice , I just can't find a related ticket and just working out the patch to send. If we find Jian's ticket we can mark this as a duplicated one

$ cat config.patch
diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4
index 7421cfb91b..4f088a148b 100644
--- a/lnet/autoconf/lustre-lnet.m4
+++ b/lnet/autoconf/lustre-lnet.m4
@@ -245,7 +245,7 @@ AS_IF([test $ENABLEO2IB = "no"], [
                        O2IB_SYMVER=$LINUX_OBJ/Module.symvers
                fi
                if test -n "$O2IB_SYMVER"; then
-                       if test "$O2IB_SYMVER" != "$LINUX_OBJ/Module.symvers"; then
+                       if test !"$O2IB_SYMVER" -ef "$LINUX_OBJ/Module.symvers"; then
                                AC_MSG_NOTICE([adding $O2IB_SYMVER to Symbol Path O2IB])
                                EXTRA_SYMBOLS="$EXTRA_SYMBOLS $O2IB_SYMVER"
                                AC_SUBST(EXTRA_SYMBOLS)
@@ -286,7 +286,7 @@ AC_SUBST(ENABLEO2IB) AS_IF([test $ENABLEO2IB != "no"], [
        EXTRA_CHECK_INCLUDE="$EXTRA_OFED_CONFIG $EXTRA_OFED_INCLUDE"
-       if test $O2IBPATH != $LINUX_OBJ; then
+       if test ! $O2IBPATH -ef $LINUX_OBJ; then
                KBUILD_EXTRA_SYMBOLS="$KBUILD_EXTRA_SYMBOLS $O2IBPATH/Module.symvers"
        fi 

For in-tree IB support and without passing Linux src path, the LINUX_OBJ  maybe just a soft link to O2IBPATH, they are pointing to the same dir.

E.g.:

O2IBPATH='/usr/src/kernels/6.1.8-3.0.0.7.oe1.aarch64' 
LINUX_OBJ='/lib/modules/6.1.8-3.0.0.7.oe1.aarch64/build'
$ ls -l /lib/modules/6.1.8-3.0.0.7.oe1.aarch64/build
lrwxrwxrwx 1 root root 42 Feb  7 00:00 /lib/modules/6.1.8-3.0.0.7.oe1.aarch64/build -> /usr/src/kernels/6.1.8-3.0.0.7.oe1.aarch64
Comment by Jian Yu [ 24/Mar/23 ]

Hi xinliang and paf0186,
The ticket is DDN-3569. However, there are two issues. Please refer to #comment-366961.

Comment by Xinliang Liu [ 24/Mar/23 ]

Sorry yujian , I can't open the comment link.

Comment by Peter Jones [ 24/Mar/23 ]

That is expected - it is not a public comment. So, it would be better to collaborate on this ticket

Comment by Jian Yu [ 24/Mar/23 ]

Another issue is:

# ./configure --disable-server --with-o2ib
# make rpms
<~snip~>
make[4]: *** No rule to make target 'crypto.c', needed by 'distdir'.  Stop.

 

Comment by Xinliang Liu [ 24/Mar/23 ]

Yeah, this is really another issue which need another ticket to track.

But I can't reproduce this issue on my v6.1 kernel arm machine with your cmds on master branch.

BTW, I apply some unmerged patches mentioned in LU-16351

f7edfcb684 (HEAD -> 6.1-openeuler) LU-16662 autoconf: fix configure test compile for CONFIG_KEYS
e61195e4f8 LU-16351 llite: Linux 6.1 prandom, folios_contig, vma_iterator
6add9c73a4 LU-16350 osd-ldiskfs: no_llseek removed, dquot_transfer
5bc0f95938 LU-16328 llite: Linux 6.0 migrate_folio, vfs_setxattr
a0f760acdd LU-16327 llite: read_folio, release_folio, filler_t 
Comment by Gerrit Updater [ 24/Mar/23 ]

"xinliang <xinliang.liu@linaro.org>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/50399
Subject: LU-16662 autoconf: fix configure test compile for CONFIG_KEYS
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 32e82ef1eef4e7968ff4a543a61d9ab374e0b6f3

Comment by Gerrit Updater [ 04/Apr/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/50399/
Subject: LU-16662 autoconf: fix configure test compile for CONFIG_KEYS
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 321a533b868908f37d01a4b787f5a463a02e427c

Comment by Peter Jones [ 04/Apr/23 ]

Landed for 2.16

Comment by Gerrit Updater [ 07/Apr/23 ]

"Jian Yu <yujian@whamcloud.com>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/50568
Subject: LU-16662 autoconf: fix configure test compile for CONFIG_KEYS
Project: fs/lustre-release
Branch: b2_15
Current Patch Set: 1
Commit: 3b719f23c352f73471a3f5904ef790e9936497bf

Comment by Jian Yu [ 07/Apr/23 ]

Just found the mlx build was not enabled on master branch. With this patch applied on another branch, el9.0, el9.1, sles15sp3, sles15sp4, ubuntu2004 and ubuntu2204 mlx build failed:

ERROR: modpost: "backport_dependency_symbol" [/tmp/rpmbuild-lustre-jenkins-7GHqQmd3/BUILD/....../lnet/klnds/o2iblnd/ko2iblnd.ko] undefined!
ERROR: modpost: "ib_get_dma_mr" [/tmp/rpmbuild-lustre-jenkins-7GHqQmd3/BUILD/....../lnet/klnds/o2iblnd/ko2iblnd.ko] undefined!

$O2IB_SYMVER was not added to Symbol Path.

Comment by Xinliang Liu [ 10/Apr/23 ]

Maybe the $O2IB_SYMVER is not correct.

Comment by Xinliang Liu [ 10/Apr/23 ]

And LU-15962 shows that it should add kernel's Module.symvers to variable EXTRA_SYMBOLS.

Looks like variable EXTRA_SYMBOLS and KBUILD_EXTRA_SYMBOLS are not the same thing.

And can't find any description of EXTRA_SYMBOLS in https://www.kernel.org/doc/Documentation/kbuild/modules.txt or somewhere else.

Comment by Chris Horn [ 10/Apr/23 ]

Building against mlnx-ofa_kernel no longer works with this patch.

Comment by Chris Horn [ 10/Apr/23 ]

running configure with this patch:

> git -P diff
diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4
index 4f088a148b..3c45644447 100644
--- a/lnet/autoconf/lustre-lnet.m4
+++ b/lnet/autoconf/lustre-lnet.m4
@@ -249,6 +249,8 @@ AS_IF([test $ENABLEO2IB = "no"], [
 				AC_MSG_NOTICE([adding $O2IB_SYMVER to Symbol Path O2IB])
 				EXTRA_SYMBOLS="$EXTRA_SYMBOLS $O2IB_SYMVER"
 				AC_SUBST(EXTRA_SYMBOLS)
+			else
+				AC_MSG_NOTICE([$O2IB_SYMVER -ef $LINUX_OBJ/Module.symvers])
 			fi
 		else
 			AC_MSG_ERROR([an external source tree was, either specified or detected, for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
> ./configure --with-linux=/usr/src/linux-5.3.18-150300.59.106 --with-linux-obj=/usr/src/linux-5.3.18-150300.59.106-obj/x86_64/default --disable-server --with-o2ib=/usr/src/ofa_kernel/default
...
configure: /usr/src/ofa_kernel/x86_64/5.3.18-150300.59.106-default/Module.symvers -ef /usr/src/linux-5.3.18-150300.59.106-obj/x86_64/default/Module.symvers
...
> md5sum /usr/src/ofa_kernel/x86_64/5.3.18-150300.59.106-default/Module.symvers
746f968f5349ba78622c251b5ca1f625  /usr/src/ofa_kernel/x86_64/5.3.18-150300.59.106-default/Module.symvers
> md5sum /usr/src/linux-5.3.18-150300.59.106-obj/x86_64/default/Module.symvers
445f21b295267047818da63f2ca27ee6  /usr/src/linux-5.3.18-150300.59.106-obj/x86_64/default/Module.symvers
>
Comment by Xinliang Liu [ 12/Apr/23 ]

Strangely! I verified that the test operator "-ef" can test if a file is equal to a link, no matter if it is a soft or hard link.

See https://stackoverflow.com/questions/40813253/compare-a-symlink-and-his-target-with-bash-test-ef also.

But another thing is that "-ef" is not a POSIX test, see: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128

 

And the configure script seems to use shell interpreter "/bin/sh". Could you check which shell it is? And check that "-ef" is support like below

[jenkins@lustre-jenkins-slave-1 ~]$ ls -l /bin/sh
lrwxrwxrwx. 1 root root 4 Jan 12  2021 /bin/sh -> bash
[jenkins@lustre-jenkins-slave-1 ~]$ sh -c " test ! . -ef .. && echo !="
!=
 

 

Comment by Xinliang Liu [ 12/Apr/23 ]

Looks like it will append EXTRA SYMBOLS to KBUILD_EXTRA_SYMBOLS eventually.

[openeuler@oe-mainline-test lustre-release]$ grep @EXTRA_SYMBOLS@ -rn|grep KBUILD_EXTRA_SYMBOLS
build/Rules.in:37:KBUILD_EXTRA_SYMBOLS += @EXTRA_SYMBOLS@ 

https://www.kernel.org/doc/Documentation/kbuild/modules.txt 

Comment by Xinliang Liu [ 12/May/23 ]

The below merged patch contains $O2IB_SYMVER adding fix. Thanks, Shaun Tancheff.

https://review.whamcloud.com/c/fs/lustre-release/+/50711

Comment by Peter Jones [ 19/Dec/23 ]

All patches merged for 2.16

Comment by Gerrit Updater [ 20/Dec/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/50568/
Subject: LU-16662 autoconf: fix configure test compile for CONFIG_KEYS
Project: fs/lustre-release
Branch: b2_15
Current Patch Set:
Commit: 05df94478440a0902467c177295804faeeac2991

Generated at Sat Feb 10 03:28:56 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.