From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751998AbcDWIZH (ORCPT ); Sat, 23 Apr 2016 04:25:07 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:34362 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751742AbcDWIZE (ORCPT ); Sat, 23 Apr 2016 04:25:04 -0400 Date: Sat, 23 Apr 2016 17:26:34 +0900 From: Sergey Senozhatsky To: Jan Kara Cc: Sergey Senozhatsky , Andrew Morton , Jan Kara , Petr Mladek , Tejun Heo , Tetsuo Handa , linux-kernel@vger.kernel.org, Byungchul Park , Sergey Senozhatsky Subject: Re: [PATCH v12 3/3] printk: make printk.synchronous param rw Message-ID: <20160423082634.GA531@swordfish> References: <1461333180-2897-1-git-send-email-sergey.senozhatsky@gmail.com> <1461333180-2897-4-git-send-email-sergey.senozhatsky@gmail.com> <20160423065633.GA6771@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160423065633.GA6771@quack2.suse.cz> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On (04/23/16 08:56), Jan Kara wrote: > > > > Signed-off-by: Sergey Senozhatsky > > The patch looks good to me. One suggestion below: > > > @@ -1785,7 +1782,7 @@ asmlinkage int vprintk_emit(int facility, int level, > > * operate in sync mode once panic() occurred. > > */ > > if (console_loglevel != CONSOLE_LOGLEVEL_MOTORMOUTH && > > - printk_kthread) { > > + !printk_sync && printk_kthread) { > > /* Offload printing to a schedulable context. */ > > printk_kthread_need_flush_console = true; > > wake_up_process(printk_kthread); > > It would seem more future-proof to hide '!printk_sync && printk_kthread' > into a wrapper function as it is somewhat subtle detail that printk_kthread > needn't exist while !printk_sync and I can imagine someone forgetting to > check that in the future. Something like 'can_print_async()'? But I don't > feel too strongly about that so feel free to add: hm, yes. this is what I eventually do in "yet to be posted" make-console_unlock()-async patch. I move printing kthread wakeup-s and those async printing checks out of vprintk_emit() and wake_up_klogd_work_func() to a special function: static bool console_unlock_async_flush(void) { ... if (console_loglevel != CONSOLE_LOGLEVEL_MOTORMOUTH && !printk_sync && printk_kthread) { /* Offload printing to a schedulable context. */ printk_kthread_need_flush_console = true; console_locked = 0; up_console_sem(); wake_up_process(printk_kthread); return true; } return false; } so async_printk flags live in one place (which makes it easier to maintain) and vprintk_emit()/wake_up_klogd_work_func() simply do: if (console_trylock()) console_unlock(); console_unlock() is the one who decides if it can do async printk or a 'direct printing' via console_flush_and_unlock(). void console_unlock(void) { if (console_unlock_async_flush()) return; console_flush_and_unlock(); } console_flush_and_unlock() is what was previously known as console_unlock() - emit the messages and call_console_drivers(). I guess I can send out an updated version of 0003 as a reply to the initial patch and hide '!printk_sync && printk_kthread'. > Reviewed-by: Jan Kara > > regardless whether you change this or not. thanks. -ss