mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: "John Warthog9 Hawley" <warthog9@kernel.org>,
	"Ricardo B. Marlière" <rbm@suse.com>,
	"John Hawley" <warthog9@eaglescrag.net>,
	"Andrea Righi" <arighi@nvidia.com>,
	"Marcos Paulo de Souza" <mpdesouza@suse.com>,
	"Matthieu Baerts" <matttbe@kernel.org>,
	"Fernando Fernandez Mancera" <fmancera@suse.de>,
	"Pedro Falcato" <pfalcato@suse.de>
Subject: [for-next][PATCH 6/9] ktest: Stop dropping console output during power-cycle reboot
Date: Mon, 16 Mar 2026 14:40:39 -0400	[thread overview]
Message-ID: <20260316184116.554314614@kernel.org> (raw)
In-Reply-To: <20260316184033.927944169@kernel.org>

From: =?UTF-8?q?Ricardo=20B=2E=20Marli=C3=A8re?= <rbm@suse.com>

The POWER_CYCLE fallback added to reboot() flushes monitor output at the
wrong time. In the untimed reboot path, flushing immediately after
start_monitor() can consume the first output from the new boot before
monitor() begins reading it. In the timed path, flushing after POWER_CYCLE
can eat the "Linux version" banner or REBOOT_SUCCESS_LINE from the new
kernel.

That makes ktest miss the boot it is waiting for and can trigger an
unnecessary second power cycle.

Start the monitor before POWER_CYCLE so the reference counting stays
balanced, but only flush when reboot() was asked to wait for a timed
reboot. Perform that flush before issuing POWER_CYCLE so it drains stale
output from the old kernel instead of consuming the next boot.

Cc: John Hawley <warthog9@eaglescrag.net>
Cc: Andrea Righi <arighi@nvidia.com>
Cc: Marcos Paulo de Souza <mpdesouza@suse.com>
Cc: Matthieu Baerts <matttbe@kernel.org>
Cc: Fernando Fernandez Mancera <fmancera@suse.de>
Cc: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20260307-ktest-fixes-v1-6-565d412f4925@suse.com
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/testing/ktest/ktest.pl | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 9d6f50045dbd..bd2e2311884c 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -1499,12 +1499,13 @@ sub reboot {
     }
 
     if ($powercycle) {
-	run_command "$power_cycle";
-
 	start_monitor;
-	# flush out current monitor
-	# May contain the reboot success line
-	wait_for_monitor 1;
+	if (defined($time)) {
+		# Flush stale console output from the old kernel before power-cycling.
+		wait_for_monitor 1;
+	}
+
+	run_command "$power_cycle";
 
     } else {
 	# Make sure everything has been written to disk
-- 
2.51.0



  parent reply	other threads:[~2026-03-16 18:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16 18:40 [for-next][PATCH 0/9] ktest: Updates to ktest for 7.1 Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 1/9] ktest: Avoid undef warning when WARNINGS_FILE is unset Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 2/9] ktest: Resolve LOG_FILE in test option context Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 3/9] ktest: Treat undefined self-reference as empty Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 4/9] ktest: Honor empty per-test option overrides Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 5/9] ktest: Run commands through list-form shell open Steven Rostedt
2026-03-16 18:40 ` Steven Rostedt [this message]
2026-03-16 18:40 ` [for-next][PATCH 7/9] ktest: Add PRE_KTEST_DIE for PRE_KTEST failures Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 8/9] ktest: Run POST_KTEST hooks on failure and cancellation Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 9/9] ktest: Add a --dry-run mode Steven Rostedt

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=20260316184116.554314614@kernel.org \
    --to=rostedt@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=fmancera@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mpdesouza@suse.com \
    --cc=pfalcato@suse.de \
    --cc=rbm@suse.com \
    --cc=warthog9@eaglescrag.net \
    --cc=warthog9@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®