Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1034618rdb; Tue, 19 Sep 2023 19:16:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsA6fburZ0u9K82ldUJoyeR1kHZ7XQe8LecW7MAb4DVz6TAKik46nvd16qjbB0QwvSRwQT X-Received: by 2002:a54:4e85:0:b0:3ad:af12:2fbc with SMTP id c5-20020a544e85000000b003adaf122fbcmr893886oiy.38.1695176193679; Tue, 19 Sep 2023 19:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695176193; cv=none; d=google.com; s=arc-20160816; b=u5etbU6B3cmj6Nj9A1+uVrR7RQnswFVQ7MfMUXzPCg08/1jr3TM/75XC1zLnU75Htw tE9QDvCduB9VgASPS32EOXVf/Pd1PPaHfcF2AagtpJf7+V46C1yfV4yrb+3XmHbo+Nzg xIr6U4+EzaM+bIBKa9w/aJLKdzGKh1uRfnja3QNM2KaErWkpHMMBqSaQN/h9laFh+i0A pYHCB3RI727Q7xZ72upqa7tAINHbEJwyMn+xPeGTA+0zgeMi6P5ICK/a4/UlHAGT9Rd4 EFpR/pKKjJ10R6q2WgG13CuxjMuWFap05XpCMYhaPSonoaQ+es3cbcoQTkofzCNOesus ilzA== 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=zprfWcxtWmGsW80DlqzMcGe9h+c0hqNmqd+wr5GO9aw=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=AV6iHZ5648H1/MKh6OMYoHYCWlUQQw+YVy7lpYPDrONe9nXhf2N+gxR3vJE01EhxLQ B4SSD/xkYOS5kN2AltV6YVq6uG4OLpm3pYM+Q92xkZBbYxEIJMJ42V+7bXgB5Jid5nPu hc/K8WdoY2zvJ3Qm5WlPJCOpNYSI/uSnmBxmHLMiADfs/m3rLmTezp1DUmAVY0jP9EXD JgMtVjoMp5ciqmGQ2QQiJwnBhgdCDRFvAUIPhKtzZIGuPPAdwAk+a+QK6LGQ6Oe8ivmz A91eJOiXTjiJQvbwMa1BJGQbQ1aTeghPiwSa9xyZ+KVqJkcAfoaH9Tg02FOJvROugUec lxrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NqrWEArT; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u11-20020a63d34b000000b00573fef8a892si10663652pgi.484.2023.09.19.19.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 19:16:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NqrWEArT; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 869DD82878E4; Tue, 19 Sep 2023 16:10:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233545AbjISXJ0 (ORCPT + 99 others); Tue, 19 Sep 2023 19:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233297AbjISXJS (ORCPT ); Tue, 19 Sep 2023 19:09:18 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30E4CC9 for ; Tue, 19 Sep 2023 16:09:11 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695164948; 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=zprfWcxtWmGsW80DlqzMcGe9h+c0hqNmqd+wr5GO9aw=; b=NqrWEArTVkOy9DG7b5frQSYQblAKGvpp22x32+WwFYR9zB6qW/0fsQSr7IV39IfV37Da7q Q+hj7kJKWiQnEpNbIZbY5vEwLvjA/N/ELDLTHQNpTLDoRkoGgE7HBGX1u+cvrTsbASjCJw yIhIM5NDscnXHQNRStawJyeFrYHLO6bT+WgpyE10s1QsoIslZhViDxVOWo/wApqHgnr9rb A72Alx8CHXUD3IR9/KZaidJ0Rwmdmv18/i4JOu52dYZ8ZbW90yp4EaVK+p5/VRqHRdTYJ+ EGyTfSRGNH9BMpOuvHbq3b/GT+568tcM1kHqWz5ivbxYiGbKCk9MpV6Ey1aJdg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695164948; 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=zprfWcxtWmGsW80DlqzMcGe9h+c0hqNmqd+wr5GO9aw=; b=rVZGFDSbIEtHTnitVDxJl51V5moAMlVq4GL6Rmxzwt9+Kz/f6jDOnmo/CBN8p5GEZunxnH 7Y73EIQfaJ1N5cBg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 03/11] printk: Add @flags argument for console_is_usable() Date: Wed, 20 Sep 2023 01:14:48 +0206 Message-Id: <20230919230856.661435-4-john.ogness@linutronix.de> In-Reply-To: <20230919230856.661435-1-john.ogness@linutronix.de> References: <20230919230856.661435-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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 19 Sep 2023 16:10:07 -0700 (PDT) The caller of console_is_usable() usually needs @console->flags for its own checks. Rather than having console_is_usable() read its own copy, make the caller pass in the @flags. This also ensures that the caller saw the same @flags value. Signed-off-by: John Ogness --- kernel/printk/internal.h | 8 ++------ kernel/printk/printk.c | 5 +++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index 69c8861be92c..6780911fa8f2 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -83,13 +83,9 @@ void nbcon_free(struct console *con); * records. Note that this function does not consider the current context, * which can also play a role in deciding if @con can be used to print * records. - * - * Requires the console_srcu_read_lock. */ -static inline bool console_is_usable(struct console *con) +static inline bool console_is_usable(struct console *con, short flags) { - short flags = console_srcu_read_flags(con); - if (!(flags & CON_ENABLED)) return false; @@ -136,7 +132,7 @@ static inline bool nbcon_alloc(struct console *con) { return false; } static inline void nbcon_init(struct console *con) { } static inline void nbcon_free(struct console *con) { } -static inline bool console_is_usable(struct console *con) { return false; } +static inline bool console_is_usable(struct console *con, short flags) { return false; } #endif /* CONFIG_PRINTK */ diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index b6cfae75a574..6ef33cefa4d0 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2929,9 +2929,10 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove cookie = console_srcu_read_lock(); for_each_console_srcu(con) { + short flags = console_srcu_read_flags(con); bool progress; - if (!console_is_usable(con)) + if (!console_is_usable(con, flags)) continue; any_usable = true; @@ -3754,7 +3755,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre * that they make forward progress, so only increment * @diff for usable consoles. */ - if (!console_is_usable(c)) + if (!console_is_usable(c, flags)) continue; if (flags & CON_NBCON) { -- 2.39.2