From nobody Mon Feb 9 17:23:22 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E6D634A3D0; Wed, 7 Jan 2026 16:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767804543; cv=none; b=hdmq63wBJHcCk+AG1yqXR10L06Dw5dXRrYlHaGHm3mO9C5XJaskPt8ze5j95TWqmiHrhH1YOKmMPnAOhxi5F8uAv5UataDPXl8TiO/frQF6xK94NUbFAu6qUZgTvJ2+aoS0ws4+A9J8ej0+J5SkJLKXScOJMmO9crlqePuW+KMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767804543; c=relaxed/simple; bh=ZNRxNFE32weRNSCQI7tMxuz6rq0DOTVV9Nj6X02kyMk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HGFGVvejFn+04gEGYxatp3n+fQzPd3o8U1biJhsAkjirzWRd6gGWsvWNh4YHtmf+v/qob8dcqvnMFyrFETFyvk4CTImvLMXm2Pytww6CEeBe4BvELpWgABRCyDKdSdOa2KoHuDtPQnVxX8IvzbMmZnP8upptMGrsu7H9ursecVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A5ED81595; Wed, 7 Jan 2026 08:48:45 -0800 (PST) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 434633F5A1; Wed, 7 Jan 2026 08:48:51 -0800 (PST) From: Kevin Brodsky To: linux-mm@kvack.org, linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , Mark Brown , Ryan Roberts , Shuah Khan Subject: [PATCH v2 1/8] selftests/mm: default KDIR to build directory Date: Wed, 7 Jan 2026 16:48:35 +0000 Message-ID: <20260107164842.3289559-2-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260107164842.3289559-1-kevin.brodsky@arm.com> References: <20260107164842.3289559-1-kevin.brodsky@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" KDIR currently defaults to the running kernel's modules directory when building the page_frag module. The underlying assumption is that most users build the kselftests in order to run them against the system they're built on. This assumption seems questionable, and there is no guarantee that the module can actually be built against the running kernel. Switch the default value of KDIR to the kernel's build directory, i.e. $(O) if O=3D or KBUILD_OUTPUT=3D is used, and the source directory otherwise. This seems like the least surprising option: the test module is built against the kernel that has been previously built. Note: we can't use $(top_srcdir) in mm/Makefile because it is only defined once lib.mk is included. Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/Makefile | 2 +- tools/testing/selftests/mm/page_frag/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/= mm/Makefile index eaf9312097f7..bb93101e339e 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -44,7 +44,7 @@ LDLIBS =3D -lrt -lpthread -lm # warnings. CFLAGS +=3D -U_FORTIFY_SOURCE =20 -KDIR ?=3D /lib/modules/$(shell uname -r)/build +KDIR ?=3D $(if $(O),$(O),$(realpath ../../../..)) ifneq (,$(wildcard $(KDIR)/Module.symvers)) ifneq (,$(wildcard $(KDIR)/include/linux/page_frag_cache.h)) TEST_GEN_MODS_DIR :=3D page_frag diff --git a/tools/testing/selftests/mm/page_frag/Makefile b/tools/testing/= selftests/mm/page_frag/Makefile index 8c8bb39ffa28..96e5f646e69b 100644 --- a/tools/testing/selftests/mm/page_frag/Makefile +++ b/tools/testing/selftests/mm/page_frag/Makefile @@ -1,5 +1,5 @@ PAGE_FRAG_TEST_DIR :=3D $(realpath $(dir $(abspath $(lastword $(MAKEFILE_L= IST))))) -KDIR ?=3D /lib/modules/$(shell uname -r)/build +KDIR ?=3D $(if $(O),$(O),$(realpath ../../../../..)) =20 ifeq ($(V),1) Q =3D --=20 2.51.2