* [LTP] [PATCH v2 0/2] Fix sporadic failures in pids shell tests
@ 2026-06-16 8:30 Andrea Cervesato
2026-06-16 8:30 ` [LTP] [PATCH v2 1/2] pids: fix cleanup of orphaned pids_task1 children Andrea Cervesato
2026-06-16 8:30 ` [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() Andrea Cervesato
0 siblings, 2 replies; 9+ messages in thread
From: Andrea Cervesato @ 2026-06-16 8:30 UTC (permalink / raw)
To: Linux Test Project
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Changes in v2:
- handle ESRCH only when ret < 0
- Link to v1: https://lore.kernel.org/r/20260615-fix_pids_errors-v1-0-99a54a205180@suse.com
---
Andrea Cervesato (2):
pids: fix cleanup of orphaned pids_task1 children
tst_cgroup: tolerate ESRCH in cgroup_drain()
lib/tst_cgroup.c | 6 +++++-
testcases/kernel/controllers/pids/pids.sh | 5 +++--
2 files changed, 8 insertions(+), 3 deletions(-)
---
base-commit: b4d31ea5d5c16628b9c45932fc98b929ca2ceece
change-id: 20260615-fix_pids_errors-19399419c8ee
Best regards,
--
Andrea Cervesato <andrea.cervesato@suse.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 9+ messages in thread* [LTP] [PATCH v2 1/2] pids: fix cleanup of orphaned pids_task1 children 2026-06-16 8:30 [LTP] [PATCH v2 0/2] Fix sporadic failures in pids shell tests Andrea Cervesato @ 2026-06-16 8:30 ` Andrea Cervesato 2026-06-16 10:10 ` [LTP] " linuxtestproject.agent 2026-06-16 8:30 ` [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() Andrea Cervesato 1 sibling, 1 reply; 9+ messages in thread From: Andrea Cervesato @ 2026-06-16 8:30 UTC (permalink / raw) To: Linux Test Project From: Andrea Cervesato <andrea.cervesato@suse.com> pids_task1 forks a child that calls pause(), then the parent exits. The orphaned child remains in the cgroup but gets reparented to init, so it is not a child of the test shell. stop_pids_tasks_path() reads cgroup.procs which includes this orphan. kill -9 succeeds but wait fails with 'not a child of this shell'. Using ROD for kill also unnecessarily aborts if the process is already dead. Fix by suppressing errors from both kill and wait, and add killall for pids_task1 in cleanup() to catch any remaining orphans. Reviewed-by: Li Wang <li.wang@linux.dev> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com> --- testcases/kernel/controllers/pids/pids.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/controllers/pids/pids.sh b/testcases/kernel/controllers/pids/pids.sh index 26a0c6a221ea63e683016ebfea33f2744800aaea..dd27b5616f0c4b55c625ca57efa2507325949b07 100755 --- a/testcases/kernel/controllers/pids/pids.sh +++ b/testcases/kernel/controllers/pids/pids.sh @@ -35,6 +35,7 @@ EOF cleanup() { killall -9 pids_task2 >/dev/null 2>&1 + killall -9 pids_task1 >/dev/null 2>&1 cgroup_cleanup } @@ -79,8 +80,8 @@ stop_pids_tasks_path() path=$1 for i in $(cat "$path/$task_list"); do - ROD kill -9 $i - wait $i + kill -9 $i 2>/dev/null + wait $i 2>/dev/null done } -- 2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [LTP] pids: fix cleanup of orphaned pids_task1 children 2026-06-16 8:30 ` [LTP] [PATCH v2 1/2] pids: fix cleanup of orphaned pids_task1 children Andrea Cervesato @ 2026-06-16 10:10 ` linuxtestproject.agent 0 siblings, 0 replies; 9+ messages in thread From: linuxtestproject.agent @ 2026-06-16 10:10 UTC (permalink / raw) To: Andrea Cervesato; +Cc: ltp Hi Andrea, On Tue, 16 Jun 2026, Andrea Cervesato wrote: > pids: fix cleanup of orphaned pids_task1 children > tst_cgroup: tolerate ESRCH in cgroup_drain() Verdict - Reviewed --- Note: The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions. Regards, LTP AI Reviewer -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 9+ messages in thread
* [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() 2026-06-16 8:30 [LTP] [PATCH v2 0/2] Fix sporadic failures in pids shell tests Andrea Cervesato 2026-06-16 8:30 ` [LTP] [PATCH v2 1/2] pids: fix cleanup of orphaned pids_task1 children Andrea Cervesato @ 2026-06-16 8:30 ` Andrea Cervesato 2026-06-16 12:13 ` Li Wang ` (2 more replies) 1 sibling, 3 replies; 9+ messages in thread From: Andrea Cervesato @ 2026-06-16 8:30 UTC (permalink / raw) To: Linux Test Project From: Andrea Cervesato <andrea.cervesato@suse.com> A process can die between reading cgroup.procs and writing its PID to the destination cgroup. When this happens, the kernel returns ESRCH which is a normal race condition, not a test infrastructure failure. Skip ESRCH errors instead of aborting with TBROK. Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com> --- lib/tst_cgroup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c index a37bf1516aabfbcb9a02fedd6fddb98e85ecc653..f548c0e01cf60803ad4c1e898e7ec2d39dc33c84 100644 --- a/lib/tst_cgroup.c +++ b/lib/tst_cgroup.c @@ -974,8 +974,12 @@ static void cgroup_drain(const enum tst_cg_ver ver, for (tok = strtok(pid_list, "\n"); tok; tok = strtok(NULL, "\n")) { ret = dprintf(fd, "%s", tok); - if (ret < (ssize_t)strlen(tok)) + if (ret < (ssize_t)strlen(tok)) { + if (ret < 0 && errno == ESRCH) + continue; + tst_brk(TBROK | TERRNO, "Failed to drain %s", tok); + } } SAFE_CLOSE(fd); } -- 2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() 2026-06-16 8:30 ` [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() Andrea Cervesato @ 2026-06-16 12:13 ` Li Wang 2026-06-17 9:05 ` Cyril Hrubis 2026-06-17 10:18 ` Andrea Cervesato via ltp 2 siblings, 0 replies; 9+ messages in thread From: Li Wang @ 2026-06-16 12:13 UTC (permalink / raw) To: Andrea Cervesato; +Cc: Linux Test Project On Tue, Jun 16, 2026 at 10:30:07AM +0200, Andrea Cervesato wrote: > From: Andrea Cervesato <andrea.cervesato@suse.com> > > A process can die between reading cgroup.procs and writing its PID > to the destination cgroup. When this happens, the kernel returns > ESRCH which is a normal race condition, not a test infrastructure > failure. > > Skip ESRCH errors instead of aborting with TBROK. > > Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com> Reviewed-by: Li Wang <li.wang@linux.dev> -- Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() 2026-06-16 8:30 ` [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() Andrea Cervesato 2026-06-16 12:13 ` Li Wang @ 2026-06-17 9:05 ` Cyril Hrubis 2026-06-17 9:15 ` Andrea Cervesato via ltp 2026-06-17 10:18 ` Andrea Cervesato via ltp 2 siblings, 1 reply; 9+ messages in thread From: Cyril Hrubis @ 2026-06-17 9:05 UTC (permalink / raw) To: Andrea Cervesato; +Cc: Linux Test Project Hi! > A process can die between reading cgroup.procs and writing its PID > to the destination cgroup. When this happens, the kernel returns > ESRCH which is a normal race condition, not a test infrastructure > failure. > > Skip ESRCH errors instead of aborting with TBROK. > > Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com> > --- > lib/tst_cgroup.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c > index a37bf1516aabfbcb9a02fedd6fddb98e85ecc653..f548c0e01cf60803ad4c1e898e7ec2d39dc33c84 100644 > --- a/lib/tst_cgroup.c > +++ b/lib/tst_cgroup.c > @@ -974,8 +974,12 @@ static void cgroup_drain(const enum tst_cg_ver ver, > for (tok = strtok(pid_list, "\n"); tok; tok = strtok(NULL, "\n")) { > ret = dprintf(fd, "%s", tok); > > - if (ret < (ssize_t)strlen(tok)) > + if (ret < (ssize_t)strlen(tok)) { > + if (ret < 0 && errno == ESRCH) > + continue; Maybe we can print tst_res(TINFO, "Pid %s died during drain", tok); here as well, so that when this happens we will have the information in the test log. Otherwise: Reviewed-by: Cyril Hrubis <chrubis@suse.cz> > tst_brk(TBROK | TERRNO, "Failed to drain %s", tok); > + } > } > SAFE_CLOSE(fd); > } > > -- > 2.51.0 > > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp -- Cyril Hrubis chrubis@suse.cz -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() 2026-06-17 9:05 ` Cyril Hrubis @ 2026-06-17 9:15 ` Andrea Cervesato via ltp 2026-06-17 9:36 ` Cyril Hrubis 0 siblings, 1 reply; 9+ messages in thread From: Andrea Cervesato via ltp @ 2026-06-17 9:15 UTC (permalink / raw) To: Cyril Hrubis; +Cc: Linux Test Project > Maybe we can print tst_res(TINFO, "Pid %s died during drain", tok); > here as well, so that when this happens we will have the information in > the test log. What about TDEBUG ? -- Andrea Cervesato SUSE QE Automation Engineer Linux andrea.cervesato@suse.com -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() 2026-06-17 9:15 ` Andrea Cervesato via ltp @ 2026-06-17 9:36 ` Cyril Hrubis 0 siblings, 0 replies; 9+ messages in thread From: Cyril Hrubis @ 2026-06-17 9:36 UTC (permalink / raw) To: Andrea Cervesato; +Cc: Linux Test Project Hi! > > Maybe we can print tst_res(TINFO, "Pid %s died during drain", tok); > > here as well, so that when this happens we will have the information in > > the test log. > > What about TDEBUG ? I was thinking about TDEBUG but in the end I think TINFO is better because: - the message is not going to be printed very often - it's visible by default, i.e. included in logs from CI -- Cyril Hrubis chrubis@suse.cz -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() 2026-06-16 8:30 ` [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() Andrea Cervesato 2026-06-16 12:13 ` Li Wang 2026-06-17 9:05 ` Cyril Hrubis @ 2026-06-17 10:18 ` Andrea Cervesato via ltp 2 siblings, 0 replies; 9+ messages in thread From: Andrea Cervesato via ltp @ 2026-06-17 10:18 UTC (permalink / raw) To: Andrea Cervesato; +Cc: Linux Test Project Merged, Thanks! With suggested @Cyril TINFO message on ESRCH. -- Andrea Cervesato SUSE QE Automation Engineer Linux andrea.cervesato@suse.com -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-06-17 10:18 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-16 8:30 [LTP] [PATCH v2 0/2] Fix sporadic failures in pids shell tests Andrea Cervesato 2026-06-16 8:30 ` [LTP] [PATCH v2 1/2] pids: fix cleanup of orphaned pids_task1 children Andrea Cervesato 2026-06-16 10:10 ` [LTP] " linuxtestproject.agent 2026-06-16 8:30 ` [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() Andrea Cervesato 2026-06-16 12:13 ` Li Wang 2026-06-17 9:05 ` Cyril Hrubis 2026-06-17 9:15 ` Andrea Cervesato via ltp 2026-06-17 9:36 ` Cyril Hrubis 2026-06-17 10:18 ` Andrea Cervesato via ltp
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox