Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp142154imw; Thu, 14 Jul 2022 23:13:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uXSg+TEFPZirEnczwDu/nZYajWe/xsicugV9vvePdDJdrCKmJBszujWYDkgM3YjQjGZLll X-Received: by 2002:a05:6402:360d:b0:435:710a:2531 with SMTP id el13-20020a056402360d00b00435710a2531mr16539599edb.377.1657865608889; Thu, 14 Jul 2022 23:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657865608; cv=none; d=google.com; s=arc-20160816; b=EfCSQCAoJObQtBQatMUWM2zSENSXTZbeZPXELHsx5tCNO30sS6FtM/+gSE4MS/5J7X Sr0/ma/J41vKIb7+DPAwQ5uHN3PalpyUwYQjM09Prn9vYoEwOrTFYHwmuwuKEYehvlrv 6rWgXfIDC9SU8k3GcaAkvOZm0hr/y+fWEjSdfOMYGsKy6SMj5rSXwHBNWthoJf3PC4lk eHScOdIZOeUhOIbsSaqCyD0ZibwtNPX3Ca8ezffc9AqBNCji0fbEGc6KXjAfUKkd0Zu6 HVdg5kyNjPtHgpLxjS6xX9G8RzUTCS5dJMKZZ/xy3Dh3UJ6KXmCFPtj4tmnpCZIhXMvE T5vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=34AfcYpevfLpsDQXx/FrfkJftZBZGpSvDOrexHkg1Ig=; b=0cpIPI58dSZuj7ssipKnokeU8NYWtop8edZgqW2Sxe9KogQAGJ/XTRWjib5aZRgHh5 0BC8AE+50z0Q1I9p3yYFwVshrdpySTkMPrOt9agp5sjq5ZwBh5bv0YFVXOLv0XHkApHK 31hWmG0J8EqwKb5ly+5dVaN7pjMm0IO20sppcoKj/xesjBk0I05FuUBRYaawcmRcJuWC 0JPujPiKig4B2ZTys2GQgp9mdm5XvtI0AJvo/8WnW5bVODupJ8GyxbHQ6WnS7EbLZGVf h0jTG+LPEzKlXzeWqFPVn3vNhxXEc8uCkht00RN0pey7qzwggdFg3HCvG9lmRgxLUVZX jbhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pt1XvMFa; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=s8p4KjZQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du17-20020a17090772d100b0072697437875si3335360ejc.704.2022.07.14.23.13.03; Thu, 14 Jul 2022 23:13:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pt1XvMFa; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=s8p4KjZQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229685AbiGOGK4 (ORCPT + 99 others); Fri, 15 Jul 2022 02:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230201AbiGOGKs (ORCPT ); Fri, 15 Jul 2022 02:10:48 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59017735BF for ; Thu, 14 Jul 2022 23:10:45 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1657865443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=34AfcYpevfLpsDQXx/FrfkJftZBZGpSvDOrexHkg1Ig=; b=pt1XvMFaFcgmDP+bDSKk87KCLSwA9Vwnmvss/Ga7S2kJPU4FdC5p5otm5tnKzA93gLfaBM 2sqv1+BQ3ZE4FS2N844tja4oiFUieKjhCIz23HjvEBD14JNdNKHEM9USJ3J3js2R1muLkR c0t2YSwBNBuNDU115qFOydbpJ74WJsPyCk+KRXBdxPXTwZaSSkL8U0I6Cvi2CfN+T+DfQ1 ZxeMrEuCeBx1eK4EoBIgcgTl71rwCi13v2Zs/s/fSjDTSxj/zaRxZRuc9WXrFqbkp9YnTU UJzEY6tdLva6wE3goE7njDeVJthkKUahGKEysV5GRPZRJG6hXbfhYxVv7fP91w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1657865443; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=34AfcYpevfLpsDQXx/FrfkJftZBZGpSvDOrexHkg1Ig=; b=s8p4KjZQTCDnVdlw0A8f3hsaM1Am+lI8UlfF0y7SwE35QRP0d0Z54Ij668d/viwRBSr0uR Ux7SvrXmnTPXSyAQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , linux-kernel@vger.kernel.org, Todd Brandt Subject: [PATCH v3] printk: do not wait for consoles when suspended Date: Fri, 15 Jul 2022 08:16:42 +0206 Message-Id: <20220715061042.373640-2-john.ogness@linutronix.de> In-Reply-To: <20220715061042.373640-1-john.ogness@linutronix.de> References: <20220715061042.373640-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: John Ogness Tested-by: Todd Brandt --- 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