From patchwork Wed Nov 16 16:21:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 21148 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp233094wru; Wed, 16 Nov 2022 08:25:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf70VdsHy0YBdpEnPgwaNxUMvy7ebqoivOEm5K4In9IsyfA0pUHeFC5zLiumEG9Ko8zvkj6g X-Received: by 2002:a17:902:e782:b0:17f:52af:d035 with SMTP id cp2-20020a170902e78200b0017f52afd035mr9993789plb.106.1668615906153; Wed, 16 Nov 2022 08:25:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668615906; cv=none; d=google.com; s=arc-20160816; b=vJuXsDhckwEbaO6G0rW1tVEVlg0BQaaoquYjsjuhQA6AIiPFrqtHt3RmSwbT8KjdeN g7Skqqk6W9QTHMcrduMPrGhIwNvIfCt02LlA5mZWXENBYoLncD/vyQ8j9OHz4bNvOJmC Y0CYpsQ/03LhwmddLSEOQtGWScGA4LswbyXQ0yRQwJ6A8q3m468E73Kptmlxkm+Ktcyt 7KytAf5yDxbtkTAG6pgITnl63JNgvWHybay2nobX3Pqr//bXVPGf/AuntOHELiYe3mYS PDWOfjYospP+2eyVTjRsMv3sUTB1Xhur0oWmQK+kiYgD2vQwxSKiQ7+nM8M4dkIDaugm s6Tw== 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=nhhJ4NEYDrYYk962PRI1KO7CTDJYZ90BsmoX/yxQ/gI=; b=fSOqDaGQn2ee0x0uX7+7OVZaEYK3cjejxnYqy3EXSgYz44APY+OcCHlBOfY+UW+VC8 jFQoE0omU9p8T4sfhC+9FgPE+8uAM/A5COi/35OLR1RL4K1NyQ34j73GXSXkd7KjYDxb 0pqNmh5HQZ4epQLaKzepzBOtahKQ41mT/XxooxlNM7pVPhB+N6VsPzBnPQCsb965f9pL DB4yoNmCDOiOjew0zR8zojRGlL5C7K0+G66TvFYYxKo0V8FjR4PO3iKrEor2QBr1O2iu 1mU8e5esbCTDykuF6w/nzIM1By2g+ZvUUUk6wnO747VtZH8AQjq1z4D3BnSdKlp4qca1 lvpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lRDydq5F; 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 18-20020a631052000000b00473d2c2c082si15765797pgq.361.2022.11.16.08.24.52; Wed, 16 Nov 2022 08:25:06 -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=lRDydq5F; 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 S238657AbiKPQXl (ORCPT + 99 others); Wed, 16 Nov 2022 11:23:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234426AbiKPQWI (ORCPT ); Wed, 16 Nov 2022 11:22:08 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDC2747311 for ; Wed, 16 Nov 2022 08:22:06 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668615725; 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=nhhJ4NEYDrYYk962PRI1KO7CTDJYZ90BsmoX/yxQ/gI=; b=lRDydq5FRZTnwLjVZHwb0EFCh4BnmAql/o3iD/Qhwm+z4zzC7IEwqkBDf2PopO8HzRgRB9 rYWm/6nGUKDvhLD52VVku54Wzv3n+RpLJ1VYDeXtDYnm81qg/kqn67NNDxXntUC4ZqHj5T 76kg6Qu3zH/jNH7WI5zmxvWp96rFCt2IpIJ+lqpcQXLaI32egKpudioKS2bXTKJOOFx/kM l5yZrET/CWXg6D0NcF1jzBUJuVzPtFCyqGSgcctEYxK5uPOnTXkovYxcy0G++vcVykd5DO sYa/WzWP4KKm77GyhziPCSDqiwU5LZi+ZHnuBvk8ZXMJoicHCDGCmFB3idMIEw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615725; 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=nhhJ4NEYDrYYk962PRI1KO7CTDJYZ90BsmoX/yxQ/gI=; b=bY0sIjstLLp8P/5/imQZ/AMuPiIf5JzcDLwL9jC+9b1Sxa18frPcCl9+jZamwRBFbekt5C rWE6Za9htWGPuTAw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v5 17/40] printk: console_is_usable: use console_srcu_read_flags Date: Wed, 16 Nov 2022 17:27:29 +0106 Message-Id: <20221116162152.193147-18-john.ogness@linutronix.de> In-Reply-To: <20221116162152.193147-1-john.ogness@linutronix.de> References: <20221116162152.193147-1-john.ogness@linutronix.de> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749670592436167529?= X-GMAIL-MSGID: =?utf-8?q?1749670592436167529?= All users of console_is_usable() are SRCU iterators. Use the appropriate wrapper function to locklessly read the flags. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- 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 6666cc27a014..75951c4bda05 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;