From nobody Fri Jul 24 21:29:49 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A0804429CC8; Fri, 24 Jul 2026 10:25:02 +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=1784888705; cv=none; b=lkP5dw9NEc6ZpOyYoQgWP/I712g9aO1+2DOO4/0RyQdIBkSirmHnrzK7f61eyrYAqW2LZKn74g+p2D7gNVVIFCX2aLdknQNhO8h4oM4jqT8GwV4nXNJ7/YtDiVFA8VqH6aVK7dCZ7Pkf65C1uffxo+og2FCMcIhobCwtQbYEmxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888705; c=relaxed/simple; bh=EfYVwz+NK1/iRlKs2gYESBuvvKYJIJMJC6PoEmXo+N8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BbizyUki55/XPPPE8lzIH8wCV8fbvOdyt7qCn7O8mqbvim+k1FOQZQXLVqH6yARW5itAVAaxM9MQzknqYzd0TPj8wPb1XcAgbGi41NT/uLQYZqu101nJzgqN2glsET4r2XlQqFfewL4yzl7SDqMU/TQgYGnOZ3e2Zgjq2wbvxpg= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=su4bVAnm; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="su4bVAnm" 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 285471595; Fri, 24 Jul 2026 03:24:57 -0700 (PDT) Received: from e142334-100.cambridge.arm.com (e142334-100.cambridge.arm.com [10.2.198.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 227853F66F; Fri, 24 Jul 2026 03:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784888701; bh=EfYVwz+NK1/iRlKs2gYESBuvvKYJIJMJC6PoEmXo+N8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=su4bVAnmZBoo2ATbYQzURgZRjznCKZUwulbqfhLZZiOBoMjqIQ35Hxafm0nvpLpyN aBCNKx1AWIm+hFSLyGvxrPvOjkzmRd6Pif3wv+bV3IKeyS1Ds3KaXKozIMKFQYTIq2 jSxXF2o334/FJKgadnG7nlb2ga1BsRyB+LT1spdI= From: Muhammad Usama Anjum To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shuah Khan , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Miaohe Lin , Naoya Horiguchi , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, sarthak.sharma@arm.com Cc: Muhammad Usama Anjum Subject: [PATCH v2 1/5] selftests/mm: skip COW tmpfile cases when fallocate() is unsupported Date: Fri, 24 Jul 2026 11:24:24 +0100 Message-ID: <20260724102431.1199519-2-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260724102431.1199519-1-usama.anjum@arm.com> References: <20260724102431.1199519-1-usama.anjum@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" The tmpfile-backed COW cases allocate a one-page file with fallocate() before exercising private and shared mappings. When the filesystem backing tmpfile() does not implement fallocate(), setup fails with EOPNOTSUPP and no COW behavior is exercised. This occurs when the temporary directory resides on a filesystem with limited allocation support, such as NFSv3. Reporting a failure adds noise because the test prerequisite is absent rather than the COW implementation being broken. Report EOPNOTSUPP as a skip. Continue treating every other fallocate() error as a failure so unexpected setup regressions remain visible. Tested-by: Sarthak Sharma Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/cow.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/= cow.c index 0c627ea89ff7b..c1b8920e29342 100644 --- a/tools/testing/selftests/mm/cow.c +++ b/tools/testing/selftests/mm/cow.c @@ -1718,8 +1718,13 @@ static void run_with_tmpfile(non_anon_test_fn fn, co= nst char *desc) =20 /* File consists of a single page filled with zeroes. */ if (fallocate(fd, 0, 0, pagesize)) { - ksft_perror("fallocate() failed"); - log_test_result(KSFT_FAIL); + if (errno =3D=3D EOPNOTSUPP) { + ksft_print_msg("fallocate() not supported by filesystem\n"); + log_test_result(KSFT_SKIP); + } else { + ksft_perror("fallocate() failed"); + log_test_result(KSFT_FAIL); + } goto close; } =20 --=20 2.47.3 From nobody Fri Jul 24 21:29:49 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C21E41D228; Fri, 24 Jul 2026 10:25:08 +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=1784888713; cv=none; b=HsHuksLxoKUTypFPD663/0Se54comd82mgjcAXdjimzKPef7gO8/mZfS2hrcdXPK6NaYSjqFqkA/v+zR+O8xaFRtJQmsAmj7cM7lIRg9iyNpIFM34L0uTR/T8eakfe+oxGmVAEIQ380l0LJcWTL9TOeR9WdFBUY6pLK+cvAwJvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888713; c=relaxed/simple; bh=5jwfmfxf7oRAwU0+Iu55SZwsCJdmgyHH7m7BYSAM9vo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=InbAfCyfqUdrsz5BXIIq3+gFNGVyyZQNehV+/vUJywc8xS5BK1SdnO8MJ0II/QlFiIGr+HB3XX6EUHHtS70sPR528UHYf5l7jAOpYb9XHJ8FJ6/q88AvGWCIQTL7WPF8ihO8w8TCBD73uQKP89bq/BB/rmbaxiLhkl9qmpnrDNQ= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=l+ofVQqw; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="l+ofVQqw" 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 283B51477; Fri, 24 Jul 2026 03:25:03 -0700 (PDT) Received: from e142334-100.cambridge.arm.com (e142334-100.cambridge.arm.com [10.2.198.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 997B43F66F; Fri, 24 Jul 2026 03:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784888707; bh=5jwfmfxf7oRAwU0+Iu55SZwsCJdmgyHH7m7BYSAM9vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l+ofVQqwbTWimElc9Yq6VbYs+ZIY7H/dk9jj9QdtduerfU0exNqtADXcl7Ebywpv3 ZRiV4zFxTvg/H56JTHQbkwdG0aSB2CzrzuiXcTkiB+MAedDF3R65iR6j6/O1IqiMU6 4xRa+d0vS16w4oWbEFctoDR7kk5Vb0gqzeyrt0C0= From: Muhammad Usama Anjum To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shuah Khan , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Miaohe Lin , Naoya Horiguchi , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, sarthak.sharma@arm.com Cc: Muhammad Usama Anjum Subject: [PATCH v2 2/5] selftests/mm: skip guard hole-punch test if MADV_REMOVE is unsupported Date: Fri, 24 Jul 2026 11:24:25 +0100 Message-ID: <20260724102431.1199519-3-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260724102431.1199519-1-usama.anjum@arm.com> References: <20260724102431.1199519-1-usama.anjum@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" The hole_punch case verifies that guard regions survive MADV_REMOVE and that the backing range is punched out. MADV_REMOVE delegates the hole punch to the backing filesystem, which may reject the operation with EOPNOTSUPP. That result means the test cannot establish the state whose guard semantics it intends to validate. Treating the missing filesystem capability as a guard-region failure creates a false regression. Unmap the range and skip only when MADV_REMOVE fails with EOPNOTSUPP. Preserve the assertion for all other errors so failures on supported configurations remain visible. Tested-by: Sarthak Sharma Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/guard-regions.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/guard-regions.c b/tools/testing/sel= ftests/mm/guard-regions.c index b21df3040b1c7..5c8ec3ca75d7d 100644 --- a/tools/testing/selftests/mm/guard-regions.c +++ b/tools/testing/selftests/mm/guard-regions.c @@ -1912,7 +1912,7 @@ TEST_F(guard_regions, hole_punch) { const unsigned long page_size =3D self->page_size; char *ptr; - int i; + int i, ret; =20 if (variant->backing =3D=3D ANON_BACKED) SKIP(return, "Truncation test specific to file-backed"); @@ -1944,8 +1944,12 @@ TEST_F(guard_regions, hole_punch) } =20 /* Now hole punch the guarded region. */ - ASSERT_EQ(madvise(&ptr[3 * page_size], 4 * page_size, - MADV_REMOVE), 0); + ret =3D madvise(&ptr[3 * page_size], 4 * page_size, MADV_REMOVE); + if (ret =3D=3D -1 && errno =3D=3D EOPNOTSUPP) { + ASSERT_EQ(munmap(ptr, 10 * page_size), 0); + SKIP(return, "MADV_REMOVE not supported by filesystem"); + } + ASSERT_EQ(ret, 0); =20 /* Ensure guard regions remain. */ for (i =3D 0; i < 10; i++) { --=20 2.47.3 From nobody Fri Jul 24 21:29:49 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3187342B746; Fri, 24 Jul 2026 10:25:14 +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=1784888715; cv=none; b=A/1dSjorjGQHVJJXPEFTfHT50ehLOzx1YYwbLTKJUgsAZ/7hzmpJpUT6nVGwpj7MjXTmSXj0wmZt784vHZIi2b18mzbzXeUQGkrhzGSKWoeR8/dojr3/SnppSpzZpHyJk4VQw1yDeihfnTfs0lJ+MlLw776uhKSqeBvTF3PiSB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888715; c=relaxed/simple; bh=MakI4ukXwu0PoXIFZ3JJzT172oQaQ64yT7zlKhSuUTw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I6qQDfT2rA+JEOVKewo8abG3bAt3U/SXKtJ/07rXpfYpfc0HgDQU4xQzIRQgFC+3B7qB4psithlPtMn/v3FJWrI/1J9K1y5zQRBmEXQ5UtXp4nfej0Jw5KbFki3+vIiI1gqh+YjcxhyOBlPzk6aba1DHzbkDOJzIZTJRM3NJRZk= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=RyUi2Q98; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="RyUi2Q98" 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 854BA1595; Fri, 24 Jul 2026 03:25:08 -0700 (PDT) Received: from e142334-100.cambridge.arm.com (e142334-100.cambridge.arm.com [10.2.198.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 99B2B3F66F; Fri, 24 Jul 2026 03:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784888712; bh=MakI4ukXwu0PoXIFZ3JJzT172oQaQ64yT7zlKhSuUTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RyUi2Q981HswYqVpjbuDTwj78A3tH8i5UuXyjlM507jXF24nM0iAqloacy8W8SZGq Dvyh7DsZXMH6UZa5BzH/h9DKlmHQ75aJzUG5l/zDDHBJHo9mI1AUhOBZZX0jOspoiM 1qqdagny8325f26PjfsJ2imrsIsB9FyvfRnyIzsI= From: Muhammad Usama Anjum To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shuah Khan , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Miaohe Lin , Naoya Horiguchi , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, sarthak.sharma@arm.com Cc: Muhammad Usama Anjum Subject: [PATCH v2 3/5] selftests/mm: skip khugepaged swap tests without swap Date: Fri, 24 Jul 2026 11:24:26 +0100 Message-ID: <20260724102431.1199519-4-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260724102431.1199519-1-usama.anjum@arm.com> References: <20260724102431.1199519-1-usama.anjum@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" collapse_swapin_single_pte and collapse_max_ptes_swap require MADV_PAGEOUT to replace anonymous pages with swap entries. On swapless systems there is no backing store with which to create those entries, so check_swap() reports missing setup rather than broken khugepaged behavior. Swapless configurations are common on Android and other constrained test devices. Failing these cases obscures actionable results from the rest of the khugepaged suite. Check /proc/swaps before either swap-dependent case and skip when no active swap area exists. With swap present, retain the existing MADV_PAGEOUT and swap-entry assertions unchanged. Print each existing swapout diagnostic before the prerequisite check so skip() completes a KTAP diagnostic line instead of emitting an unprefixed message. Signed-off-by: Muhammad Usama Anjum Tested-by: Sarthak Sharma --- Changes since v1: - Print swapout diagnostics before reporting no-swap skips. --- tools/testing/selftests/mm/khugepaged.c | 38 +++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selfte= sts/mm/khugepaged.c index 10e8dedcb087d..54e888eb48bbc 100644 --- a/tools/testing/selftests/mm/khugepaged.c +++ b/tools/testing/selftests/mm/khugepaged.c @@ -100,6 +100,28 @@ static void skip(const char *msg) exit_status =3D KSFT_SKIP; } =20 +static bool is_swap_enabled(void) +{ + char buf[MAX_LINE_LENGTH]; + FILE *file; + bool enabled =3D false; + + file =3D fopen("/proc/swaps", "r"); + if (!file) + return false; + + if (!fgets(buf, sizeof(buf), file)) + goto out; + + /* Check for first active swap entry. */ + if (fgets(buf, sizeof(buf), file)) + enabled =3D true; + +out: + fclose(file); + return enabled; +} + static void save_settings(void) { ksft_print_msg("Save THP and khugepaged settings..."); @@ -734,10 +756,16 @@ static void collapse_swapin_single_pte(struct collaps= e_context *c, struct mem_op { void *p; =20 + ksft_print_msg("Swapout one page..."); + if (!is_swap_enabled()) { + skip("No active swap"); + ksft_test_result_report(exit_status, "%s\n", __func__); + return; + } + p =3D ops->setup_area(1); ops->fault(p, 0, hpage_pmd_size); =20 - ksft_print_msg("Swapout one page..."); if (madvise(p, page_size, MADV_PAGEOUT)) ksft_exit_fail_perror("madvise(MADV_PAGEOUT)"); if (check_swap(p, page_size)) { @@ -760,10 +788,16 @@ static void collapse_max_ptes_swap(struct collapse_co= ntext *c, struct mem_ops *o int max_ptes_swap =3D thp_read_num("khugepaged/max_ptes_swap"); void *p; =20 + ksft_print_msg("Swapout %d of %d pages...", max_ptes_swap + 1, hpage_pmd_= nr); + if (!is_swap_enabled()) { + skip("No active swap"); + ksft_test_result_report(exit_status, "%s\n", __func__); + return; + } + p =3D ops->setup_area(1); ops->fault(p, 0, hpage_pmd_size); =20 - ksft_print_msg("Swapout %d of %d pages...", max_ptes_swap + 1, hpage_pmd_= nr); if (madvise(p, (max_ptes_swap + 1) * page_size, MADV_PAGEOUT)) ksft_exit_fail_perror("madvise(MADV_PAGEOUT)"); if (check_swap(p, (max_ptes_swap + 1) * page_size)) { --=20 2.47.3 From nobody Fri Jul 24 21:29:49 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0317941F7D1; Fri, 24 Jul 2026 10:25:18 +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=1784888721; cv=none; b=khTAK9w8hpFta1VPHi2AT/NSwLkWeq65QFiyjSysPRQ12nT39yyX6nhhMgFnj99296alsq6G982FzeX/PktW07FSx+k7zHwGinW9/FPRjp9X/p37YBeVbNi3W+aGnyDsKYuluhbiJFbfYDiExmICI4qeWM7d0QZDjbaevCVjZ04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888721; c=relaxed/simple; bh=gjhEdojn6ZH69RosJEQqB2oqwaUfEM3sBTnWP0w/g2k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bkjMUmaBhxKLNky9qMvbgDPYBhCyhJuC4iHxi195nZXWLFrE+9w2BzJ6Oo1+yFwV6S7obxYtYC7OxKvNJYcTSR2P6igKAkNVste0640g03y9+pqHkDSt6fFCij3GGDMgnm5xgPRSFQ0VWFHu4bYqbzAu9jiPXTsn2KWHUpckF/0= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=OAemU0+u; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="OAemU0+u" 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 CF5931477; Fri, 24 Jul 2026 03:25:13 -0700 (PDT) Received: from e142334-100.cambridge.arm.com (e142334-100.cambridge.arm.com [10.2.198.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 03FB13F66F; Fri, 24 Jul 2026 03:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784888717; bh=gjhEdojn6ZH69RosJEQqB2oqwaUfEM3sBTnWP0w/g2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OAemU0+uVLTgy6K8UI65WLReaYHpNiL+wmtJLPZk5gycAjgiOTE/Slg8yl+Kx7qEn 6E/dCgnKnZlagJM2f3tiaG3HG7RVvbVNM+YiV/9fXOsHT4FxT/dV1XnVAJIeyCpWmb CQLc8U/xO8szAlH/Z52w4Hajp2pniG8CCVYFh2G8= From: Muhammad Usama Anjum To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shuah Khan , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Miaohe Lin , Naoya Horiguchi , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, sarthak.sharma@arm.com Cc: Muhammad Usama Anjum Subject: [PATCH v2 4/5] selftests/mm: skip hard dirty page-cache test on NFS Date: Fri, 24 Jul 2026 11:24:27 +0100 Message-ID: <20260724102431.1199519-5-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260724102431.1199519-1-usama.anjum@arm.com> References: <20260724102431.1199519-1-usama.anjum@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" The hard dirty_pagecache variant uses MADV_HWPOISON to exercise recovery of a dirty file-backed page. The recovery path records -EIO in the address_space mapping, which NFS later reports when the test closes the file. This makes the test fail after the hwpoison checks have completed. Skip this variant when the test file is on NFS. Keep the hard clean-page and both soft-offline variants enabled because they use folio removal, invalidation, or migration rather than recording a delayed writeback error. The unsupported-filesystem path in clean_pagecache() also returns without closing the opened test file. Close the descriptor before skipping there and in dirty_pagecache(). Signed-off-by: Muhammad Usama Anjum --- Changes since v1: - Limit the NFS skip to the hard dirty-page variant. --- tools/testing/selftests/mm/memory-failure.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/memory-failure.c b/tools/testing/se= lftests/mm/memory-failure.c index 032ed952057c6..3c72084f57e8b 100644 --- a/tools/testing/selftests/mm/memory-failure.c +++ b/tools/testing/selftests/mm/memory-failure.c @@ -283,8 +283,10 @@ TEST_F(memory_failure, clean_pagecache) if (fd < 0) SKIP(return, "failed to open test file.\n"); fs_type =3D get_fs_type(fd); - if (!fs_type || fs_type =3D=3D TMPFS_MAGIC) + if (!fs_type || fs_type =3D=3D TMPFS_MAGIC) { + close(fd); SKIP(return, "unsupported filesystem :%x\n", fs_type); + } =20 addr =3D mmap(0, self->page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); @@ -325,8 +327,11 @@ TEST_F(memory_failure, dirty_pagecache) if (fd < 0) SKIP(return, "failed to open test file.\n"); fs_type =3D get_fs_type(fd); - if (!fs_type || fs_type =3D=3D TMPFS_MAGIC) + if (!fs_type || fs_type =3D=3D TMPFS_MAGIC || + (fs_type =3D=3D NFS_SUPER_MAGIC && variant->type =3D=3D MADV_HARD)) { + close(fd); SKIP(return, "unsupported filesystem :%x\n", fs_type); + } =20 addr =3D mmap(0, self->page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); --=20 2.47.3 From nobody Fri Jul 24 21:29:49 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE5AC42FCBA; Fri, 24 Jul 2026 10:25:24 +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=1784888726; cv=none; b=TRmX15bdDKex5ispis9S0/Lti315GtQf1VbxCgKsJfDzFfNs/g1KAQ5cQeNmt+4oSMEdfbKTF/oWCukDj99x/ut8eZ5Z3NAv7dfBNxB4C8me0XY+f3Og6IAwG/1hOUe/c0qQhnAllaWOoGTZb4znnCReTPh9mL5m/w+4/aQcNJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784888726; c=relaxed/simple; bh=PTkd813JAn6wO/CqG5+sfWiGVF8RyWenBAffF9OaPTk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DXGyhKsYeTrdClBZejXL7DVSgJAOk35Glsu8RlTlXCtqlSIsppoiHEn20zjbKwpFKUj3BFGv18rS88D31fz/Y97Ej6cOjd6+kCnDClzmKJEAjQqSM4Fx6Ig3EqDK3Bk8+a5e1EHybjAX1zROzpCLP+jzWD35jUwwequY0Bujv64= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=SYgESkRN; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="SYgESkRN" 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 53A8C1477; Fri, 24 Jul 2026 03:25:19 -0700 (PDT) Received: from e142334-100.cambridge.arm.com (e142334-100.cambridge.arm.com [10.2.198.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4D3083F66F; Fri, 24 Jul 2026 03:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784888723; bh=PTkd813JAn6wO/CqG5+sfWiGVF8RyWenBAffF9OaPTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYgESkRNnBZJfRvPIAM2Qt/TdjRWqMzPBuD4hU94OL1ezv2gj3cU8HFwZ8nTnwxfm ANbgDoeQZ+2WHT5aRpezBSm9mb/FES6quOK2ZBDucx6beJ1r/uG/Xcs2ktDs2NdTWP umVLYO3cSq91pKgdGhdg2w6PzxcAOjpcG25Vz5Hc= From: Muhammad Usama Anjum To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shuah Khan , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Miaohe Lin , Naoya Horiguchi , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, sarthak.sharma@arm.com Cc: Muhammad Usama Anjum Subject: [PATCH v2 5/5] selftests/mm: retry migration failures for the full runtime Date: Fri, 24 Jul 2026 11:24:28 +0100 Message-ID: <20260724102431.1199519-6-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260724102431.1199519-1-usama.anjum@arm.com> References: <20260724102431.1199519-1-usama.anjum@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" move_pages() is best effort and can temporarily fail when concurrent faults race with page unmapping. A busy shared-anon workload can exhaust the current 100 retries long before the intended 20-second runtime and produce a false failure. Use the full runtime as the retry window. Since the initial page location is unknown, require it to reach both alternating NUMA targets to confirm that cross-node migration made progress despite transient contention. Signed-off-by: Muhammad Usama Anjum --- Changes since v1: - Retry per-page failures for the full runtime - Verify that both alternating NUMA targets are reached --- tools/testing/selftests/mm/migration.c | 39 ++++++++++++++------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftes= ts/mm/migration.c index 29f7492453d43..4d55a424058a9 100644 --- a/tools/testing/selftests/mm/migration.c +++ b/tools/testing/selftests/mm/migration.c @@ -7,7 +7,7 @@ #include "kselftest_harness.h" #include "hugepage_settings.h" =20 -#include +#include #include #include #include @@ -20,7 +20,6 @@ =20 #define TWOMEG (2<<20) #define RUNTIME (20) -#define MAX_RETRIES 100 #define ALIGN(x, a) (((x) + (a - 1)) & (~((a) - 1))) =20 HUGETLB_SETUP_DEFAULT_PAGES(1) @@ -110,7 +109,7 @@ int migrate(uint64_t *ptr, int n1, int n2) int ret, tmp; int status =3D 0; struct timespec ts1, ts2; - int failures =3D 0; + int success =3D 0; =20 if (clock_gettime(CLOCK_MONOTONIC, &ts1)) return -1; @@ -119,29 +118,33 @@ int migrate(uint64_t *ptr, int n1, int n2) if (clock_gettime(CLOCK_MONOTONIC, &ts2)) return -1; =20 - if (ts2.tv_sec - ts1.tv_sec >=3D RUNTIME) - return 0; + if (ts2.tv_sec - ts1.tv_sec >=3D RUNTIME) { + /* Reaching both targets verifies a cross-node move. */ + if (success >=3D 2) + return 0; + else + return -2; + } =20 ret =3D move_pages(0, 1, (void **) &ptr, &n2, &status, MPOL_MF_MOVE_ALL); - if (ret) { - if (ret > 0) { - /* Migration is best effort; try again */ - if (++failures < MAX_RETRIES) - continue; - printf("Didn't migrate %d pages\n", ret); - } - else - perror("Couldn't migrate pages"); - return -2; + if (ret < 0) { + perror("Couldn't migrate pages"); + return ret; } - failures =3D 0; + /* Migration is best effort. Try again */ + if (ret > 0 || status < 0) + continue; + if (status !=3D n2) { + printf("Page is on node %d instead of target node %d\n", + status, n2); + return status; + } + success++; tmp =3D n2; n2 =3D n1; n1 =3D tmp; } - - return 0; } =20 void *access_mem(void *ptr) --=20 2.47.3