From nobody Sun Sep 14 18:46:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 302F5C6379F for ; Wed, 18 Jan 2023 22:02:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbjARWCf (ORCPT ); Wed, 18 Jan 2023 17:02:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229950AbjARWBu (ORCPT ); Wed, 18 Jan 2023 17:01:50 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E41410A8F; Wed, 18 Jan 2023 14:01:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2ABEB61A73; Wed, 18 Jan 2023 22:01:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 947E7C433F2; Wed, 18 Jan 2023 22:01:47 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1pIGV8-002H9N-1U; Wed, 18 Jan 2023 17:01:46 -0500 Message-ID: <20230118220146.327085542@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 18 Jan 2023 16:54:36 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , Masami Hiramatsu , stable@vger.kernel.org Subject: [for-linus][PATCH 1/3] ktest.pl: Fix missing "end_monitor" when machine check fails References: <20230118215435.016435760@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Steven Rostedt In the "reboot" command, it does a check of the machine to see if it is still alive with a simple "ssh echo" command. If it fails, it will assume that a normal "ssh reboot" is not possible and force a power cycle. In this case, the "start_monitor" is executed, but the "end_monitor" is not, and this causes the screen will not be given back to the console. That is, after the test, a "reset" command needs to be performed, as "echo" is turned off. Cc: stable@vger.kernel.org Fixes: 6474ace999edd ("ktest.pl: Powercycle the box on reboot if no connect= ion can be made") Signed-off-by: Steven Rostedt Tested-by: Masami Hiramatsu (Google) --- tools/testing/ktest/ktest.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 6f9fff88cedf..f2f48ce6ac4d 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -1499,7 +1499,8 @@ sub reboot { =20 # Still need to wait for the reboot to finish wait_for_monitor($time, $reboot_success_line); - + } + if ($powercycle || $time) { end_monitor; } } --=20 2.39.0 From nobody Sun Sep 14 18:46:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20955C678D6 for ; Wed, 18 Jan 2023 22:02:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230137AbjARWCc (ORCPT ); Wed, 18 Jan 2023 17:02:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbjARWBv (ORCPT ); Wed, 18 Jan 2023 17:01:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 514F02F7B3; Wed, 18 Jan 2023 14:01:50 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 07900B81D69; Wed, 18 Jan 2023 22:01:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFFBCC43392; Wed, 18 Jan 2023 22:01:47 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1pIGV8-002H9r-20; Wed, 18 Jan 2023 17:01:46 -0500 Message-ID: <20230118220146.482536390@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 18 Jan 2023 16:54:37 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , Masami Hiramatsu , stable@vger.kernel.org Subject: [for-linus][PATCH 2/3] ktest.pl: Give back console on Ctrt^C on monitor References: <20230118215435.016435760@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Steven Rostedt When monitoring the console output, the stdout is being redirected to do so. If Ctrl^C is hit during this mode, the stdout is not back to the console, the user does not see anything they type (no echo). Add "end_monitor" to the SIGINT interrupt handler to give back the console on Ctrl^C. Cc: stable@vger.kernel.org Fixes: 9f2cdcbbb90e7 ("ktest: Give console process a dedicated tty") Signed-off-by: Steven Rostedt Tested-by: Masami Hiramatsu (Google) --- tools/testing/ktest/ktest.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index f2f48ce6ac4d..78249c3a03a5 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -4205,6 +4205,9 @@ sub send_email { } =20 sub cancel_test { + if ($monitor_cnt) { + end_monitor; + } if ($email_when_canceled) { my $name =3D get_test_name; send_email("KTEST: Your [$name] test was cancelled", --=20 2.39.0 From nobody Sun Sep 14 18:46:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11E6AC46467 for ; Wed, 18 Jan 2023 22:02:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbjARWC2 (ORCPT ); Wed, 18 Jan 2023 17:02:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229963AbjARWBv (ORCPT ); Wed, 18 Jan 2023 17:01:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8638337F01; Wed, 18 Jan 2023 14:01:50 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 46EFFB81F14; Wed, 18 Jan 2023 22:01:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBF1BC4339E; Wed, 18 Jan 2023 22:01:47 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1pIGV8-002HAL-2V; Wed, 18 Jan 2023 17:01:46 -0500 Message-ID: <20230118220146.639491327@goodmis.org> User-Agent: quilt/0.66 Date: Wed, 18 Jan 2023 16:54:38 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: "John Warthog9 Hawley" , Masami Hiramatsu , stable@vger.kernel.org Subject: [for-linus][PATCH 3/3] ktest.pl: Add RUN_TIMEOUT option with default unlimited References: <20230118215435.016435760@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Steven Rostedt There is a disconnect between the run_command function and the wait_for_input. The wait_for_input has a default timeout of 2 minutes. But if that happens, the run_command loop will exit out to the waitpid() of the executing command. This fails in that it no longer monitors the command, and also, the ssh to the test box can hang when its finished, as it's waiting for the pipe it's writing to to flush, but the loop that reads that pipe has already exited, leaving the command stuck, and the test hangs. Instead, make the default "wait_for_input" of the run_command infinite, and allow the user to override it if they want with a default timeout option "RUN_TIMEOUT". But this fixes the hang that happens when the pipe is full and the ssh session never exits. Cc: stable@vger.kernel.org Fixes: 6e98d1b4415fe ("ktest: Add timeout to ssh command") Signed-off-by: Steven Rostedt Tested-by: Masami Hiramatsu (Google) --- tools/testing/ktest/ktest.pl | 20 ++++++++++++++++---- tools/testing/ktest/sample.conf | 5 +++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 78249c3a03a5..7c91d753a9f2 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -178,6 +178,7 @@ my $store_failures; my $store_successes; my $test_name; my $timeout; +my $run_timeout; my $connect_timeout; my $config_bisect_exec; my $booted_timeout; @@ -340,6 +341,7 @@ my %option_map =3D ( "STORE_SUCCESSES" =3D> \$store_successes, "TEST_NAME" =3D> \$test_name, "TIMEOUT" =3D> \$timeout, + "RUN_TIMEOUT" =3D> \$run_timeout, "CONNECT_TIMEOUT" =3D> \$connect_timeout, "CONFIG_BISECT_EXEC" =3D> \$config_bisect_exec, "BOOTED_TIMEOUT" =3D> \$booted_timeout, @@ -1862,6 +1864,14 @@ sub run_command { $command =3D~ s/\$SSH_USER/$ssh_user/g; $command =3D~ s/\$MACHINE/$machine/g; =20 + if (!defined($timeout)) { + $timeout =3D $run_timeout; + } + + if (!defined($timeout)) { + $timeout =3D -1; # tell wait_for_input to wait indefinitely + } + doprint("$command ... "); $start_time =3D time; =20 @@ -1888,13 +1898,10 @@ sub run_command { =20 while (1) { my $fp =3D \*CMD; - if (defined($timeout)) { - doprint "timeout =3D $timeout\n"; - } my $line =3D wait_for_input($fp, $timeout); if (!defined($line)) { my $now =3D time; - if (defined($timeout) && (($now - $start_time) >=3D $timeout)) { + if ($timeout >=3D 0 && (($now - $start_time) >=3D $timeout)) { doprint "Hit timeout of $timeout, killing process\n"; $hit_timeout =3D 1; kill 9, $pid; @@ -2066,6 +2073,11 @@ sub wait_for_input { $time =3D $timeout; } =20 + if ($time < 0) { + # Negative number means wait indefinitely + undef $time; + } + $rin =3D ''; vec($rin, fileno($fp), 1) =3D 1; vec($rin, fileno(\*STDIN), 1) =3D 1; diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.c= onf index 2d0fe15a096d..f43477a9b857 100644 --- a/tools/testing/ktest/sample.conf +++ b/tools/testing/ktest/sample.conf @@ -817,6 +817,11 @@ # is issued instead of a reboot. # CONNECT_TIMEOUT =3D 25 =20 +# The timeout in seconds for how long to wait for any running command +# to timeout. If not defined, it will let it go indefinitely. +# (default undefined) +#RUN_TIMEOUT =3D 600 + # In between tests, a reboot of the box may occur, and this # is the time to wait for the console after it stops producing # output. Some machines may not produce a large lag on reboot --=20 2.39.0