From patchwork Mon Apr 24 17:46:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcos Paulo de Souza X-Patchwork-Id: 13222463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D99AC7618E for ; Mon, 24 Apr 2023 17:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231710AbjDXRq5 (ORCPT ); Mon, 24 Apr 2023 13:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbjDXRq5 (ORCPT ); Mon, 24 Apr 2023 13:46:57 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC3C4E9 for ; Mon, 24 Apr 2023 10:46:54 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 26689218D6 for ; Mon, 24 Apr 2023 17:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1682358413; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=0Xn1uT17cEmjgnWq6XOzx2+3VncuOSwoIq1e0FPNZDE=; b=IR58HqseossuHn6qgotbVSUhyPNhTq4ZCDXZ6wVj80CqfQP6Q+dKAcP5olq9y/RG08YpKQ URc2wSOhQGOFc9Dw5VW5RnU80tS1IcpI/3dgrT7YFwkn+5tEIW2pfx409JMjGEKwJ9GqZY GrvJp7wg90wMcdIQy+x2RynfWpIG/Sc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1682358413; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=0Xn1uT17cEmjgnWq6XOzx2+3VncuOSwoIq1e0FPNZDE=; b=V+LhdCtTfqqgTWJTPW5Sqo+li/48qiCU2GET0k6EyuDx0jBkKdIsoH0g8dh5beoDxB4KFY Ve9H4C146sj5fUCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A243613780 for ; Mon, 24 Apr 2023 17:46:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id McvZGYzARmTiNgAAMHmgww (envelope-from ) for ; Mon, 24 Apr 2023 17:46:52 +0000 Date: Mon, 24 Apr 2023 14:46:50 -0300 From: Marcos Paulo de Souza To: linux-kbuild@vger.kernel.org Subject: Question: Adding new kselftest mod build rule resulting on "m2c: command not found" Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Hi, I've being trying to understand a problem when adding a new rule to compile modules on ksefltests: $ make kselftest TARGETS=livepatch make[2]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch' make[3]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules' make -C /home/mpdesouza/git/linux M=/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules modules m2c -o scripts/Makefile.build -e scripts/Makefile.build scripts/Makefile.build.mod make[5]: m2c: No such file or directory I managed to create a minimal reproducer for the problem here[1]. I'll attach the patches at the end of the email if you want to inspect the changes without getting the patches from github. The curious part is, if I execute the ksefltests using a different target, it works: $ make -C tools/testing/selftests run_tests TARGETS=livepatch make: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests' make[1]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch' make -C /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules make[2]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules' make -C /home/mpdesouza/git/linux M=/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules modules CC [M] /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules/mod_test.o MODPOST /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules/Module.symvers CC [M] /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules/mod_test.mod.o LD [M] /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules/mod_test.ko BTF [M] /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules/mod_test.ko make[2]: Leaving directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules' make[1]: Leaving directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch' make[1]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch' make -C /home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules make[2]: Entering directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules' make -C /home/mpdesouza/git/linux M=/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules modules make[2]: Leaving directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch/test_modules' TAP version 13 1..1 # selftests: livepatch: test-true.sh ok 1 selftests: livepatch: test-true.sh make[1]: Leaving directory '/home/mpdesouza/git/linux/tools/testing/selftests/livepatch' make: Leaving directory '/home/mpdesouza/git/linux/tools/testing/selftests' In the root Makefile, ksefltest is defined as: PHONY += kselftest kselftest: headers $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests So, it's quite odd that a "mostly identical" rules being triggered result in that odd "m2c" command being invoked. Both outputs here were got from a openSUSE Tumbleweed machine, using make 4.4.1. When executing the kselftest target on a Ubuntu machine, the error is similar but not the same: ... make[4]: Entering directory '/root/linux-kbuild' make -f ./scripts/Makefile.build obj=arch/x86/entry/syscalls all m2c -o scripts/Makefile.lib -e scripts/Makefile.lib scripts/Makefile.lib.mod make[5]: m2c: No such file or directory make[5]: *** [: scripts/Makefile.lib] Error 127 make[4]: *** [arch/x86/Makefile:248: archheaders] Error 2 ... So, error is the same, but it failed on Makefile.lib, instead of Makefile.build from the previous run. I also tried to change the KDIR from tools/testing/selftests/livepatch/test_modules/Makefile to point to KDIR ?= /lib/modules/$(shell uname -r)/build, but it then results in a different problem, making building_out_of_srctree to be set to false on /usr/src/linux-6.2.10-1-obj/x86_64/default/Makefile, which then results in different problems... So I would like to understand this problem first, since there was no way to stop make from calling "m2c". It was also tested on linux-kbuild/for-next, but the problem is the same. I also found some links[2] mentioning "m2c", but the workarounds didn't solved the issue. At this point any help would be great! [1]: https://github.com/marcosps/linux/commits/kbuild-next-kselftests [2]: https://lists.mcs.anl.gov/pipermail/petsc-users/2010-November/007299.html From 5ac1d2d3e7e66bfe58094f00029fc4ba15555d10 Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza Date: Thu, 20 Apr 2023 11:51:29 -0300 Subject: [PATCH 2/2] easily test mods building for kselftests Signed-off-by: Marcos Paulo de Souza --- tools/testing/selftests/livepatch/Makefile | 8 ++------ tools/testing/selftests/livepatch/test-true.sh | 3 +++ .../selftests/livepatch/test_modules/Makefile | 11 +++++++++++ .../selftests/livepatch/test_modules/mod_test.c | 15 +++++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100755 tools/testing/selftests/livepatch/test-true.sh create mode 100644 tools/testing/selftests/livepatch/test_modules/Makefile create mode 100644 tools/testing/selftests/livepatch/test_modules/mod_test.c diff --git a/tools/testing/selftests/livepatch/Makefile b/tools/testing/selftests/livepatch/Makefile index 02fadc9d55e0..bfe048f6a65d 100644 --- a/tools/testing/selftests/livepatch/Makefile +++ b/tools/testing/selftests/livepatch/Makefile @@ -1,13 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 +TEST_GEN_MODS_DIR := test_modules TEST_PROGS_EXTENDED := functions.sh TEST_PROGS := \ - test-livepatch.sh \ - test-callbacks.sh \ - test-shadow-vars.sh \ - test-state.sh \ - test-ftrace.sh \ - test-sysfs.sh + test-true.sh TEST_FILES := settings diff --git a/tools/testing/selftests/livepatch/test-true.sh b/tools/testing/selftests/livepatch/test-true.sh new file mode 100755 index 000000000000..8c3cbfc39d94 --- /dev/null +++ b/tools/testing/selftests/livepatch/test-true.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +exit 0 diff --git a/tools/testing/selftests/livepatch/test_modules/Makefile b/tools/testing/selftests/livepatch/test_modules/Makefile new file mode 100644 index 000000000000..2975fe21f48c --- /dev/null +++ b/tools/testing/selftests/livepatch/test_modules/Makefile @@ -0,0 +1,11 @@ +LP_TESTMODS_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) +#KDIR ?= /lib/modules/$(shell uname -r)/build +KDIR ?= $(abspath $(LP_TESTMODS_DIR)/../../../../..) + +obj-m += mod_test.o + +all: + make -C $(KDIR) M=$(LP_TESTMODS_DIR) modules + +clean: + make -C $(KDIR) M=$(LP_TESTMODS_DIR) clean diff --git a/tools/testing/selftests/livepatch/test_modules/mod_test.c b/tools/testing/selftests/livepatch/test_modules/mod_test.c new file mode 100644 index 000000000000..135f5d0b55b0 --- /dev/null +++ b/tools/testing/selftests/livepatch/test_modules/mod_test.c @@ -0,0 +1,15 @@ +#include +#include + +static int mod_init(void) +{ + return 0; +} + +static void mod_exit(void) +{ +} + +module_init(mod_init); +module_exit(mod_exit); +MODULE_LICENSE("GPL"); -- 2.40.0