Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp349748rwb; Wed, 16 Nov 2022 01:18:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf40i0i/b/vSiGa2X0Fr8WNNexyV4a0Uik9Fy8qYbaENKeMIFJ45lQVldldRZqYqiSlyHSCj X-Received: by 2002:aa7:c517:0:b0:461:a89:8654 with SMTP id o23-20020aa7c517000000b004610a898654mr18631388edq.212.1668590285389; Wed, 16 Nov 2022 01:18:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668590285; cv=none; d=google.com; s=arc-20160816; b=daMlIFyY3Vi4ZGrglWiTMXQklSsMe/zIzGfyJxTSTvTWx3/HIsb81/BCubLFl+W0An VtT7n9006X37MBsNiy1M1us8yaxUn2qOj5tmqUOMhwpj8+DuawtMgwdApX1ejQOlUESx xcJXSLafIyVMTj3tKR3XyYMimcg1taYrJhskwbLqbAVIuCp45LU1QUeT/b/lGqRZSXSM 49MnE2fzGGnZYkDISk6hwgpqhal2K+CWqzveEwln+rOlJNwCOdOmjpCMtC8ZfxTF25m5 5CKS/n4QojQ11cPsJHP72ygB1Au01GqcZcy4RqmSsCgj1PfuefnipFkZWZyWZn9SRGfp vF/w== 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=/MF/qmh79dQpFUCUsIj7y+bcIBscvDkSCatXQ4UiYkk=; b=TCpaAOIXDWxnivC7av5gfZOhhDG8ATHz2rOmG+ds+IamitVg8aoVQTr5dfqE/op0th LWc14gcOcaxs1guEeb1WU1vGZyhZbtyGwqit1xYzSNS4A/c/j+5+j1eOOtfJJADjiikq g9NNMfecDCDOvK3coSS7VZA3U2kpYLp2Vfc/svL03H57cdpwzgxDjZMs4+0d028UpXuT 52HGCngzOkW+REDXk3gLbdoAjhzj0z3TSUuMnUIvVU2enxumMYYAISvpnojfFqH0p889 Tt48KVQdy/otUmzRznKkSCwb6aK7X0lLMUjTrJ1AL/nC3o18YT1k0R+hinzvBc3WaxPA 3VIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=FuNe1SOl; 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 qa6-20020a170907868600b007a45e4f4ff0si15096164ejc.885.2022.11.16.01.17.43; Wed, 16 Nov 2022 01:18:05 -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=FuNe1SOl; 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 S231890AbiKPIwf (ORCPT + 91 others); Wed, 16 Nov 2022 03:52:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbiKPIwd (ORCPT ); Wed, 16 Nov 2022 03:52:33 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06765A1B9 for ; Wed, 16 Nov 2022 00:52:32 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668588751; 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=/MF/qmh79dQpFUCUsIj7y+bcIBscvDkSCatXQ4UiYkk=; b=FuNe1SOlnuxHLgkLS01nsuq08lF3yPSsP+sAtQnSlzZ8zJBAG1TKtj+19wzVb2t1JOnCoY wMR/mwvH8fQV8HDIGrXWwd8YhbeE8jccDn1NWTvhZtHHMq5RDFzb0boRBQbLz7Tis2rGH8 7M0wzWbE5L/Ws6zWbKOKfA/GDyjmBTlQ182A3fC7+qSlD1MKhlGyOmPNTr53JSs54GtHu1 gdXF61sNFvfVW7hsp27YUqeLNkoa575ypFAyxwiRP3s5pN02vsJdzVIn4Z/KLyeysdlr/I 1CRv2LFrnpuUVI9MNY396kSKRX1tNlqaaz+QMhKc2j2LFOXxR6xGIT2cscTtrQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668588751; 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=/MF/qmh79dQpFUCUsIj7y+bcIBscvDkSCatXQ4UiYkk=; b=qcByEwFWhDvWOJGLDcNH3g7wMRxdiE6WfNdISFXrlBJA7o6WuJUGWdrlCjUgFEcAWM3LPS 3Fnyo2hlK12oRZAw== 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: References: <20221114162932.141883-1-john.ogness@linutronix.de> <20221114162932.141883-39-john.ogness@linutronix.de> <87tu30maqf.fsf@jogness.linutronix.de> Date: Wed, 16 Nov 2022 09:58:28 +0106 Message-ID: <87y1sbjn77.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 On 2022-11-15, Petr Mladek wrote: > It is not that easy because console_flush_all() might handover the > console_lock(). Also some new messages might appear so that we > should re-read prb_next_seq(). OK. Taking all this into account, how about: 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. */ 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