From nobody Wed Nov 27 16:39:03 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6BF2249E5; Tue, 8 Oct 2024 15:35:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728401728; cv=none; b=sEzXDV7Lq08ooY+F+oZlHJ8qzEJDPuD2umR/UJhjgTWhiADn4kClgDhGTjNXNY1o/c60Ysjd76Sqwc0t55Q/cUlWiB9GvntBBENXBa2/UrKnlLM8yF5U5pzUmflseESE/YiKUmWHn5iWz1L9erRo18rbduvOmiK1AS8gsKYp5rc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728401728; c=relaxed/simple; bh=Wl1j1DcsdjghWUruz8NJy1B0MpfUs6RuX40DQKKNB4I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=d9usMJV+6gIKhBy2ZL/Te4QArMezKVLOGipuuTAFWSt3D0lONt4Mo5JD7bHlulrE1HP4Ilxmy51DGz7AWJ8GleKrLp4+ueImQKxc1KZieAn6qFPGBCznHti+ba2Rj6aoI/xa0DlsB9sBxbdSS8Y2oyyRSWeGJil9S6qneG4TX/w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PJs2EVol; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PJs2EVol" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49C0FC4CECE; Tue, 8 Oct 2024 15:35:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728401728; bh=Wl1j1DcsdjghWUruz8NJy1B0MpfUs6RuX40DQKKNB4I=; h=From:To:Cc:Subject:Date:From; b=PJs2EVolLdF3G1KCtNP10zYBxCxio9SdSC5+Q40F64AvPO+dwJiGEVjVuhP0HB4V6 NVNzPnBR/tjFyDVvRCN2IWSw6db+SpTMAycXYsVy0iW9ILoLPznpqVzqBvH7I46vTo PnH3zijWchCPF9cnAYUSaUUy9lTzqjOzrDPkLDuuuNhS5kzG7faD9CbDSWp+vbLkAU ZPIpdNblmYgxaP1wH4aIjX6glH8IV2vuKDLLli8K7BvLR2I2n5AXSoitZJMOI8ziwb TltOKetZuXsSrR9hkKq57H7YZrCA92znScqi9WcT+GChkcj9u8yWlkLQ6iSDmhGCtz hGxJdqziUftpA== From: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= To: Tejun Heo , David Vernet , Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Mark Brown Cc: =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , bpf@vger.kernel.org, linux-riscv@lists.infradead.org, Anders Roxell Subject: [PATCH v3] selftests: sched_ext: Add sched_ext as proper selftest target Date: Tue, 8 Oct 2024 17:35:18 +0200 Message-ID: <20241008153519.1270862-1-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Bj=C3=B6rn T=C3=B6pel The sched_ext selftests is missing proper cross-compilation support, a proper target entry, and out-of-tree build support. When building the kselftest suite, e.g.: make ARCH=3Driscv CROSS_COMPILE=3Driscv64-linux-gnu- \ TARGETS=3Dsched_ext SKIP_TARGETS=3D"" O=3D/output/foo \ -C tools/testing/selftests install or: make ARCH=3Darm64 LLVM=3D1 TARGETS=3Dsched_ext SKIP_TARGETS=3D"" \ O=3D/output/foo -C tools/testing/selftests install The expectation is that the sched_ext is included, cross-built, the correct toolchain is picked up, and placed into /output/foo. In contrast to the BPF selftests, the sched_ext suite does not use bpftool at test run-time, so it is sufficient to build bpftool for the build host only. Add ARCH, CROSS_COMPILE, OUTPUT, and TARGETS support to the sched_ext selftest. Also, remove some variables that were unused by the Makefile. Signed-off-by: Bj=C3=B6rn T=C3=B6pel Acked-by: David Vernet Reviewed-by: Mark Brown Reviewed-by: Shuah Khan Tested-by: Mark Brown --- v3: * Always build a build host version of bpftool (Mark) * Make sure LLVM style "ARCH only" cross-build works (Mark) =20 v2: * Removed the duplicated LLVM prefix parsing (David) * Made sure make clean didn't do a complete mess (David) * Added sched_ext to default skip (Shuah) --- tools/testing/selftests/Makefile | 9 +-- tools/testing/selftests/sched_ext/Makefile | 73 ++++++++++------------ 2 files changed, 38 insertions(+), 44 deletions(-) diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Mak= efile index b38199965f99..363d031a16f7 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -88,6 +88,7 @@ TARGETS +=3D rlimits TARGETS +=3D rseq TARGETS +=3D rtc TARGETS +=3D rust +TARGETS +=3D sched_ext TARGETS +=3D seccomp TARGETS +=3D sgx TARGETS +=3D sigaltstack @@ -129,10 +130,10 @@ ifeq ($(filter net/lib,$(TARGETS)),) endif endif =20 -# User can optionally provide a TARGETS skiplist. By default we skip -# BPF since it has cutting edge build time dependencies which require -# more effort to install. -SKIP_TARGETS ?=3D bpf +# User can optionally provide a TARGETS skiplist. By default we skip +# targets using BPF since it has cutting edge build time dependencies +# which require more effort to install. +SKIP_TARGETS ?=3D bpf sched_ext ifneq ($(SKIP_TARGETS),) TMP :=3D $(filter-out $(SKIP_TARGETS), $(TARGETS)) override TARGETS :=3D $(TMP) diff --git a/tools/testing/selftests/sched_ext/Makefile b/tools/testing/sel= ftests/sched_ext/Makefile index 0754a2c110a1..06ae9c107049 100644 --- a/tools/testing/selftests/sched_ext/Makefile +++ b/tools/testing/selftests/sched_ext/Makefile @@ -3,24 +3,13 @@ include ../../../build/Build.include include ../../../scripts/Makefile.arch include ../../../scripts/Makefile.include + +TEST_GEN_PROGS :=3D runner + +# override lib.mk's default rules +OVERRIDE_TARGETS :=3D 1 include ../lib.mk =20 -ifneq ($(LLVM),) -ifneq ($(filter %/,$(LLVM)),) -LLVM_PREFIX :=3D $(LLVM) -else ifneq ($(filter -%,$(LLVM)),) -LLVM_SUFFIX :=3D $(LLVM) -endif - -CC :=3D $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as -else -CC :=3D gcc -endif # LLVM - -ifneq ($(CROSS_COMPILE),) -$(error CROSS_COMPILE not supported for scx selftests) -endif # CROSS_COMPILE - CURDIR :=3D $(abspath .) REPOROOT :=3D $(abspath ../../../..) TOOLSDIR :=3D $(REPOROOT)/tools @@ -34,18 +23,23 @@ GENHDR :=3D $(GENDIR)/autoconf.h SCXTOOLSDIR :=3D $(TOOLSDIR)/sched_ext SCXTOOLSINCDIR :=3D $(TOOLSDIR)/sched_ext/include =20 -OUTPUT_DIR :=3D $(CURDIR)/build +OUTPUT_DIR :=3D $(OUTPUT)/build OBJ_DIR :=3D $(OUTPUT_DIR)/obj INCLUDE_DIR :=3D $(OUTPUT_DIR)/include BPFOBJ_DIR :=3D $(OBJ_DIR)/libbpf SCXOBJ_DIR :=3D $(OBJ_DIR)/sched_ext BPFOBJ :=3D $(BPFOBJ_DIR)/libbpf.a LIBBPF_OUTPUT :=3D $(OBJ_DIR)/libbpf/libbpf.a -DEFAULT_BPFTOOL :=3D $(OUTPUT_DIR)/sbin/bpftool -HOST_BUILD_DIR :=3D $(OBJ_DIR) -HOST_OUTPUT_DIR :=3D $(OUTPUT_DIR) =20 -VMLINUX_BTF_PATHS ?=3D ../../../../vmlinux \ +DEFAULT_BPFTOOL :=3D $(OUTPUT_DIR)/host/sbin/bpftool +HOST_OBJ_DIR :=3D $(OBJ_DIR)/host/bpftool +HOST_LIBBPF_OUTPUT :=3D $(OBJ_DIR)/host/libbpf/ +HOST_LIBBPF_DESTDIR :=3D $(OUTPUT_DIR)/host/ +HOST_DESTDIR :=3D $(OUTPUT_DIR)/host/ + +VMLINUX_BTF_PATHS ?=3D $(if $(O),$(O)/vmlinux) \ + $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ + ../../../../vmlinux \ /sys/kernel/btf/vmlinux \ /boot/vmlinux-$(shell uname -r) VMLINUX_BTF ?=3D $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS)))) @@ -80,17 +74,23 @@ IS_LITTLE_ENDIAN =3D $(shell $(CC) -dM -E - &1 \ +$(shell $(1) $(2) -v -E - &1 \ | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-= idirafter \1|p }') \ -$(shell $(1) -dM -E -