From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02F87C77B6C for ; Thu, 13 Apr 2023 09:04:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbjDMJEh (ORCPT ); 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> 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