Message ID | 20221114162932.141883-17-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2238193wru; Mon, 14 Nov 2022 08:31:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf7lpfSeoMhd+AgbYK8OHzJfi0XqO32CnSuDW9Kb8ZDtmoyI/hd6qLdy2DlIeoD7P2e3QTid X-Received: by 2002:a17:90b:48cd:b0:213:47:57cc with SMTP id li13-20020a17090b48cd00b00213004757ccmr14086294pjb.174.1668443490966; Mon, 14 Nov 2022 08:31:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668443490; cv=none; d=google.com; s=arc-20160816; b=fAmpvhjpb4tpUjO6+Vwq2X8Jr2BBFfP6bLtvQvtQjeRnN3UZn6tpwX0A71wy62ySZT l9cTyFPThy81ZT+5/3SafdfXcHHKnwwAQfbwXdOuFLktXMxQrhnm6TZPqqs3gLe86xsW KRi7ecTi3Xgljvm4JDlqjt5+jc8urIy2OWHANo4+vCCgYsJuOu19G50t0OiOBNI6PZfr h7kMO/DVsXAor4edYja4lA+jMpxjNeueqLlH9WgbfpEIdqkCIny8dVmdUFew23ILtIao JUY/TSPKzTqa0780o6YdvDtEIqVdZi0TYcwvl2hqfRhAdHvBkhhvtqSZZwkrJ9KOc9qP q6WA== 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=15kv2lfD0mZOWcVuclsvK9b1h/ynFw4leTYyP0YL6rw=; b=oar6LxdwK75KQ1KsaFzbyi+I2T1L/ItkoAdXpWcUlKIAPAAjIhsmt24hI9l116NPG4 9iQ2ueJB02lfIoP6HDi1ynp9Sa/xQvSwe7g6jHU5rKEDJegI/xmgn29Hol2D+H9v2C+f hOWBq8jgAjWg09NWfiRiibGrOgaFrZ5dmKWVh3Z5S4X0uJeSdBz9ZnVTVJBgh+IF7tGG BJ8UhSSJLDjaytGIUVIzIKhXzq00d5L+yKn/uD3FjqP8Tc4xd7jk88gx1KtDZRs8/fH6 fvxMUxZ8qEhnqWs6da9y6b3VVcPg/DbD33L9oN+D5BPu6BDENuLyySYDJtMhoNHmAI3Z mBYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=okh6A5Ql; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 20-20020a631454000000b0044b5e15db73si10368506pgu.249.2022.11.14.08.31.01; Mon, 14 Nov 2022 08:31:30 -0800 (PST) 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=okh6A5Ql; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S237669AbiKNQaf (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Mon, 14 Nov 2022 11:30:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237427AbiKNQ3q (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 14 Nov 2022 11:29:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8A1B1D329 for <linux-kernel@vger.kernel.org>; Mon, 14 Nov 2022 08:29:42 -0800 (PST) From: John Ogness <john.ogness@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668443381; 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=15kv2lfD0mZOWcVuclsvK9b1h/ynFw4leTYyP0YL6rw=; b=okh6A5QlkjpXnF9pvfDJcTztMcEqPE2ZSnWcrrxa3D8kuKAc8UTMRdT0c1hkuitjBXNNDM jhHlWRLXkX8q9iegblR2CQvjQgraDlaLGzqYlVGZUtAz/peO9lIHwhcH7h1SfDRDWjE0Jo pADbPTE4O44NqmyRyRKpjdsMVrW2yKAmXFF9mR03SnaMxDiX6ShaX066yswHAj21BHuVaf nvUjYGkkyBujbFZc+zxYh+0ZoO2NgyKwLLgfFWY11jLxO5ZPI50GRVptsLOOlyWfGYmQZu ex+5XtJByUT6RcllQbiHE3xIW2f2CcmN4+kl12Xb5IVcrAfkXFDOIC8rtAp0yg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443381; 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=15kv2lfD0mZOWcVuclsvK9b1h/ynFw4leTYyP0YL6rw=; b=OQIMQpLs1oTaVmqPcyzpUCH3snN/rsTE4GnEQR/mf0gHB+XdIdbvEWEUX7kbVh7tAr4HIb PFUVAyeQcHj6mwBg== To: Petr Mladek <pmladek@suse.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org Subject: [PATCH printk v4 16/39] printk: console_is_usable: use console_srcu_read_flags Date: Mon, 14 Nov 2022 17:35:09 +0106 Message-Id: <20221114162932.141883-17-john.ogness@linutronix.de> In-Reply-To: <20221114162932.141883-1-john.ogness@linutronix.de> References: <20221114162932.141883-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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749489802136629298?= X-GMAIL-MSGID: =?utf-8?q?1749489802136629298?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 14, 2022, 4:29 p.m. UTC
All users of console_is_usable() are SRCU iterators. Use the
appropriate wrapper function to locklessly read the flags.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
kernel/printk/printk.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Comments
On Mon 2022-11-14 17:35:09, John Ogness wrote: > All users of console_is_usable() are SRCU iterators. Use the > appropriate wrapper function to locklessly read the flags. > > Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Best Regards, Petr
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 3d9e5bb1a50b..bc563972e468 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2708,11 +2708,13 @@ static bool abandon_console_lock_in_panic(void) * Check if the given console is currently capable and allowed to print * records. * - * Requires the console_lock. + * Requires the console_srcu_read_lock. */ static inline bool console_is_usable(struct console *con) { - if (!(con->flags & CON_ENABLED)) + short flags = console_srcu_read_flags(con); + + if (!(flags & CON_ENABLED)) return false; if (!con->write) @@ -2723,8 +2725,7 @@ static inline bool console_is_usable(struct console *con) * allocated. So unless they're explicitly marked as being able to * cope (CON_ANYTIME) don't call them until this CPU is officially up. */ - if (!cpu_online(raw_smp_processor_id()) && - !(con->flags & CON_ANYTIME)) + if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME)) return false; return true;