Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp849467rwb; Wed, 16 Nov 2022 08:25:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf6stXUnxpzvoS4P/1EyygWizt/QV15ncQFMyzoS8+CbhsoUbUNbfdG78cyUhv2wjSBUSb59 X-Received: by 2002:a17:906:7143:b0:78c:f5a1:86bf with SMTP id z3-20020a170906714300b0078cf5a186bfmr17945039ejj.245.1668615937379; Wed, 16 Nov 2022 08:25:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668615937; cv=none; d=google.com; s=arc-20160816; b=w4t4XzmEGf1KSt6L/FbD5/09DgkpyCMcsL5iWcnkIMLNuii3BGUc5KWEx7Iap45IAd wcOxwPo7uocPPZ8DEVFShEAsYjawIYzOrv6h+wmvMYGCv85rSFSzNIEVNGhwAdbut1qW BS4q/Z7z3924OErrNI2PU4b+Nl5LLdxn32GLhVzrnr58Ao281MOeQQN/ufVrUai6faR5 kGG7XUMLSLOHpGDrv5hpI2GdsW5KeylRJICpPJjUgQsSRAhxS+hfDd/838dLg/LNVhcs vfnpkekvJSNZhdmdQrYqCRq5yAICKmB4bfVW9dAZ7p6dwIUJ6ZsWn+kO9tZssJpEqZWc r/RQ== 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=GEhKO0dJc2f16pdA5isP3tyKiWxAMb8gJwHLg9bJtvU=; b=s+bMFaF6nYlNeeIrZzoYLmAvntKR53XJAGs80b5Q+3WUD2gAW2bPl5Z9tcVkSn/Xc7 2Rn7a09UGxMihdS1VgB8s5Dr6w2UUtbXis3sc2t6I3FJXWw94fDqao0ci6LLIqRl+z1V xxHlwR6iYz6Mto8Eexa/vu/n1GciwS+qdIq0ShOAhr/ZqKkrCnNUNBE+8w9b51tMSE0I 2Q5r8YJWyGY0JGHUavKP3Gi9yWV9J6PIYhUzOwLFW3KsRocBoVrDWPOvezuIwFyqtkp1 vnJayt/ftQYktqg6ZKWy9DiX5AjEgBIJTA5W9a+UGhA0zMmT6AWUx2plX3w459V32ajp dqAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oIuBdriz; 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 o22-20020a509b16000000b00462e23be64fsi13010272edi.578.2022.11.16.08.25.12; Wed, 16 Nov 2022 08:25:37 -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=oIuBdriz; 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 S238258AbiKPQXH (ORCPT + 92 others); Wed, 16 Nov 2022 11:23:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234314AbiKPQWH (ORCPT ); Wed, 16 Nov 2022 11:22:07 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25EF849B6B for ; Wed, 16 Nov 2022 08:22:05 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668615723; 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=GEhKO0dJc2f16pdA5isP3tyKiWxAMb8gJwHLg9bJtvU=; b=oIuBdriz4JcEynWjZAm586o5EvapOAFjcQM7Y2h/jaFjTqDiY6uPhp8aLR8nBjL3sNQ3Dd wHZzRlW7PVlMFZSrjuZBAdlaxGYKCPXOLT+eJt0Bx/Bf77XSVU/Sdj0fUXPID4f2JKMYWO xth7HR45tX4LCgAiYQR9UtjW3xY/OwKJbQ+MTsyvDkIBwVQsRDJgcmxvXQmLUsb4ji4IMo 1l0xna2GGygbTY1KnRexudbFu2wA9TeXsj853JqPUmudt8ywLyxwW5Iiqh0Ree6FU5BaTz iM41PTKy8qkj5y2nB37PhrfFjKOUabUIaaJMqZLYTWFwtJKpjb3tdQms5EUKig== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615723; 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=GEhKO0dJc2f16pdA5isP3tyKiWxAMb8gJwHLg9bJtvU=; b=OZ7EGuhsAVFVp8NSWYxYiCIDMCwa1My5MhuROv6LAzBXyKI2zB/l2XJjq2B5TvLEf2EdaF XZjkrE4iliwyN5CQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org Subject: [PATCH printk v5 13/40] um: kmsg_dumper: use srcu console list iterator Date: Wed, 16 Nov 2022 17:27:25 +0106 Message-Id: <20221116162152.193147-14-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 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 Rather than using the console_lock to guarantee safe console list traversal, use srcu console list iteration. Signed-off-by: John Ogness Reviewed-by: Petr Mladek --- arch/um/kernel/kmsg_dump.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/um/kernel/kmsg_dump.c b/arch/um/kernel/kmsg_dump.c index 40abf1e9ccb1..427dd5a61a38 100644 --- a/arch/um/kernel/kmsg_dump.c +++ b/arch/um/kernel/kmsg_dump.c @@ -16,29 +16,26 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper, struct console *con; unsigned long flags; size_t len = 0; + int cookie; /* * If no consoles are available to output crash information, dump * the kmsg buffer to stdout. */ - if (!console_trylock()) - return; - - for_each_console(con) { + cookie = console_srcu_read_lock(); + for_each_console_srcu(con) { /* * The ttynull console and disabled consoles are ignored * since they cannot output. All other consoles are * expected to output the crash information. */ if (strcmp(con->name, "ttynull") != 0 && - (con->flags & CON_ENABLED)) { + (console_srcu_read_flags(con) & CON_ENABLED)) { break; } } - - console_unlock(); - + console_srcu_read_unlock(cookie); if (con) return; -- 2.30.2