Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp560619qtb; Wed, 19 Oct 2022 08:57:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM53+BNUgU4T5Yiv/F04Q1KomA1JuUq7j5fHWQ2lOxxCbmfe3eEZb+eMp7xB9DPlyYPViuDN X-Received: by 2002:a17:902:e5c3:b0:185:5100:26f3 with SMTP id u3-20020a170902e5c300b00185510026f3mr9363360plf.73.1666195037144; Wed, 19 Oct 2022 08:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666195037; cv=none; d=google.com; s=arc-20160816; b=sbPujC28SneOlh2pQIzFCl2KUS7f8U5MVMDvSOcCxVIaIwzYdm2xIyyH1M05m8vu1V kIlUe+8dWp/d3P7LUYaWwY2tQGCslUN2lbaYACdzmky8zTjXiUlGk/bmcAqegW60++pK GzJdRicI4JHLZNktoV+AKVj8Vl+QCOHtYcX0Q/1i0Ryc/oD2231YEupI1GTE0DmhRmF0 Rp173RRjDNwfXfMlLvrmfC+0PxFQI9YkLGf2Nv/mZTZk7+zqtak29Gg3jvgkWgFyt7Zh sU6YNl0xJG3ZxjoRqwA6Y1BWK8ZQ7AQRHaevQsuZUwN5GD3OYj9OTlNuk6+2O0VSFsvF DJeQ== 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=kDZ6pRjPX3M/aNWQNadxCVy2Ern3rX+BUG+UFbJRacE=; b=IblqMgAHge4oNGFouCeyG5+rIv/XWIio7AfxcMZprD41/FXLRhSyrf90Brqwya58Gf Iqy4v3+P1vVHNVDkOGriCf46O8dwBYfbKonS+Lm0cx9dyt/7nLspwKFpSWkghZg/WVxC mJgJDwJv7a2j4vqPNeV2OGdgxfyAYE+fw7mqesvBzMwB8EBCTHBZJ7lyGrs4b3M1XHlU HrWGBTQ1e4PlfEuA5AUe649F3jWVpT3v6rR+Aq6wxt3RpbmyfdCwMMB+v0+VhvzryIqY wegQRKkjEX7+/LcPsa9eVBdj+DJBLpu8ezhE5gBHBcDsn0VKX7UMGJUwqFKaPYHhlz9f lakQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vZ++W4VE; dkim=neutral (no key) header.i=@linutronix.de; 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 ds13-20020a056a004acd00b00561fb25a42asi17024391pfb.303.2022.10.19.08.57.01; Wed, 19 Oct 2022 08:57:17 -0700 (PDT) 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=vZ++W4VE; dkim=neutral (no key) header.i=@linutronix.de; 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 S232000AbiJSPGM (ORCPT + 99 others); Wed, 19 Oct 2022 11:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbiJSPF0 (ORCPT ); Wed, 19 Oct 2022 11:05:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98472153835 for ; Wed, 19 Oct 2022 07:59:11 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191378; 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=kDZ6pRjPX3M/aNWQNadxCVy2Ern3rX+BUG+UFbJRacE=; b=vZ++W4VE4AQQNPASVoIgQEv9QFic6MvrPxW9APkzUtJQWlJmpTRafFJlXDcuEug7iTrgAr Q68gq3cOHoYxad58FRzrhkyde3adxE+hwep+0uWLN2/qDedGH7Q7xx1AmRkMh/mK0VoNFv nMsU91BskHVFEannoZwBQZA7Z1nTnh3feCTKpKo/0ocU/OTDbu3KpsM2BSapW5B13XOBk4 XEBAiQvwiu+9W09sKCUpa/szF8Xe08dS43bdhg5WwWcE38dtMvjprltTZX5kT84uDgwvUo ks5/LYqdhSVgBppHnyQB/LpicRRiUXa15t6U5CopyRfzugDG8cvli1d2t8CL9Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191378; 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=kDZ6pRjPX3M/aNWQNadxCVy2Ern3rX+BUG+UFbJRacE=; b=zlEFWao8VJz19cq1+qrdLmGFpWXLPFk4nyCnR24oE/kjsnhlT2viimgpJo1H5sm4DIHUYs PFn0fdw64FnnTOBQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 30/38] printk: console_device: use srcu console list iterator Date: Wed, 19 Oct 2022 17:01:52 +0206 Message-Id: <20221019145600.1282823-31-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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 Use srcu console list iteration for console list traversal. Document why the console_lock is still necessary. Signed-off-by: John Ogness --- kernel/printk/printk.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index e478cb92e7ba..410ad9d5649c 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3025,15 +3025,24 @@ struct tty_driver *console_device(int *index) { struct console *c; struct tty_driver *driver = NULL; + int cookie; + /* + * Stop console printing because the device() callback may + * assume the console is not within its write() callback. + */ console_lock(); - for_each_console(c) { + + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { if (!c->device) continue; driver = c->device(c, index); if (driver) break; } + console_srcu_read_unlock(cookie); + console_unlock(); return driver; } -- 2.30.2