Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp394272rwb; Wed, 16 Nov 2022 02:08:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf6OIQSQZgxtYKLYXjuSlkRdsMw3aBn10bRRWSUM5vjgm87pvfbwGWFtgcn31v2M9aIJbQAm X-Received: by 2002:a17:902:bc41:b0:186:ce8c:e654 with SMTP id t1-20020a170902bc4100b00186ce8ce654mr8259953plz.89.1668593287474; Wed, 16 Nov 2022 02:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668593287; cv=none; d=google.com; s=arc-20160816; b=jjideUUqASRjWGNI8i2/czG/TASOIgiA/+JUvP8gIQkGgbfN0SQ/kA13WmuNzK/I4E FTi+xw82J8W0845410RG7MtuuZMuHMn07qMXWWO8FCQBz89yyB5Dw21oo+AUsth0tKkS BWJx2GFAJMHUcF9Qk5ltW/ILPimSbYQT7y00mS6D5IH4KzuLNHbxFAn5SBqGv1XeI6qN mjp9ZDlipNkpc9GkicQwHnTb+bkTRSVRwzgfftY3miiXq0m/b9lJli6XBeWFgFkfum0U L/fheWPyvz9jm1S8JptGnWWtJ6WGedF3VnoGNFNRBa6HTiPQlkuFnTenemskBE6fqJly humQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=0CGWwYZrTrOzwGHnTvqXKCFp/Dj3jrSRjmzNVayxzmw=; b=QPtqNosktLmOxFBjan6sCuc6fOcxH+MdfauZhld25omeHVUcMY7PxK2fzI+q8nqZvw +H7hzZowWnBKwQmMQr4QsV2DzvHDDHcX276iwTgIFH/ElwDG18iijtdvUnZZ9IRI+mBU XXyQZfHUeJYTfELvY/k16Un1BKMVUsQ3W6lu81C9mj5Q8p+8Fq7zDfKvfjBdAfURCmmr 8ZbAhdYTY/5Tum8Yj1iRH8VT2Mb1jYrs/DtFQ9l9IywICxmRrlaQBSeru6y2SIGFkwwG 2lwznCxERbms+1J38InGeV1Il7HwHu3gVdNsyGPxwNLxA6pPwTW6vYV3Few/qTIw3XyH yz0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kNIzzDy9; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="ub2g/GEY"; 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 a21-20020a63e855000000b0046f9443ad6asi15283732pgk.377.2022.11.16.02.07.54; Wed, 16 Nov 2022 02:08:07 -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=kNIzzDy9; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="ub2g/GEY"; 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 S238617AbiKPJJi (ORCPT + 91 others); Wed, 16 Nov 2022 04:09:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238792AbiKPJJS (ORCPT ); Wed, 16 Nov 2022 04:09:18 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51E07233B8 for ; Wed, 16 Nov 2022 01:08:39 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668589717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0CGWwYZrTrOzwGHnTvqXKCFp/Dj3jrSRjmzNVayxzmw=; b=kNIzzDy9jcb1oibTWn5I2FK59aR4j35tmXJ6OFhYezb1ZGavcMjg5c9o6lYxADsnRagKHw IM7/v67lVDyOQ2HCtjXFJO5JQPvUeqTSIXLCq1hgpH8dGOW44EnFkHOFewEICWtj60VaoF bvVsntVA5p9MsuGfdZUbEabUvCxRSNBipvdNE6CQl51Q5XayKh6NJc8yU32oYrlJkMdq7T sGlMu42SPO5y9dZRA1Ji2ovPFIDvLfbQCxspD2RvAMc62SMo1aenP7Kzit8Tz0YOBVaAbP VVh34zMTd90QWp3TQJm4ejku6ipqNzpKbbZUvtFM5RprrzFaoDpmo3Ny7j1eeQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668589717; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0CGWwYZrTrOzwGHnTvqXKCFp/Dj3jrSRjmzNVayxzmw=; b=ub2g/GEYV7gRim+IeFw+0P2xRSDXNIW/CGofJ54VJCnHwHkV6Tr0p+zo8ihQibnp2ag4li CqCqcaE9rcn8pkAQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: replay log: Re: [PATCH printk v4 38/39] printk: relieve console_lock of list synchronization duties In-Reply-To: <87v8nfjn0d.fsf@jogness.linutronix.de> References: <20221114162932.141883-1-john.ogness@linutronix.de> <20221114162932.141883-39-john.ogness@linutronix.de> <87tu30maqf.fsf@jogness.linutronix.de> <87y1sbjn77.fsf@jogness.linutronix.de> <87v8nfjn0d.fsf@jogness.linutronix.de> Date: Wed, 16 Nov 2022 10:14:35 +0106 Message-ID: <87sfijjmgc.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain 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 Hi Petr, Sorry, console_flush_all() only loses the console_lock if there was a handover. Here is a new complete suggestion from me. if (newcon->flags & (CON_PRINTBUFFER | CON_BOOT)) { /* Get a consistent copy of @syslog_seq. */ mutex_lock(&syslog_lock); newcon->seq = syslog_seq; mutex_unlock(&syslog_lock); } else { /* Begin with next message added to ringbuffer. */ newcon->seq = prb_next_seq(prb); /* * If any enabled boot consoles are due to be unregistered * shortly, some may not be caught up and may be the same * device as @newcon. Since it is not known which boot console * is the same device, flush all consoles and, if necessary, * start with the message of the enabled boot console that is * the furthest behind. */ if (bootcon_registered && !keep_bootcon) { bool handover; /* * Hold the console_lock to guarantee safe access to * console->seq. */ console_lock(); /* * Flush all consoles and set the console to start at * the next unprinted sequence number. */ if (!console_flush_all(true, &newcon->seq, &handover)) { /* * Flushing failed. Just choose the lowest * sequence of the enabled boot consoles. */ /* * If there was a handover, this context no * longer holds the console_lock. */ if (handover) console_lock(); newcon->seq = prb_next_seq(prb); for_each_console(con) { if ((con->flags & CON_BOOT) && (con->flags & CON_ENABLED) && con->seq < newcon->seq) { newcon->seq = con->seq; } } } console_unlock(); } John Ogness