* [PATCH v3] printk: fix extra suspend/resume delays
@ 2022-07-15 6:10 John Ogness
2022-07-15 6:10 ` [PATCH v3] printk: do not wait for consoles when suspended John Ogness
0 siblings, 1 reply; 3+ messages in thread
From: John Ogness @ 2022-07-15 6:10 UTC (permalink / raw)
To: Petr Mladek; +Cc: Sergey Senozhatsky, Steven Rostedt, linux-kernel
As reported here [0], an unnecessary delay exists in the
suspend/resume paths for certain scenarios. Here is the
fix for it. Since the extra delays were introduced in
5.19-rc1, this fix should go into 5.19-rc7.
The changelog is in the patch stats.
John Ogness
[0] https://bugzilla.kernel.org/show_bug.cgi?id=216216
John Ogness (1):
printk: do not wait for consoles when suspended
kernel/printk/printk.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
base-commit: 32346491ddf24599decca06190ebca03ff9de7f8
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3] printk: do not wait for consoles when suspended
2022-07-15 6:10 [PATCH v3] printk: fix extra suspend/resume delays John Ogness
@ 2022-07-15 6:10 ` John Ogness
2022-07-15 9:14 ` Petr Mladek
0 siblings, 1 reply; 3+ messages in thread
From: John Ogness @ 2022-07-15 6:10 UTC (permalink / raw)
To: Petr Mladek; +Cc: Sergey Senozhatsky, Steven Rostedt, linux-kernel, Todd Brandt
The console_stop() and console_start() functions call pr_flush().
When suspending, these functions are called by the serial subsystem
while the serial port is suspended. In this scenario, if there are
any pending messages, a call to pr_flush() will always result in a
timeout because the serial port cannot make forward progress. This
causes longer suspend and resume times.
Add a check in pr_flush() so that it will immediately timeout if
the consoles are suspended.
Fixes: 3b604ca81202 ("printk: add pr_flush()")
Reported-by: Todd Brandt <todd.e.brandt@linux.intel.com>
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Tested-by: Todd Brandt <todd.e.brandt@linux.intel.com>
---
v3: add more details to commit message and comment
v2: only avoid wait if suspended
kernel/printk/printk.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index b49c6ff6dca0..a1a81fd9889b 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -3380,6 +3380,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
diff = 0;
console_lock();
+
for_each_console(c) {
if (con && con != c)
continue;
@@ -3389,11 +3390,19 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
if (printk_seq < seq)
diff += seq - printk_seq;
}
- console_unlock();
- if (diff != last_diff && reset_on_progress)
+ /*
+ * If consoles are suspended, it cannot be expected that they
+ * make forward progress, so timeout immediately. @diff is
+ * still used to return a valid flush status.
+ */
+ if (console_suspended)
+ remaining = 0;
+ else if (diff != last_diff && reset_on_progress)
remaining = timeout_ms;
+ console_unlock();
+
if (diff == 0 || remaining == 0)
break;
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v3] printk: do not wait for consoles when suspended
2022-07-15 6:10 ` [PATCH v3] printk: do not wait for consoles when suspended John Ogness
@ 2022-07-15 9:14 ` Petr Mladek
0 siblings, 0 replies; 3+ messages in thread
From: Petr Mladek @ 2022-07-15 9:14 UTC (permalink / raw)
To: John Ogness; +Cc: Sergey Senozhatsky, Steven Rostedt, linux-kernel, Todd Brandt
On Fri 2022-07-15 08:16:42, John Ogness wrote:
> The console_stop() and console_start() functions call pr_flush().
> When suspending, these functions are called by the serial subsystem
> while the serial port is suspended. In this scenario, if there are
> any pending messages, a call to pr_flush() will always result in a
> timeout because the serial port cannot make forward progress. This
> causes longer suspend and resume times.
>
> Add a check in pr_flush() so that it will immediately timeout if
> the consoles are suspended.
>
> Fixes: 3b604ca81202 ("printk: add pr_flush()")
> Reported-by: Todd Brandt <todd.e.brandt@linux.intel.com>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> Tested-by: Todd Brandt <todd.e.brandt@linux.intel.com>
The patch is committed in printk/linux.git, branch rework/kthreads.
I think about creating pull request for 5.19 later today or tomorrow
so that it is in the last rc.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-15 9:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-15 6:10 [PATCH v3] printk: fix extra suspend/resume delays John Ogness
2022-07-15 6:10 ` [PATCH v3] printk: do not wait for consoles when suspended John Ogness
2022-07-15 9:14 ` Petr Mladek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox