Re: [PATCH v3] selftests/cgroup: add PSI pressure trigger and validation tests
Tao Cui <[email protected]>
| Newsgroups | dev.linux.lists.sashiko-reviews |
|---|---|
| Message-ID | <[email protected]> |
在 2026/8/13 21:54, [email protected] 写道: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [Medium] The child processes spawned to generate CPU pressure execute an unconditional infinite loop (`for (;;);`). If the test is interrupted (e.g., via SIGINT or a CI timeout sending SIGTERM), the parent process will exit immediately without executing the cleanup block (`cg_killall()`). This leaves `ncpus + 1` child processes running forever, consuming 100% CPU on all cores and effectively locking up the system. > -- > > --- Patch [1]: [PATCH v3] selftests/cgroup: add PSI pressure trigger and validation tests --- > commit a3c72bd52fb11f36beba6ee125a9c7100e986a5a > Author: Tao Cui <[email protected]> > selftests/cgroup: add PSI pressure trigger and validation tests > > This commit adds per-resource trigger smoke tests, a cgroup.pressure > hide/show toggle test, and a CPU-pressure trigger test using > over-subscription to the cgroup selftests. > > Link: https://lore.kernel.org/all/[email protected]/ > Link: https://lore.kernel.org/all/[email protected]/ > >> diff --git a/tools/testing/selftests/cgroup/test_psi.c b/tools/testing/selftests/cgroup/test_psi.c >> new file mode 100644 >> index 0000000000000..cfb412f614588 >> --- /dev/null >> +++ b/tools/testing/selftests/cgroup/test_psi.c > [ ... ] >> +/* A child that burns CPU forever; stopped by cg_killall() in the parent. */ >> +static int hog_cpu(const char *cgroup, void *arg) >> +{ >> + for (;;) >> + ; > > [Severity: Medium] > Will this leave runaway CPU hogs consuming 100% CPU on all cores if the test > is interrupted? > > If the parent process is interrupted by a signal (like SIGINT or a CI runner > timeout sending SIGTERM) while waiting for poll(), it will exit immediately > without executing the cg_killall() cleanup block. > > Could a fallback termination condition be added here, such as > prctl(PR_SET_PDEATHSIG, SIGKILL) or checking getppid(), to prevent orphaned > processes from locking up the system? > Agreed. The hogs run forever, so interrupting the parent during poll() skips cg_killall() and orphans them. I'll add prctl(PR_SET_PDEATHSIG, SIGKILL) at the start of each hog so the kernel reaps them if the parent dies -- for v4. >> + return 0; >> +} >