Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2141721rwl; Thu, 13 Apr 2023 02:08:33 -0700 (PDT) X-Google-Smtp-Source: AKy350aMtHY2QhkHGjNVuabGcdyjl9yskK+3/jMFD2uAtkEUG792LriOCUmeF6bc9/UTQESp0vOJ X-Received: by 2002:a05:6a00:1992:b0:638:d85c:5f25 with SMTP id d18-20020a056a00199200b00638d85c5f25mr3131861pfl.17.1681376913139; Thu, 13 Apr 2023 02:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681376913; cv=none; d=google.com; s=arc-20160816; b=0qhn1XuxptL94OS6fdZIxQ0e+bsKMmJxToxpljjf0KrQASG6GL+MYpmc4fvHSppWVb mAkI6o7VhJO+nwjnBz0fHW6ldJrP/H9VzD++vQnVaFfyAPzruIBfeOR9Rhy/9++YG+iF zmR637kS2LGlKo0IdT84uCzsl9Srieg//HsWiT3i+Uu9lLGJbGIgEBYuUykwkDRJJf7L 7cugE7iwKu6liLfCBaRQVUHeg2+6uxpoA6lrU0HaItREvtanJAz2nyQQhc/wQALXjKWT p0MjajEYdMJ7wskBLhWbsn/+LfS3oaEmAc8WNA4UaZ6s7dAvmZWkgmcyrpECH4seEFOt 2s7w== 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=KV4d3BUt4ERuBIA1e4+EsOIH3BKf/5YsgbB/jlNy8ew=; b=NXWY42QX9xy0+Taz2d1uJMcDgb3WM/artC/QzRw9nxoJibXdbZuGxK4zlGtaEtOQU0 sYQtANrxYw5p8dqv/qebFeaBvwCrszJmIkEIT3rv+zAo4r7PJo6LCFQITFI5eJUCHefk 2KVJLy9e9TphqyWzaqDUoMPR3HoNCnK7ID7J3S4eYGTOUPUCn9fnmPXg/7qUOzPl611Z utuCmMi/0EAeK6YuFcXLXCIzMvmTqCkbPIecyniyG56H8+FA/eBLf+USl25G7CXFZXIs yvo5NqUsCt/7o5gRad1t6mFtA7GEo2UP7GLuJwl+aWv6rLMtp+66Eh4syDTC+HMUccmw Q6pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=nOivJRhI; 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 d13-20020a65588d000000b00518706a93f1si1556758pgu.361.2023.04.13.02.08.22; Thu, 13 Apr 2023 02:08:33 -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=nOivJRhI; 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 S229920AbjDMJEh (ORCPT + 99 others); Thu, 13 Apr 2023 05:04:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229951AbjDMJEO (ORCPT ); Thu, 13 Apr 2023 05:04:14 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4217D9029 for ; Thu, 13 Apr 2023 02:03:41 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D718E218D6; Thu, 13 Apr 2023 09:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1681376619; 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=KV4d3BUt4ERuBIA1e4+EsOIH3BKf/5YsgbB/jlNy8ew=; b=nOivJRhIStBIT0lS3VzI5Q/5ohaFxhYLxlQiuXzlzZLNP2ywGXX5iWbgwl1gjmPlK0WsQD a+gtFeT1g8CqfQDKVinJWRAq74THut0cMlqcYBH4SJaceoxKX4Nd+YNQiEQl/hwyUZQoe8 ul1PEgl/Kk14QsD4DwjSFZ9mm43bpfM= 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 7B8D92C143; Thu, 13 Apr 2023 09:03:39 +0000 (UTC) Date: Thu, 13 Apr 2023 11:03:33 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk v1 15/18] printk: nobkl: Stop threads on shutdown/reboot Message-ID: References: <20230302195618.156940-1-john.ogness@linutronix.de> <20230302195618.156940-16-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230302195618.156940-16-john.ogness@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,URIBL_BLOCKED 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 Thu 2023-03-02 21:02:15, John Ogness wrote: > Register a syscore_ops shutdown function to stop all threaded > printers on shutdown/reboot. This allows printk to transition back > to atomic printing in order to provide a robust mechanism for > outputting the final messages. > > --- a/kernel/printk/printk_nobkl.c > +++ b/kernel/printk/printk_nobkl.c > @@ -1763,3 +1764,33 @@ void cons_nobkl_cleanup(struct console *con) > cons_state_set(con, CON_STATE_REQ, &state); > cons_free_percpu_data(con); > } > + > +/** > + * printk_kthread_shutdown - shutdown all threaded printers > + * > + * On system shutdown all threaded printers are stopped. This allows printk > + * to transition back to atomic printing, thus providing a robust mechanism > + * for the final shutdown/reboot messages to be output. > + */ > +static void printk_kthread_shutdown(void) > +{ > + struct console *con; > + > + console_list_lock(); > + for_each_console(con) { > + if (con->flags & CON_NO_BKL) > + cons_kthread_stop(con); > + } > + console_list_unlock(); It would make sense to explicitly flush the consoles after stopping the kthreads. There might be pending messages... > +} > + > +static struct syscore_ops printk_syscore_ops = { > + .shutdown = printk_kthread_shutdown, > +}; > + > +static int __init printk_init_ops(void) > +{ > + register_syscore_ops(&printk_syscore_ops); > + return 0; > +} > +device_initcall(printk_init_ops); Otherwise it looks good. Best Regards, Petr