Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp878167rwi; Mon, 31 Oct 2022 08:35:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5scSjxN9/222pc6yAyLgWLfP1O0sw8sMpLqQRXytCGdFcv4B8gtdVmyDVFvQksalE6Eww2 X-Received: by 2002:a17:907:6e23:b0:7ad:b962:33ee with SMTP id sd35-20020a1709076e2300b007adb96233eemr11080046ejc.28.1667230500636; Mon, 31 Oct 2022 08:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667230500; cv=none; d=google.com; s=arc-20160816; b=fEpLE2lE8mVczmdtZFA1JaQ8u44QJx6p8PtNVAnl7246TsHL/E+Y6IAmjcfWg7WARR AKO2c3jJr3Gv4lxA5l7Z8wBvvtwakhb5f/GeGQ4dtsfXuzq2Ng1AwYLKtsdgMzNioRS9 MHIfapX3CelZeQs1YzS24qISyTLos8cVQYMwXFRS7M9eQz9mAfl090J7EyHyLD2D0lQc UAKs+f8uzlgEEhFr7mH+KShNtORXjj7KKCheR0gdkbYNrBZ9pCGVF0uiaj7X0lTdUMIt 0I0SROKZ7qbX/3N9OhHbAcQyGE7hT/NBugRJvB5yWSXS3nws9RlW1gVIrGZ4UvD8TGUx TeYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MOQBcJHrH5TTnJTZ9kKFPMfWJn6TwnLyDmMgvxVGxwg=; b=cCe32gyb3bPej1/WJMnaXX+14hs4XUjtdFYmrbLS3Gz3hLMSlGe9/93LwYd83w3Ra9 0K/NBFJsVbBXRn/axJWGVqlfgXHpfBOtwjGvdtNjLd0vrS+bXMKKdaw5yOpdrtB9kIVd ZoMIJrYxcY7Qh2chu4BAivu1URxBrZ8RPqvH7q8RnkECFX9AvJCdJJjUCLujobR/7BJj QX0tCAzs2SISBhJLVqSkBgKeELreVAckPCGhXdB1zWDbkSZzM9VOQZ5vEyUlQ1mc7L2b N8JdZibtJ3wskBlsfq64g9gKS3I8fBnQrL6zUKE4CXvawGVWED49KqzIaS9WRi/GRx+X Si6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=l8S0H1Bi; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo22-20020a170906d05600b0078c3197bf86si7454032ejb.533.2022.10.31.08.34.36; Mon, 31 Oct 2022 08:35:00 -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=@suse.com header.s=susede1 header.b=l8S0H1Bi; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231499AbiJaOJV (ORCPT + 98 others); Mon, 31 Oct 2022 10:09:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231455AbiJaOJS (ORCPT ); Mon, 31 Oct 2022 10:09:18 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72E3010B48 for ; Mon, 31 Oct 2022 07:09:17 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 24625338B7; Mon, 31 Oct 2022 14:09:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1667225356; h=from:from:reply-to: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=MOQBcJHrH5TTnJTZ9kKFPMfWJn6TwnLyDmMgvxVGxwg=; b=l8S0H1BijW3zAOwbmv8qVvGzFSrIDP5N8AnYoEG/v03mJPOfWsxl5hafA8kktX/59vjX7I LQzzcZLCJIljG1bsRAi27lH1BEFf6liJlyi6Ov69B4xUw7TCxeQIDd9B+lYCsnsC0gfA/r +ZeT6TQHbeV8R5RGPG05qkvduMsXtqU= Received: from suse.cz (unknown [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id DAC362C141; Mon, 31 Oct 2022 14:09:15 +0000 (UTC) Date: Mon, 31 Oct 2022 15:09:12 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Miguel Ojeda , "Paul E. McKenney" , Greg Kroah-Hartman Subject: Re: [PATCH printk v2 03/38] printk: Prepare for SRCU console list protection Message-ID: References: <20221019145600.1282823-1-john.ogness@linutronix.de> <20221019145600.1282823-4-john.ogness@linutronix.de> <87leow9m77.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87leow9m77.fsf@jogness.linutronix.de> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Mon 2022-10-31 14:12:36, John Ogness wrote: > On 2022-10-21, Petr Mladek wrote: > >> @@ -3179,6 +3214,17 @@ void register_console(struct console *newcon) > >> newcon->flags &= ~CON_PRINTBUFFER; > >> } > >> > >> + newcon->dropped = 0; > >> + if (newcon->flags & CON_PRINTBUFFER) { > >> + /* Get a consistent copy of @syslog_seq. */ > >> + mutex_lock(&syslog_lock); > >> + newcon->seq = syslog_seq; > >> + mutex_unlock(&syslog_lock); > >> + } else { > >> + /* Begin with next message. */ > >> + newcon->seq = prb_next_seq(prb); > > > > Hmm, prb_next_seq() is the next-to-be written message. It does not > > guarantee that all the existing messages already reached the boot > > console. > > > > Ideally, we should set it to con->seq from the related boot > > consoles. But we do not know which one it is. > > Yes. It is really sad that we do not know this. We need to fix this boot > console handover at some point in the future. > > > A good enough solution would be to set it to the minimal con->seq > > of all registered boot consoles. They would most likely be on > > the same sequence number. Anyway, con->seq has to be read under > > console_lock() at least at this stage of the patchset. > > Well, for v3 I would do the following: > > - explicitly have boot consoles also behave like CON_PRINTBUFFER > > - use the oldest boot+enabled message > > The code would include the additional changes: > > - if (newcon->flags & CON_PRINTBUFFER) { > + 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. */ > + /* Begin with next message added to the ringbuffer. */ > newcon->seq = prb_next_seq(prb); > + > + /* > + * If an enabled boot console is not caught up, start with > + * that message instead. That boot console will be > + * unregistered shortly and may be the same device. > + */ > + for_each_console(con) { > + if ((con->flags & (CON_BOOT | CON_ENABLED)) == (CON_BOOT | CON_ENABLED) && > + con->seq < newcon->seq) { > + newcon->seq = con->seq; > + } > + } > } Makes sense. Just please do it in a separate patch. It might potentially change the behavior. And the problem have been there since the global "console_seq" was moved to struct console_seq. > >> + hlist_add_behind_rcu(&newcon->node, console_list.first); > >> } > >> console_unlock(); > >> + All the other proposed changes look good. Best Regards, Petr