From nobody Fri Jul 24 23:30:47 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0DE43E3DBE; Wed, 22 Jul 2026 09:12:30 +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=1784711553; cv=none; b=pZNjFUQh5wDUAKOpppgWTrky1sT5PH/C/njKiTzQv2/IlAciXm+EcByJoWsHYI7RkYS5E1vDw3j87ciITTxWVoqnbi7qOVnXOb5kArOuqIH1cFuQjgj3bMXD0PSbZKFaQsx15UafBfv/xLEOCqchfU/qSOrwZwETjRBYsFSrnTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784711553; c=relaxed/simple; bh=UkCBixZE4BaIDZgj4iTqd571WFG+D+00A3uwsD0HWlU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dTQyF1de9QV8PpDrEsiD6xCG7aCAN10Jik3C2Ns/RTUesUBiMNcvP9e+0jPOFC3yRp/3Kz0m6PVWAUX1Og+yocwyysYgyo7jOooTic6cEPE3p9ttA8JFxq6RsaLqsFmUmboQYGdYc2slvVrFp/S9rh1IV7PO++gjfVkG0MaeSS0= 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=T1kpQAfc; 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="T1kpQAfc" 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 1A27D168F; Wed, 22 Jul 2026 02:12:26 -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 227653F86F; Wed, 22 Jul 2026 02:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784711550; bh=UkCBixZE4BaIDZgj4iTqd571WFG+D+00A3uwsD0HWlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T1kpQAfcd1h63oG/X29DlrT88eBxwgQGQCmu88mokQ5ya8rJ4hg9ZAOrdZBp/Kd4T zBcqkQYi93Zejo75X4d3zx+HAO0JoSr6pm/Iw/qqXemVOGO6fuVp24q8y+VRaOLsQE KSovYlksTVclqD9AuVzmhvnFkXVIIxEfDFVDKn8I= 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 Cc: Muhammad Usama Anjum Subject: [PATCH RESEND v1 1/5] selftests/mm: skip COW tmpfile cases when fallocate() is unsupported Date: Wed, 22 Jul 2026 10:11:35 +0100 Message-ID: <20260722091219.61504-2-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260722091219.61504-1-usama.anjum@arm.com> References: <20260722091219.61504-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. Signed-off-by: Muhammad Usama Anjum Tested-by: Sarthak Sharma --- 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 23:30:47 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 738FE4949EC; Wed, 22 Jul 2026 09:12:34 +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=1784711556; cv=none; b=UAH2qJ2phLynv67A/PmEBHZ1PKky3N2DZHlOTehVRk/KpCQzb9ppYbuQPZOlHLZmhPkxjVC916yus8YTYgbEC+mc5zns3T6UWGY+dHXba2v7Tgt0WBx20HD27vj1Q4wqDuveKL9XQahZfO+72meTYpnW1/wipKqEV7OG0ZYlFDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784711556; c=relaxed/simple; bh=czI4JpkN5r6Pglkijn4J8uwR+W7cYaCz20UvFW25E0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i79oKm3Ymnw8YubzgVCvyC2dosh5j+43c4scey4uiJRymA5ZTaTzT92mVAul2AOQFEORoiuuYMEr/h45zOhLSyWk5cLutN4yJyqxl7hVy9p8OXdCfh/Bqx+4Gto4oDqLaA/frq32XVjnJ7PzDdN/mZp9EUrPWSN2T5kuHBuxO9g= 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=EmAJ1LXn; 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="EmAJ1LXn" 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 82E901595; Wed, 22 Jul 2026 02:12:29 -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 8FFA03F86F; Wed, 22 Jul 2026 02:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784711553; bh=czI4JpkN5r6Pglkijn4J8uwR+W7cYaCz20UvFW25E0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EmAJ1LXnbyStBWZbM+XZg5iX3laoJLf10NFRGKMkjGikFAFWrOYZsGWQfQA7P06+l MWHlx+JH85ZMa8pFF2rSs2oP7f0pfganXr7pKQvt60cxXDGGO/l2vD0BKxmIV9ARmZ e7vXe48ntKqdSUc4bXVJMnjCIV2L9+NEpIhsSzxY= 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 Cc: Muhammad Usama Anjum Subject: [PATCH RESEND v1 2/5] selftests/mm: skip guard hole-punch test if MADV_REMOVE is unsupported Date: Wed, 22 Jul 2026 10:11:36 +0100 Message-ID: <20260722091219.61504-3-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260722091219.61504-1-usama.anjum@arm.com> References: <20260722091219.61504-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. Signed-off-by: Muhammad Usama Anjum Tested-by: Sarthak Sharma --- 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 23:30:47 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50DA6495517; Wed, 22 Jul 2026 09:12:38 +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=1784711559; cv=none; b=cfPjOsCznuwvL2u2N9el8F3QT7BqejEom4d7bUzFn64dmqJ7HStGwz3qFzpizM31nlKmIYEQb7dmVIW2HYs7C5tqhTPxyjfNkP5EDfGKh4jrkuvAgLgH+AAX4UhvwVcBK1zmqtJv4+qArueyCZQ9xbyhoG7syUi4NhJt0FlcaO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784711559; c=relaxed/simple; bh=FcfLiMt+bHeoQiYgQH5BUPvM3W4w/RBin08nosAKQeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tMXhpzdcUvyZU22wad07H0rcZO7n7YExcI1wcQETG62CXmQmt1kxK+nTWojF8x9R8H+3w6n10jT6xeQjRTiVLQlbDD9f2nWuO43UBwLxls+uzsWayr6vY54ZIW6gtDJ9nsW5qQESXGDtbuKjGLMQ44u6lPOrCzRd2vOCRD/ybD4= 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=t5D8ftkW; 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="t5D8ftkW" 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 F0C641595; Wed, 22 Jul 2026 02:12:32 -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 0A48E3F86F; Wed, 22 Jul 2026 02:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784711557; bh=FcfLiMt+bHeoQiYgQH5BUPvM3W4w/RBin08nosAKQeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t5D8ftkWCpH0Wn6f4iz0gui8c3irSjSWBII9enx1vmobNdM98AaccGRsapWj/3DAU pfkC30kUr7+goUvx4twrTbq96meG8jPrtAXXN5JszxbxqQSc0afhMFDQJNGLOpG7Ij bA8RtIE92vtzRZycWvxm89X05Y14MVWCt44pZVfc= 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 Cc: Muhammad Usama Anjum Subject: [PATCH RESEND v1 3/5] selftests/mm: skip khugepaged swap tests without swap Date: Wed, 22 Jul 2026 10:11:37 +0100 Message-ID: <20260722091219.61504-4-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260722091219.61504-1-usama.anjum@arm.com> References: <20260722091219.61504-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. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/khugepaged.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selfte= sts/mm/khugepaged.c index 10e8dedcb087d..a152cec59fcbd 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,6 +756,12 @@ static void collapse_swapin_single_pte(struct collapse= _context *c, struct mem_op { void *p; =20 + 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 @@ -760,6 +788,12 @@ static void collapse_max_ptes_swap(struct collapse_con= text *c, struct mem_ops *o int max_ptes_swap =3D thp_read_num("khugepaged/max_ptes_swap"); void *p; =20 + 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 --=20 2.47.3 From nobody Fri Jul 24 23:30:47 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62D643E3167; Wed, 22 Jul 2026 09:12:41 +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=1784711563; cv=none; b=m7Q8mHeaHSAGRCisRRsSIz6oQI7eK42EGGh0iMhOF1HI+flAvHkLURMDqL3Lybp0vXMjckaCkVhxHbwh8D5Q2xwJcIIfXkBljkibjaec1W1sI8RtjLTE2KYK942euXq2l2OBVYHCkQop2lXOIQmNT5IOzM4crgxH5P29cWP+ELI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784711563; c=relaxed/simple; bh=MAOIk6RQMMHP9g8q0wW7WPE1XWmO8u6cAL0GlkkzBe4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O4VYfKrJJ1hoa/HpVeHlskdWtBMe6bGsIO11jfJRfZOC9YfANRFG+W8diYwojQVQjs88GypFLhYEztXozveK00nUax8eMA7xa3XjyKwvfPFuCU/7T7x0a0S7exZa8zsLVj4xax7mC+LoqGWE39sBPNGku/EbVbXf09k6V+ebfQw= 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=rEfmwAtQ; 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="rEfmwAtQ" 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 6FED11691; Wed, 22 Jul 2026 02:12:36 -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 77C063F86F; Wed, 22 Jul 2026 02:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784711560; bh=MAOIk6RQMMHP9g8q0wW7WPE1XWmO8u6cAL0GlkkzBe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rEfmwAtQp5FzBpgznxbXzbVFSASRpkEAKRKrsxYS6t7OaDOvBhG7lXHIMH9aMs83S 5q0Ogl46PYCxE4UsX2On99Aa72x+SQlwXDYDlbWwiki1/+Rwonheoe9fNeCyXF0MUA znm6WmOEtVQtpUpIP2CKY8gH9TW6Njp6WSrckMmY= 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 Cc: Muhammad Usama Anjum Subject: [PATCH RESEND v1 4/5] selftests/mm: skip page-cache hwpoison tests on NFS Date: Wed, 22 Jul 2026 10:11:38 +0100 Message-ID: <20260722091219.61504-5-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260722091219.61504-1-usama.anjum@arm.com> References: <20260722091219.61504-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 clean_pagecache and dirty_pagecache cases use shared file-backed mappings to exercise page-cache memory-failure recovery. These checks assume local filesystem writeback and error-reporting semantics. On NFS, the hard dirty-page case can complete hwpoison injection and recovery, then report a delayed writeback error when the file is closed. That failure reflects NFS writeback behavior rather than the page-cache recovery path targeted by the test. Extend the existing filesystem prerequisite check to reject NFS and close the descriptor before skipping. Other filesystem types retain the existing injection and recovery checks. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/memory-failure.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/memory-failure.c b/tools/testing/se= lftests/mm/memory-failure.c index 032ed952057c6..2e77f58406868 100644 --- a/tools/testing/selftests/mm/memory-failure.c +++ b/tools/testing/selftests/mm/memory-failure.c @@ -272,6 +272,11 @@ static int get_fs_type(int fd) return ret ? 0 : (int)fs.f_type; } =20 +static bool file_backed_test_supported(int fs_type) +{ + return fs_type && fs_type !=3D TMPFS_MAGIC && fs_type !=3D NFS_SUPER_MAGI= C; +} + TEST_F(memory_failure, clean_pagecache) { int fd; @@ -283,8 +288,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 (!file_backed_test_supported(fs_type)) { + 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 +332,10 @@ 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 (!file_backed_test_supported(fs_type)) { + 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 23:30:47 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEF07495538; Wed, 22 Jul 2026 09:12:44 +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=1784711566; cv=none; b=C91qZEhgqVbct4oW49IcDiRHpg7BG2TmqA5yldYifBqSy20rjP+yvvlC7OZSq6lO+YvID4int5abgNMNA5LEWl1OdkrB6RT+rwEVf86jNQOePzvyK9+gf/+hQPFPo3Fo8vPn2Zw7YUUCFmVda3DS1qcja6PZu8mE3F499ojnAmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784711566; c=relaxed/simple; bh=zU+WJI13tWsgGSx87Of2o6NV7wNVwyx6o1/X2ur3XDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rbBWohjrWH6y/1mbvo+s2N6gEh0uQngtXrcJ1J2tKnCD7Yj3gD23iCUTwkFiGyXB9LlK5hrya414pJg8K93PKyCd/tbM7PnzG7qkW6G3NqwkecKMwXKCK7sXu4W9fo1QP9LFlkxAwHQoAZQeG9G5aFmGIRXPU7zWxNjG1YQ+CcE= 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=oS8ZvJdS; 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="oS8ZvJdS" 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 DB9021595; Wed, 22 Jul 2026 02:12:39 -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 E7C253FC81; Wed, 22 Jul 2026 02:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784711564; bh=zU+WJI13tWsgGSx87Of2o6NV7wNVwyx6o1/X2ur3XDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oS8ZvJdSVqcqJG5JmEhwWraFolHd2/OKcrNFCnyihoZTNbCtCApPpi1EvWQ4GlDhG 0qYmVOSWCIfBmRBoC7xmkVKG8a7g7aXjdDZMRRUnWgvvZv56kTX9h2dmvr4Rjp6Fci kGZiqF89fwv6XKoDKMXa4dAkdq7vQaqlqsCtxHj0= 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 Cc: Muhammad Usama Anjum Subject: [PATCH RESEND v1 5/5] selftests/mm: retry migration failures for the full runtime Date: Wed, 22 Jul 2026 10:11:39 +0100 Message-ID: <20260722091219.61504-6-usama.anjum@arm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260722091219.61504-1-usama.anjum@arm.com> References: <20260722091219.61504-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() migration is best effort and may temporarily leave a page unmigrated when another task faults on the folio during unmapping. The migration test currently tolerates 100 consecutive partial failures, but a busy machine can exhaust those retries in a fraction of a second and fail long before the intended 20-second runtime expires. This is especially visible in the shared-anon cases, where every worker process continuously accesses the same mapping. The retry count then measures syscall rate rather than whether the test can exercise a successful migration entry. Retry positive move_pages() results for the full runtime and record the per-page status. Pass if at least one migration succeeds, and report the last status before failing if no migration makes progress. Continue to fail immediately for syscall-level errors. Signed-off-by: Muhammad Usama Anjum --- tools/testing/selftests/mm/migration.c | 34 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftes= ts/mm/migration.c index 29f7492453d43..19b4cef65f345 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,8 @@ 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 last_status =3D 0; + unsigned long successes =3D 0; =20 if (clock_gettime(CLOCK_MONOTONIC, &ts1)) return -1; @@ -119,23 +119,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) { + if (successes) + return 0; =20 + if (last_status < 0) + printf("No page migration succeeded: %s (%d)\n", + strerror(-last_status), last_status); + else + printf("No page migration succeeded: status %d\n", + last_status); + return -2; + } + + status =3D 0; 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 + /* Migration is best effort; try again. */ + last_status =3D status; + continue; + } else { perror("Couldn't migrate pages"); + } return -2; } - failures =3D 0; + successes++; tmp =3D n2; n2 =3D n1; n1 =3D tmp; --=20 2.47.3