Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1428575lqm; Thu, 2 May 2024 14:49:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmis4PYvZ0g7KCG7WR/6yPbNPqOLlvqCOabkBtM+X30No+K6IwVCT0GrEYClAn3eniFQHVrV6KRCVnm7Hi23zH3lom9vF02zBcIB5uHA== X-Google-Smtp-Source: AGHT+IEHIuvHukipLf0d9F72PT7Ifs84rGPhNnuOsb/jPJ6e9ip0dXJzut+elNTFYhLpXVTJ+hMt X-Received: by 2002:a05:6a00:8c4:b0:6ec:f1ae:f579 with SMTP id s4-20020a056a0008c400b006ecf1aef579mr902146pfu.19.1714686540756; Thu, 02 May 2024 14:49:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714686540; cv=pass; d=google.com; s=arc-20160816; b=0xMLeXyppltQMzI4mZ0QW774HFKNXnSnzQzI/Yvi6qSk6gwJ9ne9cw66IZHO9XjEN5 tTumE89PY6lFdvjvXOXZQVNvdyN2t6FIWaoQPMvnPcPbVPdbJDV65YJYz8L5KpfvB1Fq O8Ubp/cY/UvWuyzmTmVfZqNTxM5YpGkkcBPwW72kOtAfssBwT0vFPStKDXreY0f+wGPO QFGdjkrCAmh0XTKG6Mt6w02+3p+HPFxI9jIZIaR/FzhCKaOgEzmIE/iXvde9UOLiEYil C3/b2er2DDMTsiV8NkrAxis6KHtF+o6P0RREsQyivqOrxvK2Hav1mjkbeBV/EWWtnjHl DLCw== 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=vHXFQ842EHAesP3cWbIS8s/eD5QSwLsV5qin0yhI+w4=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=uRfBAN/n4ITSkvLTVUoppICA4GXNFc1BVE8I8mGDxWsg1+j2ITXSNYaekVVP+ODpQ/ GkD5Q/yRCFO5C4CyzGVI7GHmE5PfIwljJJkBN8HU7fgPk4kjlpVlOFL9msLrXe4XzuCG S399HIms7+cksl8WWfVzjkM1hi/Sz4iAqWX6r4/H0MAllF4UExLpI+tsfsxtYc3yQCSK rGZ1tNBzryteuCEpNIu4Lcn4YbnvoB8d4FG/IPcr8UekJUNaO8U26tCC+OvuDPtNvCKc 4EcHGuF0IF5Thm2lBdNsObYsTgdmC4dZ1ZFgGrVvgNKyXlAzqgs4q2A0Ja7kbPDPttrQ B0Eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=u0lnJc6O; 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-166969-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x22-20020a056a00189600b006ecf2e21155si1797688pfh.249.2024.05.02.14.49.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 14:49:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166969-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=u0lnJc6O; 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-166969-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166969-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D81EE28B0FD for ; Thu, 2 May 2024 21:41:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20D39175551; Thu, 2 May 2024 21:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="u0lnJc6O"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QDGpdx7F" 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 5C9B61C65EC for ; Thu, 2 May 2024 21:38:52 +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=1714685934; cv=none; b=tjPSwg3iYgoYokrzCmRq3puDAgS3tv9Og0DHP+rypwhUrq28MvIhI3VZJ7aDmzJdVUp2eA+1tSqH3lifjmKAYZNkJh0ld1i3b8eeGjcioOBCjCtAmRgZPw6hiBcHe4FR6Bvw86ktuGGgxL8ufB7SkS4nSM5zSIrr7/YrvaAL548= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714685934; c=relaxed/simple; bh=SNLZe25NvdawX74sPMNN2b32M9UWDQ0xBcf74EaYUGs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ez65Ed11GO0WXismU833mXESueJ+Xmv9hZHXCvsCd84uL0stkie2flCSU7WMhMGE1WRuDb2GsGg6h96jKnemW5SK2lQzBqL8yFQMT8OG7/B4iwz5oVvwl8F3frX6jft96hG1nhLVlFjbeSW5/raoLPRFomXUQ3yskToB+FXZVuA= 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=u0lnJc6O; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=QDGpdx7F; 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=1714685931; 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=vHXFQ842EHAesP3cWbIS8s/eD5QSwLsV5qin0yhI+w4=; b=u0lnJc6OtkrxDt5k76e0WVIUprCNBu9MktrVs8rsgDncMTv7pyWfIDOygfzEIHCxiA3m1T mPa+et4CoUVTYN1PcDUbcIk5JpF/qc22Aul5LWW3OrFVCu/nBG5pfsAhkh4+yvhf83BQKr B7p4XvToB31OItxKQmKCD7DWDOzB/terNQw09PVz2YW0yArQ5ls6JYrVxHzHItQZCvDytc HvT2cnAEY+o5fuuakohSvqvBWv9fJGVvH2n219HYVsS1+8rv6oLL0h8PWeHqdX5rkUNmZX coWd1HRN8G/oCyoYYB0GwFLmoH9qbx3vgZ5UWkSW3SEdZ+43IouiNFBOL1sfQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1714685931; 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=vHXFQ842EHAesP3cWbIS8s/eD5QSwLsV5qin0yhI+w4=; b=QDGpdx7F/MGax+73p1+r2KrWTywkx7Qu89uuyDkRbnj4YFv+60ndkyutIyN2BRzd8rmluK MEYKpLhNGHbIKYBg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v5 17/30] printk: Add @flags argument for console_is_usable() Date: Thu, 2 May 2024 23:44:26 +0206 Message-Id: <20240502213839.376636-18-john.ogness@linutronix.de> In-Reply-To: <20240502213839.376636-1-john.ogness@linutronix.de> References: <20240502213839.376636-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 Content-Transfer-Encoding: 8bit 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 943e8f083609..e2de2d262db4 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -90,13 +90,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; @@ -143,7 +139,7 @@ static inline bool nbcon_alloc(struct console *con) { return false; } static inline void nbcon_init(struct console *con, u64 init_seq) { } 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 b0e99ee472e1..9cdc110a46a2 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2942,9 +2942,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; @@ -3823,7 +3824,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