Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp4048188rdh; Fri, 29 Sep 2023 09:30:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExTxcRoaaQmwjXNU7BBX8JQjvRdoeMqAZtGGnnOjR2n5NSswgp6yWuBNCgxYNzleGFigPV X-Received: by 2002:a17:90a:b396:b0:277:422d:3a0f with SMTP id e22-20020a17090ab39600b00277422d3a0fmr7551934pjr.17.1696005016498; Fri, 29 Sep 2023 09:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696005016; cv=none; d=google.com; s=arc-20160816; b=AZJ8+NnSE6fcSR4XBdeeFUSAIOcOhlbfm7fkd4rstR493zzAhr9Qd5POFiN17JzG6u OD8AGZdV7pmJNQA/82NdBAoP6T0DsslduSSHnfuqAt+3V1ebLDQYR6idnY8+m+iV1Vwn HPGcrSP4y6NZeTQj/+ZF8H+fiwrEVvcCdH1rMpHK9Q9VEXMH/cUwRwuv7EulLmMwzONz 3wqVK2zGUYMwsuLLq2+xVziychFRR/UQWfsDZQC7yOOvnBh/p0qEnflTySxv5+gnRfoR 9qqkBnIQf1t6kRjndTtpUo8+0JybFieFMXE4//1kvdQe6WY82Vf9oxmGD8/s8qWWNqLV uVHQ== 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 :message-id:date:subject:cc:to:dkim-signature:dkim-signature:from; bh=UIipO+SgaQkwOUgqbE7dftCadTipucHktt7Dz7VlEvw=; fh=+WiQ2jjWv7hkX4n01jo89PecmvbVaG49N7UAN6x9A/o=; b=ZpShUBsovEzcKa3h5PBYziUY6uwJcWXbL/szFDlgFfVirbqy5tWEPgwg43Yu2JRoSf c7eW3UzojT4cwrnRFjPYXoLyE8dAVQehXntm+heLvWQcCpzgO2DLWOEFyYnXZVf3W3lX hjhoNEtOdwaLYXbIC8v1H7dScay2xeNp8OkBoEj25sU+xAf152+aCVOT+SdoVJfC+Q8r K5ySFVRO+KHDheAAM0yNgv4KrNJP5YfNFLJkZfqNs9iVjtQlVKq5jg/dflZzUIdCwNpw mLnCa3XAvpEHfJIIA/QtXTQSta5jvsPi/4LuAhgg5NuCzWwuVvath9ogASi0lcWi5M6U 2eTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="r0S/zBzC"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id h11-20020a17090ac38b00b002774e11ca41si1865728pjt.67.2023.09.29.09.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 09:30:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="r0S/zBzC"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 22457830D63F; Fri, 29 Sep 2023 04:32:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232803AbjI2Lck (ORCPT + 99 others); Fri, 29 Sep 2023 07:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbjI2Lcj (ORCPT ); Fri, 29 Sep 2023 07:32:39 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB2C294 for ; Fri, 29 Sep 2023 04:32:35 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695987154; 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; bh=UIipO+SgaQkwOUgqbE7dftCadTipucHktt7Dz7VlEvw=; b=r0S/zBzCESwXq+yQNhp+72oEodba2w5Q87jwg/Wb+Q4mFjid2uFBD9anORdTgth7gKGg9W Qdx0rxID6I+zsRwm/HyNJ6TDE8qLPJRO4vmh9LVj0rRbCEYyCVBgMUz87TOF8wOtTS2m7Q m6lJNfzGYwtC2QkZSo6dZRPRKeCCnE4ML8O18KP8PDjPahYbwjTY/3TwC8aV0LCjjVaYer koMPc1AdEccb0OXgUywdw54RoxnDOOlr6zszE2ISn2H9ZAwpCP3i3gvBaD+bJrWZp9pWvE yzYhvB+3CbKyfxZ/Ih7o3S2JXKPzFFvuVXv//EsqwyQv/FrNuDjJgjJY8VK2HQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695987154; 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; bh=UIipO+SgaQkwOUgqbE7dftCadTipucHktt7Dz7VlEvw=; b=0X1loJtvalKL2keyu/6BHQPhV1aCbcE1sPE4dCfaNYEdpEVVkvBTU92IeatfUoTi4gpI9t wMjJXO1s65fLNQBA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Todd Brandt Subject: [PATCH printk] printk: flush consoles before checking progress Date: Fri, 29 Sep 2023 13:38:33 +0206 Message-Id: <20230929113233.863824-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INVALID_DATE_TZ_ABSURD, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 29 Sep 2023 04:32:51 -0700 (PDT) Commit 9e70a5e109a4 ("printk: Add per-console suspended state") removed console lock usage during resume and replaced it with the clearly defined console_list_lock and srcu mechanisms. However, the console lock usage had an important side-effect of flushing the consoles. After its removal, consoles were no longer flushed before checking their progress. Add the console_lock/console_unlock dance to the beginning of __pr_flush() to actually flush the consoles before checking their progress. Also add comments to clarify this additional usage of the console lock. Finally, in case pr_flush() needs to poll-wait (for example, because there has been a handover to another CPU), reduce the polling interval from 100ms to 1ms. In the bug report it was mentioned that 100ms is unnecessarily long. Reported-by: Todd Brandt Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217955 Fixes: 9e70a5e109a4 ("printk: Add per-console suspended state") Signed-off-by: John Ogness --- kernel/printk/printk.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 7e0b4dd02398..cf7841fc6eef 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3740,12 +3740,18 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre seq = prb_next_seq(prb); + /* Flush the consoles so that records up to @seq are printed. */ + console_lock(); + console_unlock(); + for (;;) { diff = 0; /* * Hold the console_lock to guarantee safe access to - * console->seq. + * console->seq. Releasing console_lock flushes more + * records in case @seq is still not printed on all + * usable consoles. */ console_lock(); @@ -3775,16 +3781,11 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre if (diff == 0 || remaining == 0) break; - if (remaining < 0) { - /* no timeout limit */ - msleep(100); - } else if (remaining < 100) { - msleep(remaining); - remaining = 0; - } else { - msleep(100); - remaining -= 100; - } + msleep(1); + + /* If @remaining < 0, there is no timeout limit. */ + if (remaining > 0) + remaining--; last_diff = diff; } base-commit: 4952801fc6adb5b50b8ec2bcc5aeef92fcce8730 -- 2.39.2