From patchwork Sun Feb 18 18:57:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 202842 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp912017dyc; Sun, 18 Feb 2024 11:00:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW3XbSoDBBH1rnCeEqyecCX9uuYfqXTkyEjVg6ZUBN8ZiK4SPtTsY9I31+nRumoQiQIjUYv4fiyfZp5cADTIzV/3atxSg== X-Google-Smtp-Source: AGHT+IEj6gLjH/glgsx/FUV9e6SBIR51KkJqniCjp2D+mlakJ7hiUfK7SYVBhRqsncZJ13y9HWZc X-Received: by 2002:a05:6808:1156:b0:3c0:3f3f:16e9 with SMTP id u22-20020a056808115600b003c03f3f16e9mr13935260oiu.12.1708282837551; Sun, 18 Feb 2024 11:00:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708282837; cv=pass; d=google.com; s=arc-20160816; b=WPHZwTCfWUY5RdhSEWPVe5h8bst3WBNcFX0+THhlp/08Rb5hyOVk60bLDjidbdHWUV Ua4WxQsI+F2JKTgBDdhvGtT9SQiifB4JEJJkvqwKiGkBKzaMO2AEc5gjBvNdcVrCMN3v NzqB+BPQQLlt4pyG8lhwU/kCot5hDxPqsa/ZvQpp/Bci9UoEC1XdUpXOEf9b5EHSM1+g 8QLpJqH6ORyGHgcHv8zug7OQg4UnTo+CazvzOCPYMBtlk0g3iVJA9wuKfPJB00vffBS+ w/E8ifCWbCvXgYs9cD6jNFp3+TK9+3J0drKxOCA1XgK38ucynnM35OiWGVZ/b4jHls/u XaCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=0GibUZTFTeq8Azv+JjrVAmh6V7HAl4otIfefb2UG9wk=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=LMgqngEb85GK7ah3vfgEUiiAgIuL4LRqMyzTJfVQg7GsFxymZMsCp2Xnl1oAi0Zr3m G5apJoq67lUZVXECOKQ/yyUPKvvI/GM3LUM+CVIFxsJrLLnWGj+PuLk0MfoL46qjOnWH 6jWki4+jVzZw3Iu1LR0O1RA8atVMnLWD+6qR8JzO0HaBfwJAmJkLnCbZODZrTlgoSzK7 Atd+UhRvYMKgybXomTqNbwx6ycK82uSEYWYf+yX8l86QxFzyfPn9Uqby5u+QRfWE/zA+ 60FkNzWWSCWlRHKlhdbMgezo/npIlGUQGf4OyP/eORSsPu+SGEdd52l75xd/Q9M8NtFw QL7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UiMlLlop; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-70506-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70506-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z187-20020a6333c4000000b005dc49a8c93fsi3189089pgz.764.2024.02.18.11.00.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 11:00:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70506-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UiMlLlop; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-70506-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70506-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 787D8B20F40 for ; Sun, 18 Feb 2024 19:00:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3DF276034; Sun, 18 Feb 2024 18:58:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="UiMlLlop"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gFUUiIHd" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 470346F50C for ; Sun, 18 Feb 2024 18:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708282675; cv=none; b=bTVB4U3gorWFZCM9rTR+7W7fWi/qCziwgEkGLSi5AYqKgs11rFivksI/tcxHDsuGn+xaxthhEnW7F75HSPdKv4zM5IoA6WRYLTTT4nXF+v1NwlEbIQQ0VKSBJ0wg99CWAqiTARwQC86kuhRZYoHGfHQdnJPdzNDUyyk9KCuxyBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708282675; c=relaxed/simple; bh=KWSkXCKQeNrr5eZStT4LqIX1rH8fREQLBiX0c1gHrHM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sy7ozQXYskoiRyAtZtwEyjfCsjAGRiVQKSZ2i3KrMthUfKmJJGr33q28amZr0BpW2oMb+EAu71HkcrglfQvI6DbV20pooeFJo0sBQPMrxLgShppA2dRKU1Ocl0OfE6AyzqcKLqouIXQN/BLP3kxLMyuDKvAsnFebJDNsnv54wfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=UiMlLlop; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gFUUiIHd; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708282672; 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=0GibUZTFTeq8Azv+JjrVAmh6V7HAl4otIfefb2UG9wk=; b=UiMlLlop/JEpMBas0X+fajoIusei1Be/FpyJcoty5xeAu1KPqr30RJO4Hqf8X8OyGyDfXN nU4N3qCrcwCfyCoU3j+3RzzC96tUZFGkLzMmvIpCbG4POseS/+TEi98WGoMo/Zyz3K/YMe F/dZ2U45Azmi1NXFJX/PuiIfwJVVEGkhkbBKuu5yW2J4OfBtwmceEveWAu9QcNEa+xd6+1 5tjS6hUYg9cj0kG37YdxaCUukxh3+QoatNCcg9S1ejaC+ZS/pbp7beRR+3DY/OKSYzPF4F AfbBSmFwHRjJTseChgbZxHA9q41FgyWWNUd0Z6lBsrjGTPjwE/6NnKv2Z/j22Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708282672; 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=0GibUZTFTeq8Azv+JjrVAmh6V7HAl4otIfefb2UG9wk=; b=gFUUiIHdAlO9f732mfLv2nx9vP+orySfBI5//27FsQFvL56KV9Ud3P30BMUojDQAZxZS0G GlaQl5HxOC/sgCDw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 13/26] printk: Add @flags argument for console_is_usable() Date: Sun, 18 Feb 2024 20:03:13 +0106 Message-Id: <20240218185726.1994771-14-john.ogness@linutronix.de> In-Reply-To: <20240218185726.1994771-1-john.ogness@linutronix.de> References: <20240218185726.1994771-1-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791264385035857504 X-GMAIL-MSGID: 1791264385035857504 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 Reviewed-by: Petr Mladek --- 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 ecb50590815c..9d56ce5837f9 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2939,9 +2939,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; @@ -3783,7 +3784,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) {