From patchwork Fri Oct 4 09:42:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13822032 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D0ACCFA74C for ; Fri, 4 Oct 2024 09:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=XzxFbYKsqh+aHzwsXMkPUHJSxM5DAknZ/WyFzZZhnoY=; b=QcEIAs1kDjhKCd ZGtkWkTKlqLWkLXZRJ5SMCP67+J9zOiwDHXJzlZ+R74IaUILUOTkESfQuei8OwWrSkvsmH0B0Yfmh yHukQZakidPI6h1JlZ9emZ1U00E4dNdEBqGDpqtZEMFdiiSKH6Cz0h3lhh/RLlcXqoC++yx0MunbJ deYPxUikd0sLL9S1yJtRdlPnpeIF/f8wQqJ9P2GXNPkIduyxiYVh0hp6TJqs8WbDv82CKhL45m95k S+O7B6cdUfOa90aflw/7ldqLlsGyQ8o4Tu5ReGZtZo3rbcTt392lFKLrjBJc03DAWyRWm1i45evB5 zU/ZpAshFxWrJZXIY1bg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swexO-0000000BiSq-1I4H; Fri, 04 Oct 2024 09:50:42 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swepw-0000000BgOw-3iWh for linux-riscv@lists.infradead.org; Fri, 04 Oct 2024 09:43:02 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 3E9E8A4453B; Fri, 4 Oct 2024 09:42:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76F50C4CEC6; Fri, 4 Oct 2024 09:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728034979; bh=SzhRbPk78jtGFOBCsX0ZbmHldM75YK5G46pTsUz7W2A=; h=From:To:Cc:Subject:Date:From; b=K6O24UIrnQLvTn2gf3tB4sV3i5xDEFVB8dYD+wUb7ntkgmHrol4txY5c1cCuaD/Fp gO5mQrMCLw/Lwjmhzuu5bj9lkgYwNXUNrYysI9LO+0OarhhTP0gD2/mwHU5jlanowY 236S4FQ0Jw5Nx377/hmDZaIPvZ4beLHmqREhQ+vXmW/k52t/upg3CY8ouuTCL31+EB 9uPvLAb9xAQBNliOtgTfhZWGuTmtGhDwpKGhZw6A2GLMiSrycHgnqdy4SB1ZrRa+nX JpsIfIEx6FDaDyNspvZkNAO70gb1i1JqmPrNmUv3lEw7NTrz918G2220FK/4I5cGGN 1ZhZ+KWb9tbQw== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Tejun Heo , David Vernet , Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , bpf@vger.kernel.org, linux-riscv@lists.infradead.org, Anders Roxell Subject: [PATCH] selftests: sched_ext: Add sched_ext as proper selftest target Date: Fri, 4 Oct 2024 11:42:46 +0200 Message-ID: <20241004094247.795385-1-bjorn@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241004_024301_102294_E5D852E0 X-CRM114-Status: UNSURE ( 7.94 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel 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=riscv CROSS_COMPILE=riscv64-linux-gnu- \ SKIP_TARGETS="" O=/output/foo -C tools/testing/selftests install The expectation is that the sched_ext is included, cross-built, and placed into /output/foo. Add CROSS_COMPILE, OUTPUT, and TARGETS support to the sched_ext selftest. Signed-off-by: Björn Töpel Reviewed-by: Shuah Khan --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/sched_ext/Makefile | 59 +++++++++++++++------- 2 files changed, 41 insertions(+), 19 deletions(-) base-commit: 0c559323bbaabee7346c12e74b497e283aaafef5 diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index b38199965f99..20ee8a0b795c 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -88,6 +88,7 @@ TARGETS += rlimits TARGETS += rseq TARGETS += rtc TARGETS += rust +TARGETS += sched_ext TARGETS += seccomp TARGETS += sgx TARGETS += sigaltstack diff --git a/tools/testing/selftests/sched_ext/Makefile b/tools/testing/selftests/sched_ext/Makefile index 0754a2c110a1..66467a99184d 100644 --- a/tools/testing/selftests/sched_ext/Makefile +++ b/tools/testing/selftests/sched_ext/Makefile @@ -13,14 +13,8 @@ LLVM_SUFFIX := $(LLVM) endif CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as -else -CC := gcc endif # LLVM -ifneq ($(CROSS_COMPILE),) -$(error CROSS_COMPILE not supported for scx selftests) -endif # CROSS_COMPILE - CURDIR := $(abspath .) REPOROOT := $(abspath ../../../..) TOOLSDIR := $(REPOROOT)/tools @@ -34,18 +28,39 @@ GENHDR := $(GENDIR)/autoconf.h SCXTOOLSDIR := $(TOOLSDIR)/sched_ext SCXTOOLSINCDIR := $(TOOLSDIR)/sched_ext/include -OUTPUT_DIR := $(CURDIR)/build +ifeq (,$(OUTPUT)) +OUTPUT := $(CURDIR)/build +RUNNER_DIR := $(CURDIR) +else +OUTPUT_DIR := $(OUTPUT) +RUNNER_DIR := $(OUTPUT) +endif OBJ_DIR := $(OUTPUT_DIR)/obj INCLUDE_DIR := $(OUTPUT_DIR)/include BPFOBJ_DIR := $(OBJ_DIR)/libbpf SCXOBJ_DIR := $(OBJ_DIR)/sched_ext BPFOBJ := $(BPFOBJ_DIR)/libbpf.a LIBBPF_OUTPUT := $(OBJ_DIR)/libbpf/libbpf.a -DEFAULT_BPFTOOL := $(OUTPUT_DIR)/sbin/bpftool HOST_BUILD_DIR := $(OBJ_DIR) HOST_OUTPUT_DIR := $(OUTPUT_DIR) -VMLINUX_BTF_PATHS ?= ../../../../vmlinux \ +ifneq ($(CROSS_COMPILE),) +DEFAULT_BPFTOOL := $(OUTPUT_DIR)/host/sbin/bpftool +HOST_OBJ_DIR := $(OBJ_DIR)/host/bpftool +HOST_LIBBPF_OUTPUT := $(OBJ_DIR)/host/libbpf/ +HOST_LIBBPF_DESTDIR := $(OUTPUT_DIR)/host/ +HOST_DESTDIR := $(OUTPUT_DIR)/host/ +else +DEFAULT_BPFTOOL := $(OUTPUT_DIR)/sbin/bpftool +HOST_OBJ_DIR := $(OBJ_DIR)/bpftool +HOST_LIBBPF_OUTPUT := $(OBJ_DIR)/libbpf/ +HOST_LIBBPF_DESTDIR := $(OUTPUT_DIR)/ +HOST_DESTDIR := $(OUTPUT_DIR)/ +endif + +VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \ + $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ + ../../../../vmlinux \ /sys/kernel/btf/vmlinux \ /boot/vmlinux-$(shell uname -r) VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS)))) @@ -80,17 +95,23 @@ IS_LITTLE_ENDIAN = $(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 -