* [PATCH] selftests/mm: close fd on write error @ 2026-05-20 2:03 Wei Yang 2026-05-20 3:51 ` Dev Jain 2026-05-21 0:54 ` SeongJae Park 0 siblings, 2 replies; 6+ messages in thread From: Wei Yang @ 2026-05-20 2:03 UTC (permalink / raw) To: akpm, david, ljs; +Cc: linux-mm, linux-kselftest, Wei Yang When create_pagecache_thp_and_fd() write returns error on /proc/sys/vm/dropcache, it just "goto err_out_unlink", which left fd still open. Use "goto err_out_close" to close the fd. Signed-off-by: Wei Yang <richard.weiyang@gmail.com> --- tools/testing/selftests/mm/split_huge_page_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c index 460fa1f606fd..f30402ece608 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -469,7 +469,7 @@ static int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, } if (write(*fd, "3", 1) != 1) { ksft_perror("write to drop_caches"); - goto err_out_unlink; + goto err_out_close; } close(*fd); -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/mm: close fd on write error 2026-05-20 2:03 [PATCH] selftests/mm: close fd on write error Wei Yang @ 2026-05-20 3:51 ` Dev Jain 2026-05-20 9:38 ` Wei Yang 2026-05-21 0:54 ` SeongJae Park 1 sibling, 1 reply; 6+ messages in thread From: Dev Jain @ 2026-05-20 3:51 UTC (permalink / raw) To: Wei Yang, akpm, david, ljs; +Cc: linux-mm, linux-kselftest On 20/05/26 7:33 am, Wei Yang wrote: > When create_pagecache_thp_and_fd() write returns error on > /proc/sys/vm/dropcache, it just "goto err_out_unlink", which left fd > still open. > > Use "goto err_out_close" to close the fd. > > Signed-off-by: Wei Yang <richard.weiyang@gmail.com> > --- > tools/testing/selftests/mm/split_huge_page_test.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c > index 460fa1f606fd..f30402ece608 100644 > --- a/tools/testing/selftests/mm/split_huge_page_test.c > +++ b/tools/testing/selftests/mm/split_huge_page_test.c > @@ -469,7 +469,7 @@ static int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, > } > if (write(*fd, "3", 1) != 1) { > ksft_perror("write to drop_caches"); > - goto err_out_unlink; > + goto err_out_close; > } > close(*fd); LGTM Reviewed-by: Dev Jain <dev.jain@arm.com> I asked AI and it points to another problem: for (i = 0; i < nr_thps; i++) { if (is_backed_by_folio(page_area + i * pagesize, 0, pagemap_fd, kpageflags_fd)) continue; ksft_test_result_fail("THP %zu not split\n", i); } ksft_test_result_pass("Split PTE-mapped huge pages successful\n"); "If one THP is not split, it prints FAIL, but then falls through and also prints PASS. It should probably jump to out after the failure". > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/mm: close fd on write error 2026-05-20 3:51 ` Dev Jain @ 2026-05-20 9:38 ` Wei Yang 2026-05-22 0:49 ` Andrew Morton 0 siblings, 1 reply; 6+ messages in thread From: Wei Yang @ 2026-05-20 9:38 UTC (permalink / raw) To: Dev Jain; +Cc: Wei Yang, akpm, david, ljs, linux-mm, linux-kselftest On Wed, May 20, 2026 at 09:21:48AM +0530, Dev Jain wrote: > > >On 20/05/26 7:33 am, Wei Yang wrote: >> When create_pagecache_thp_and_fd() write returns error on >> /proc/sys/vm/dropcache, it just "goto err_out_unlink", which left fd >> still open. >> >> Use "goto err_out_close" to close the fd. >> >> Signed-off-by: Wei Yang <richard.weiyang@gmail.com> >> --- >> tools/testing/selftests/mm/split_huge_page_test.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c >> index 460fa1f606fd..f30402ece608 100644 >> --- a/tools/testing/selftests/mm/split_huge_page_test.c >> +++ b/tools/testing/selftests/mm/split_huge_page_test.c >> @@ -469,7 +469,7 @@ static int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, >> } >> if (write(*fd, "3", 1) != 1) { >> ksft_perror("write to drop_caches"); >> - goto err_out_unlink; >> + goto err_out_close; >> } >> close(*fd); > >LGTM > >Reviewed-by: Dev Jain <dev.jain@arm.com> > > >I asked AI and it points to another problem: > >for (i = 0; i < nr_thps; i++) { > if (is_backed_by_folio(page_area + i * pagesize, 0, > pagemap_fd, kpageflags_fd)) > continue; > ksft_test_result_fail("THP %zu not split\n", i); >} > >ksft_test_result_pass("Split PTE-mapped huge pages successful\n"); > >"If one THP is not split, it prints FAIL, but then falls through and also prints PASS. > >It should probably jump to out after the failure". > Thanks for AI. It looks we should "goto out" after ksft_test_result_fail(). -- Wei Yang Help you, Help me ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/mm: close fd on write error 2026-05-20 9:38 ` Wei Yang @ 2026-05-22 0:49 ` Andrew Morton 2026-05-24 1:48 ` Wei Yang 0 siblings, 1 reply; 6+ messages in thread From: Andrew Morton @ 2026-05-22 0:49 UTC (permalink / raw) To: Wei Yang; +Cc: Dev Jain, david, ljs, linux-mm, linux-kselftest On Wed, 20 May 2026 09:38:24 +0000 Wei Yang <richard.weiyang@gmail.com> wrote: > > Subject: [PATCH] selftests/mm: close fd on write error > selftest/mm is a big place nowadays. I'll rewrite this to "selftests/mm/split_huge_page_test.c: ...". > >I asked AI and it points to another problem: > > > >for (i = 0; i < nr_thps; i++) { > > if (is_backed_by_folio(page_area + i * pagesize, 0, > > pagemap_fd, kpageflags_fd)) > > continue; > > ksft_test_result_fail("THP %zu not split\n", i); > >} > > > >ksft_test_result_pass("Split PTE-mapped huge pages successful\n"); > > > >"If one THP is not split, it prints FAIL, but then falls through and also prints PASS. > > > >It should probably jump to out after the failure". > > https://sashiko.dev/#/patchset/20260520020336.28914-1-richard.weiyang@gmail.com doesn't say this? > Thanks for AI. > > It looks we should "goto out" after ksft_test_result_fail(). I'll assume that's a separate patch. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/mm: close fd on write error 2026-05-22 0:49 ` Andrew Morton @ 2026-05-24 1:48 ` Wei Yang 0 siblings, 0 replies; 6+ messages in thread From: Wei Yang @ 2026-05-24 1:48 UTC (permalink / raw) To: Andrew Morton; +Cc: Wei Yang, Dev Jain, david, ljs, linux-mm, linux-kselftest On Thu, May 21, 2026 at 05:49:51PM -0700, Andrew Morton wrote: >On Wed, 20 May 2026 09:38:24 +0000 Wei Yang <richard.weiyang@gmail.com> wrote: >> >> Subject: [PATCH] selftests/mm: close fd on write error >> > >selftest/mm is a big place nowadays. I'll rewrite this to >"selftests/mm/split_huge_page_test.c: ...". > Thanks, will do similar in future work. >> >I asked AI and it points to another problem: >> > >> >for (i = 0; i < nr_thps; i++) { >> > if (is_backed_by_folio(page_area + i * pagesize, 0, >> > pagemap_fd, kpageflags_fd)) >> > continue; >> > ksft_test_result_fail("THP %zu not split\n", i); >> >} >> > >> >ksft_test_result_pass("Split PTE-mapped huge pages successful\n"); >> > >> >"If one THP is not split, it prints FAIL, but then falls through and also prints PASS. >> > >> >It should probably jump to out after the failure". >> > > >https://sashiko.dev/#/patchset/20260520020336.28914-1-richard.weiyang@gmail.com >doesn't say this? > I took a look into the above link, but not see any comment. Not sure I got it clearly? > >> Thanks for AI. >> >> It looks we should "goto out" after ksft_test_result_fail(). > >I'll assume that's a separate patch. Agree. The credit belongs to @Dev. Not sure I should send the fix. -- Wei Yang Help you, Help me ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] selftests/mm: close fd on write error 2026-05-20 2:03 [PATCH] selftests/mm: close fd on write error Wei Yang 2026-05-20 3:51 ` Dev Jain @ 2026-05-21 0:54 ` SeongJae Park 1 sibling, 0 replies; 6+ messages in thread From: SeongJae Park @ 2026-05-21 0:54 UTC (permalink / raw) To: Wei Yang; +Cc: SeongJae Park, akpm, david, ljs, linux-mm, linux-kselftest On Wed, 20 May 2026 02:03:36 +0000 Wei Yang <richard.weiyang@gmail.com> wrote: > When create_pagecache_thp_and_fd() write returns error on > /proc/sys/vm/dropcache, it just "goto err_out_unlink", which left fd > still open. > > Use "goto err_out_close" to close the fd. > > Signed-off-by: Wei Yang <richard.weiyang@gmail.com> Reviewed-by: SeongJae Park <sj@kernel.org> Thanks, SJ [...] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-05-24 1:48 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-05-20 2:03 [PATCH] selftests/mm: close fd on write error Wei Yang 2026-05-20 3:51 ` Dev Jain 2026-05-20 9:38 ` Wei Yang 2026-05-22 0:49 ` Andrew Morton 2026-05-24 1:48 ` Wei Yang 2026-05-21 0:54 ` SeongJae Park
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox