From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Leo Yan <leo.yan@linux.dev>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v1] perf test task-exit: Fix POLLHUP busy-loop race waiting for SIGCHLD
Date: Sun, 25 Oct 2026 14:49:28 -0700 [thread overview]
Message-ID: <20261025214928.1225895-1-irogers@google.com> (raw)
In the kernel's do_exit(), perf_event_exit_task() runs before exit_mm()
and exit_notify() (which delivers SIGCHLD to the parent). Once
perf_event_exit_task() completes, PERF_RECORD_EXIT is written to the
ring buffer and POLLHUP is set on the perf event file descriptor.
In test__task_exit(), once POLLHUP is set on the fd, evlist__poll()
returns immediately on every call without blocking. If the child is
still in exit_mm()..exit_notify() on another CPU when the parent reads
PERF_RECORD_EXIT, exited is still 0 and the retry loop spins through all
1000 non-blocking poll() calls in less than a millisecond before SIGCHLD
is delivered.
Sleep briefly with usleep(1000) on subsequent retries (which also wakes
early on EINTR when SIGCHLD arrives), mark exited as volatile
sig_atomic_t, and reset exited and nr_exit on test entry.
Fixes: 791ce9c48c79 ("perf test: Avoid infinite loop for task exit case")
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/tests/task-exit.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index 9fac426ac2f9..1a9de2d13497 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -9,13 +9,14 @@
#include <errno.h>
#include <signal.h>
+#include <unistd.h>
#include <linux/string.h>
#include <perf/cpumap.h>
#include <perf/evlist.h>
#include <perf/mmap.h>
-static int exited;
-static int nr_exit;
+static volatile sig_atomic_t exited;
+static volatile int nr_exit;
static void sig_handler(int sig __maybe_unused)
{
@@ -55,6 +56,8 @@ static int test__task_exit(struct test_suite *test __maybe_unused, int subtest _
struct mmap *md;
int retry_count = 0;
+ exited = 0;
+ nr_exit = 0;
signal(SIGCHLD, sig_handler);
evlist = evlist__new_dummy();
@@ -135,6 +138,8 @@ static int test__task_exit(struct test_suite *test __maybe_unused, int subtest _
err = -1;
goto out_put_evlist;
}
+ if (retry_count > 1)
+ usleep(1000);
goto retry;
}
--
2.56.0.307.g5fe7bd680c-goog
next reply other threads:[~2026-10-25 21:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 21:49 Ian Rogers [this message]
2026-10-25 22:08 ` [PATCH v1] perf test task-exit: Fix POLLHUP busy-loop race waiting for SIGCHLD sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261025214928.1225895-1-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=leo.yan@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.