From nobody Sun Feb 8 18:38:07 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30064345CAF; Tue, 16 Dec 2025 14:26:43 +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=1765895205; cv=none; b=MWAOTV18p5F7rjaIX4m3aAld6cCdSJIQ4URrw0e1ELlUOTlXhWlwW9wJWwxDnobh9QK0Ml5NnhhSxv3PcpWsj4eKVwYG1UnVoSwx+B+G0CWCG6zWGqy5dqdgKewu66X9hOSYGKpbc8QAAVxZIRykf3z5v4+wPc5uEIEveQYWhaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895205; c=relaxed/simple; bh=ulRaCuI2R5Ra/9l8IWLGkwcmHbKAofBAfOXkEXfB1u4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RKQxIfU84bHLQhVdVBmZeOqN0m28J95ZKQjemkrX4Ve2gcuhaTBtGDOhIylPs4rRRlajBf3dmfrIH6R29cUTzZYrMuFy9St4ndA2OR9QPS/9ocxhWxyY/2AnCPf7lhWrbfvZUvNkCMWfvY9+UWgF0kEOaYsUxYvnbjL90lmp/Sg= 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 66CE41516; Tue, 16 Dec 2025 06:26:36 -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 C36F83F694; Tue, 16 Dec 2025 06:26:41 -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 , Paolo Abeni , Yunsheng Lin Subject: [PATCH 1/4] selftests/mm: remove flaky header check Date: Tue, 16 Dec 2025 14:26:30 +0000 Message-ID: <20251216142633.2401447-2-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251216142633.2401447-1-kevin.brodsky@arm.com> References: <20251216142633.2401447-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" Commit 96ed62ea0298 ("mm: page_frag: fix a compile error when kernel is not compiled") introduced a check to avoid attempting to build the page_frag module if is missing. Unfortunately this check only works if KDIR points to /lib/modules/... or an in-tree kernel build. It always fails if KDIR points to an out-of-tree build (i.e. when the kernel was built with O=3D$KDIR make) because only generated headers are present under $KDIR/include/ in that case. was added more than a year ago (v6.13) so we can probably live without that check. Cc: Paolo Abeni Cc: Yunsheng Lin Signed-off-by: Kevin Brodsky Reviewed-by: Mark Brown --- tools/testing/selftests/mm/Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/= mm/Makefile index eaf9312097f7..aba51fcac752 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -46,12 +46,8 @@ CFLAGS +=3D -U_FORTIFY_SOURCE =20 KDIR ?=3D /lib/modules/$(shell uname -r)/build ifneq (,$(wildcard $(KDIR)/Module.symvers)) -ifneq (,$(wildcard $(KDIR)/include/linux/page_frag_cache.h)) TEST_GEN_MODS_DIR :=3D page_frag else -PAGE_FRAG_WARNING =3D "missing page_frag_cache.h, please use a newer kerne= l" -endif -else PAGE_FRAG_WARNING =3D "missing Module.symvers, please have the kernel buil= t first" endif =20 --=20 2.51.2 From nobody Sun Feb 8 18:38:07 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EAA934D4FC; Tue, 16 Dec 2025 14:26:46 +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=1765895208; cv=none; b=ozJ6swu27m8i/7H8JQNZmYOWhyoVW3OskfZWtjB9+fbTdNU9q8daLnyFpaOVQpO8LDOIAwz5SjWwMXzf4KW1ovkcgzwspxPfdefuQ++WR+gx0xM5B+3Tih2DLAO88bs+8QyrRH72NrBdeUFTcHZ4F6p+UwN7+fgGi8DTxmo3wII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895208; c=relaxed/simple; bh=U4hCZ8wUvvDGQzG+n7uZ1G4Ep5Ld7dyY7Pd282Fcp+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZlCHk1BUY4DBgiuogzcPpLwOL8bT+Stw8LIOH1+OrkquBvi8LDekEFIz8EQzSCQNdK+fs4gR6WqsO/FhJ23LR92xvV0+iWqq70WtrjU8yWjHgqQMg1OcfRmt/f+KaLD8V3WTYRYt1H6Ex3+bUx9mKuR3o4x5oOUkH1WqgYdWpfU= 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 7A11FFEC; Tue, 16 Dec 2025 06:26:38 -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 D20423F694; Tue, 16 Dec 2025 06:26:43 -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 , Jason Gunthorpe , John Hubbard Subject: [PATCH 2/4] selftests/mm: pass down full CC and CFLAGS to check_config.sh Date: Tue, 16 Dec 2025 14:26:31 +0000 Message-ID: <20251216142633.2401447-3-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251216142633.2401447-1-kevin.brodsky@arm.com> References: <20251216142633.2401447-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" check_config.sh checks that liburing is available by running the compiler provided as its first argument. This makes two assumptions: 1. CC consists of only one word 2. No extra flag is required Unfortunately, there are many situations where these assumptions don't hold. For instance: - When using Clang, CC consists of multiple words - When cross-compiling, extra flags may be required to allow the compiler to find headers Remove these assumptions by passing down CC and CFLAGS as-is from the Makefile, so that the same command line is used as when actually building the tests. Cc: Jason Gunthorpe Cc: John Hubbard Signed-off-by: Kevin Brodsky Acked-by: David Hildenbrand (Red Hat) --- tools/testing/selftests/mm/Makefile | 2 +- tools/testing/selftests/mm/check_config.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/= mm/Makefile index aba51fcac752..b1c949cd7c3d 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -230,7 +230,7 @@ $(OUTPUT)/migration: LDLIBS +=3D -lnuma $(OUTPUT)/rmap: LDLIBS +=3D -lnuma =20 local_config.mk local_config.h: check_config.sh - /bin/sh ./check_config.sh $(CC) + CC=3D"$(CC)" CFLAGS=3D"$(CFLAGS)" ./check_config.sh =20 EXTRA_CLEAN +=3D local_config.mk local_config.h =20 diff --git a/tools/testing/selftests/mm/check_config.sh b/tools/testing/sel= ftests/mm/check_config.sh index 3954f4746161..b84c82bbf875 100755 --- a/tools/testing/selftests/mm/check_config.sh +++ b/tools/testing/selftests/mm/check_config.sh @@ -16,8 +16,7 @@ echo "#include " > $tmpfile_c echo "#include " >> $tmpfile_c echo "int func(void) { return 0; }" >> $tmpfile_c =20 -CC=3D${1:?"Usage: $0 # example compiler: gcc"} -$CC -c $tmpfile_c -o $tmpfile_o >/dev/null 2>&1 +$CC $CFLAGS -c $tmpfile_c -o $tmpfile_o =20 if [ -f $tmpfile_o ]; then echo "#define LOCAL_CONFIG_HAVE_LIBURING 1" > $OUTPUT_H_FILE --=20 2.51.2 From nobody Sun Feb 8 18:38:07 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33EFC34DCC9; Tue, 16 Dec 2025 14:26:47 +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=1765895209; cv=none; b=Rmvf1lVmG2B5U9Oao1gxcH/JzwmV55bYd1s/BxP2cnYdYndhGNplh2Q2f4P+rByVhe7Fwj0sB+Qctr1s/Avuj/F42UONyCSDnd/6BU9MJoWQNM4+ycRzuI6pK6H3VyJFRPbFjaf/EBAD/HIJtsdyNhMZ9Qw2x88vKzaXwnee6U0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895209; c=relaxed/simple; bh=MEpleqSyHmmuXw4jN3hkUoZ62o9IG0pEB5h1GLOHmfM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UNmk+vf1NxFDnPfNBacynfPy0IItJ5k3cuej/+3rj1ei8aB+KAL7u9OIvKVEyPeJxuCsYVXGbr+zE2zTxRi6O4HOdcrPyGMplTNo9VTYAHq7C9hIj/UpA3zanlI0G4h6WHN4+Nmb4ZohCG1N5ntm4sFkJggwW1qqV/UplyirW0U= 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 6F1771655; Tue, 16 Dec 2025 06:26:40 -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 E9A833F694; Tue, 16 Dec 2025 06:26:45 -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 , Usama Anjum Subject: [PATCH 3/4] selftests/mm: fix faulting-in code in pagemap_ioctl test Date: Tue, 16 Dec 2025 14:26:32 +0000 Message-ID: <20251216142633.2401447-4-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251216142633.2401447-1-kevin.brodsky@arm.com> References: <20251216142633.2401447-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" One of the pagemap_ioctl tests attempts to fault in pages by memcpy()'ing them to an unused buffer. This probably worked originally, but since commit 46036188ea1f ("selftests/mm: build with -O2") the compiler is free to optimise away that unused buffer and the memcpy() with it. As a result there might not be any resident page in the mapping and the test may fail. We don't need to copy all that memory anyway. Just fault in every page by forcing the compiler to read the first byte. Cc: Usama Anjum Signed-off-by: Kevin Brodsky --- tools/testing/selftests/mm/pagemap_ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/pagemap_ioctl.c b/tools/testing/sel= ftests/mm/pagemap_ioctl.c index 2cb5441f29c7..67a7a3705604 100644 --- a/tools/testing/selftests/mm/pagemap_ioctl.c +++ b/tools/testing/selftests/mm/pagemap_ioctl.c @@ -1056,7 +1056,6 @@ int sanity_tests(void) struct page_region *vec; char *mem, *fmem; struct stat sbuf; - char *tmp_buf; =20 /* 1. wrong operation */ mem_size =3D 10 * page_size; @@ -1167,8 +1166,9 @@ int sanity_tests(void) if (fmem =3D=3D MAP_FAILED) ksft_exit_fail_msg("error nomem %d %s\n", errno, strerror(errno)); =20 - tmp_buf =3D malloc(sbuf.st_size); - memcpy(tmp_buf, fmem, sbuf.st_size); + /* Fault in every page by reading the first byte */ + for (i =3D 0; i < sbuf.st_size; i +=3D page_size) + (void)*(volatile char *)(fmem + i); =20 ret =3D pagemap_ioctl(fmem, sbuf.st_size, vec, vec_size, 0, 0, 0, PAGEMAP_NON_WRITTEN_BITS, 0, PAGEMAP_NON_WRITTEN_BITS); --=20 2.51.2 From nobody Sun Feb 8 18:38:07 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EB2934EEE6; Tue, 16 Dec 2025 14:26:49 +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=1765895211; cv=none; b=Cw9JnIPkqWy/e/a9RLQlxp99T2OakL721R/7LlLVnueFj4P6ggtHop+yZhOvRkBL5IlwJl7cZF7zKiKtBVtlO+dxKJ7FI4Hg9zGxSbojcjMbSiuPD6iYcrj8ft/XsRp8LjStGzdzxXRGs5mg8/7UhtH/nbGgpXPH+uJOGvkHGAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765895211; c=relaxed/simple; bh=z1V8GlOYPhY/gKBIlYErfARVC1g7kXpU/U0qEsxwYok=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=goCD6pqHpO4XrD6MgD+R7lq7p6LHVBmgOJwtdsrX8b+xn4PZ7mgEH7s201d35VGeAu6au1FrTrqfNboT/WsUFBLV/5ulsh3sP1JAhSE3tc2lcdirc55BXCZdPMrKFpGC5XwwWqvGZSpgjP3c9aJOsuR3X40AMPZjrnzP8rNHfkk= 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 5CB851682; Tue, 16 Dec 2025 06:26:42 -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 DD66A3F694; Tue, 16 Dec 2025 06:26:47 -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 , Usama Anjum Subject: [PATCH 4/4] selftests/mm: fix exit code in pagemap_ioctl Date: Tue, 16 Dec 2025 14:26:33 +0000 Message-ID: <20251216142633.2401447-5-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251216142633.2401447-1-kevin.brodsky@arm.com> References: <20251216142633.2401447-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" pagemap_ioctl always reports success, whether the tests succeeded or not. Call ksft_finished() to report the right status. While at it also fix the exit code in unexpected situations: - Report SKIP if userfaultfd isn't available (in line with other tests) - Report FAIL if we failed to open /proc/self/pagemap (returning -EINVAL from main() is meaningless) Cc: Usama Anjum Signed-off-by: Kevin Brodsky Acked-by: David Hildenbrand (Red Hat) Reviewed-by: Mark Brown Reviewed-by: Ryan Roberts --- tools/testing/selftests/mm/pagemap_ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/pagemap_ioctl.c b/tools/testing/sel= ftests/mm/pagemap_ioctl.c index 67a7a3705604..aeedb96dfffb 100644 --- a/tools/testing/selftests/mm/pagemap_ioctl.c +++ b/tools/testing/selftests/mm/pagemap_ioctl.c @@ -1553,7 +1553,7 @@ int main(int __attribute__((unused)) argc, char *argv= []) ksft_print_header(); =20 if (init_uffd()) - ksft_exit_pass(); + ksft_exit_skip("Failed to initialize userfaultfd\n"); =20 ksft_set_plan(117); =20 @@ -1562,7 +1562,7 @@ int main(int __attribute__((unused)) argc, char *argv= []) =20 pagemap_fd =3D open(PAGEMAP, O_RDONLY); if (pagemap_fd < 0) - return -EINVAL; + ksft_exit_fail_msg("Failed to open " PAGEMAP "\n"); =20 /* 1. Sanity testing */ sanity_tests_sd(); @@ -1734,5 +1734,5 @@ int main(int __attribute__((unused)) argc, char *argv= []) zeropfn_tests(); =20 close(pagemap_fd); - ksft_exit_pass(); + ksft_finished(); } --=20 2.51.2