Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5744002rwb; Mon, 14 Nov 2022 08:53:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf4MewFDclg5TNqhHXOr5ecEsWpw9jr0rMZoI5BVAFog5eZq8/25PYf8w3t2Op5KtqjQyKnV X-Received: by 2002:a62:f250:0:b0:560:8405:a052 with SMTP id y16-20020a62f250000000b005608405a052mr15014260pfl.1.1668444793108; Mon, 14 Nov 2022 08:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668444793; cv=none; d=google.com; s=arc-20160816; b=YTHgzUBN74KNEDiEtPwXW4bOH9ve4E9uGW+5qwfhwo70GgQ4dsMfzfEwdXEJ9T1XlQ Y8kzE1t02VUQcsPIcBsUx6i2FdGK7Ow5LE2ys2xeVDPFyscu5klzrRKu9qHiZXG9Axj5 chaIbYNm5Y5CJVMxnnLB5BrjQvi8Q1D4q8Lz5f4Z9Jaf5/9/4e4xnAMeiywzv+sHUrj1 LSDBN8PuixRN/MIYGkeGIKXEPYXeiFFiJyBHeAXsWqnpxk8bZjAPrFaPSw9uwrslfmIG vKJJ6UX0pf+9YnDQA5cXOR9iRg7TaYj5jUCGdSQ2RHy4yQq4vUYva4khkDPs/1Kgnv3S rkNw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x4-20020a1709029a4400b001768452d4d0si9245656plv.30.2022.11.14.08.53.01; Mon, 14 Nov 2022 08:53:13 -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 + 87 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 ); 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 ; Mon, 14 Nov 2022 08:29:42 -0800 (PST) From: John Ogness 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 Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , 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: X-Mailing-List: linux-kernel@vger.kernel.org All users of console_is_usable() are SRCU iterators. Use the appropriate wrapper function to locklessly read the flags. Signed-off-by: John Ogness --- kernel/printk/printk.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; -- 2.30.2