Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00E213DB31A; Sat, 12 Sep 2026 12:56:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789217804; cv=none; b=n+vfz8bxNM8t4s4GIdESLpVRXul0GpnO3KJZiV40sCnfITdNhcFBksijz1FaoAHBAe0Mmnc6QpXy6h16wcqvM3T/w2UohD2IzAVlmrwJaobJ0zI8G8OfoEaboGA/+r02WxQ9IwSXmq+SQvkxs+csSsiiSMNENE4MIE2PqAdbsfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789217804; c=relaxed/simple; bh=Lb8si3964V97073NQwOq7zZuVVJtd82h5J927+6v7Y0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ACbL9b6qcJu2BeRNarlefrLT18olRBOWn/+8MwLMv5qqH41XTufdjxkFyilgEv9Kuw6HqtBj7VeCd9PWIk5qFRcMTA6lzoV/RAgkx020km8f9sUwd/2h6LIvKnNXUv4qkjyLOorjZvdaMkR1xuG3rUcpyf+HSNeeo51sRQKpwE0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nlcmoALs; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nlcmoALs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 957FF1F000FF; Sat, 12 Sep 2026 12:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789217802; bh=x82/XxU+/gIdd8SxO9ODgMQ3P0o1cfK9XJR6r1CrZQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nlcmoALsy1QgmpZffP2RuaPdg114h7070HDS0zSkaKxtCPu19vaYvasH/FMMqlRtf YiucmDvGYZDyI+lXig1XsN6qz6zWtBqLxN3q8POBrZ9Spso+m6XppIn0t9oGqyAzfU iP3+BJ7DQ4q6eK5WKqexP4zKk5MeqN5/sgLZEYHg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ian Rogers , Colin Ian King , Howard Chu , Weilin Wang , James Clark , Ilya Leoshkevich , Thomas Richter , Andi Kleen , Dapeng Mi , Athira Jajeev , Michael Petlan , Veronika Molnarova , Namhyung Kim , Sasha Levin Subject: [PATCH 6.12 1012/1376] perf test: Add a signal handler to kill forked child processes Date: Sat, 12 Sep 2026 08:57:18 +0200 Message-ID: <20260912065630.117902324@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.535295758@linuxfoundation.org> References: <20260912065607.535295758@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ian Rogers [ Upstream commit 553d5efeb341f2f814f937e0658ed7d22f625662 ] If the `perf test` process is killed the child tests continue running and may run indefinitely. Propagate SIGINT (ctrl-C) and SIGTERM (kill) signals to the running child processes so that they terminate when the parent is killed. Signed-off-by: Ian Rogers Cc: Colin Ian King Cc: Howard Chu Cc: Weilin Wang Cc: James Clark Cc: Ilya Leoshkevich Cc: Thomas Richter Cc: Andi Kleen Cc: Dapeng Mi Cc: Athira Jajeev Cc: Michael Petlan Cc: Veronika Molnarova Link: https://lore.kernel.org/r/20241025192109.132482-10-irogers@google.com Signed-off-by: Namhyung Kim Stable-dep-of: 44e82c4d2ff3 ("perf test: Fix skiplist leak in cmd_test") Signed-off-by: Sasha Levin --- tools/perf/tests/builtin-test.c | 37 ++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index c240000f8b328..b9a9ce98cff6f 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -476,13 +476,22 @@ static int start_test(struct test_suite *test, int i, int subi, struct child_tes for (j = 0, k = 0; j < ARRAY_SIZE(tests); j++, k = 0) \ while ((t = tests[j][k++]) != NULL) +/* State outside of __cmd_test for the sake of the signal handler. */ + +static size_t num_tests; +static struct child_test **child_tests; +static jmp_buf cmd_test_jmp_buf; + +static void cmd_test_sig_handler(int sig) +{ + siglongjmp(cmd_test_jmp_buf, sig); +} + static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) { struct test_suite *t; - int width = 0; + static int width = 0; unsigned int j, k; - size_t num_tests = 0; - struct child_test **child_tests; int err = 0; for_each_test(j, k, t) { @@ -506,6 +515,26 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) if (!child_tests) return -ENOMEM; + err = sigsetjmp(cmd_test_jmp_buf, 1); + if (err) { + pr_err("\nSignal (%d) while running tests.\nTerminating tests with the same signal\n", + err); + for (size_t x = 0; x < num_tests; x++) { + struct child_test *child_test = child_tests[x]; + + if (!child_test) + continue; + + pr_debug3("Killing %d pid %d\n", + child_test->test_num + 1, + child_test->process.pid); + kill(child_test->process.pid, err); + } + goto err_out; + } + signal(SIGINT, cmd_test_sig_handler); + signal(SIGTERM, cmd_test_sig_handler); + /* * In parallel mode pass 1 runs non-exclusive tests in parallel, pass 2 * runs the exclusive tests sequentially. In other modes all tests are @@ -566,6 +595,8 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) } } err_out: + signal(SIGINT, SIG_DFL); + signal(SIGTERM, SIG_DFL); if (err) { pr_err("Internal test harness failure. Completing any started tests:\n:"); for (size_t x = 0; x < num_tests; x++) -- 2.53.0