* [PATCH] selftests/cachestat: clean up the mmap test scratch file
@ 2026-11-26 1:18 tongzhiwei
2026-11-27 1:19 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: tongzhiwei @ 2026-11-26 1:18 UTC (permalink / raw)
To: Nhat Pham, Johannes Weiner, Shuah Khan
Cc: tongzhiwei, linux-mm, linux-kselftest, linux-kernel
NOTE: This fix is found and coded by llm, but it has been
reviewed by human.
run_cachestat_test() creates its FILE_MMAP scratch file with open() but
cleans it up with shm_unlink(), which only removes a POSIX shared-memory
object under /dev/shm. The regular file "tmpshmcstat" is therefore left
behind in the working directory after every run.
The leftover file was previously worked around by adding its name to
.gitignore in commit b90cafb43887 ("selftests/cachestat: add
tmpshmcstat file to .gitignore"); the entry remains as a safety net
for runs interrupted mid-test, but the test itself should not leave
the file behind in the first place.
Use remove() for the mmap case and keep shm_unlink() for the FILE_SHMEM
case only, matching the cleanup the sibling test_cachestat() helper
already does for its own temp file.
Remove the file unconditionally, by design: the name "tmpshmcstat" is
test-specific so a real collision is implausible, and gating removal on
whether this run created the file would preserve stale files left by a
crashed previous run instead of cleaning them up.
Assisted-by: LLM
Signed-off-by: tongzhiwei <tongzhiwei@cmss.chinamobile.com>
---
For context: the same leftover file was previously discussed in a
related but different proposal from Madhur Kumar, which took the
EXTRA_CLEAN approach (removing the file in "make kselftest-clean")
and has not been applied so far:
https://lore.kernel.org/r/20250927161141.778631-1-madhurkumar004@gmail.com/
This patch instead removes the leftover inside the test itself, so
the file is cleaned up whether or not the test builds/runs via make.
tools/testing/selftests/cachestat/test_cachestat.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/cachestat/test_cachestat.c b/tools/testing/selftests/cachestat/test_cachestat.c
index 542cd09..5e62c49 100644
--- a/tools/testing/selftests/cachestat/test_cachestat.c
+++ b/tools/testing/selftests/cachestat/test_cachestat.c
@@ -289,7 +289,10 @@ bool run_cachestat_test(enum file_type type)
}
close_fd:
- shm_unlink(filename);
+ if (type == FILE_SHMEM)
+ shm_unlink(filename);
+ else
+ remove(filename);
out:
return ret;
}
--
2.33.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] selftests/cachestat: clean up the mmap test scratch file
2026-11-26 1:18 [PATCH] selftests/cachestat: clean up the mmap test scratch file tongzhiwei
@ 2026-11-27 1:19 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-27 1:19 UTC (permalink / raw)
To: tongzhiwei, Nhat Pham, Johannes Weiner, Shuah Khan; +Cc: linux-mm
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/cachestat: missing Fixes trailer for commit
d6a511dea45c
--
commit 6dca73321f87a5ea6aa466ecc90a54514aa6c780
Author: tongzhiwei <tongzhiwei@cmss.chinamobile.com>
> selftests/cachestat: clean up the mmap test scratch file
>
> NOTE: This fix is found and coded by llm, but it has been
> reviewed by human.
>
> run_cachestat_test() creates its FILE_MMAP scratch file with open() but
> cleans it up with shm_unlink(), which only removes a POSIX shared-memory
> object under /dev/shm. The regular file "tmpshmcstat" is therefore left
> behind in the working directory after every run.
>
> The leftover file was previously worked around by adding its name to
> .gitignore in commit b90cafb43887 ("selftests/cachestat: add
> tmpshmcstat file to .gitignore"); the entry remains as a safety net
> for runs interrupted mid-test, but the test itself should not leave
> the file behind in the first place.
>
> Use remove() for the mmap case and keep shm_unlink() for the FILE_SHMEM
> case only, matching the cleanup the sibling test_cachestat() helper
> already does for its own temp file.
>
> Remove the file unconditionally, by design: the name "tmpshmcstat" is
> test-specific so a real collision is implausible, and gating removal on
> whether this run created the file would preserve stale files left by a
> crashed previous run instead of cleaning them up.
>
> Assisted-by: LLM
> Signed-off-by: tongzhiwei <tongzhiwei@cmss.chinamobile.com>
[Severity: Low]
This fixes the FILE_MMAP cleanup introduced when test_cachestat_shmem()
was refactored into run_cachestat_test(). Should this include:
Fixes: d6a511dea45c ("selftests: cachestat: add tests for mmap, refactor and enhance mmap test for cachestat validation")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126011818.417-1-tongzhiwei@cmss.chinamobile.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 1:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 1:18 [PATCH] selftests/cachestat: clean up the mmap test scratch file tongzhiwei
2026-11-27 1:19 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox