From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754156AbcDAJgq (ORCPT ); Fri, 1 Apr 2016 05:36:46 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:33283 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752830AbcDAJgo (ORCPT ); Fri, 1 Apr 2016 05:36:44 -0400 Date: Fri, 1 Apr 2016 18:36:02 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Sergey Senozhatsky , Sergey Senozhatsky , Andrew Morton , Jan Kara , Tejun Heo , Tetsuo Handa , linux-kernel@vger.kernel.org, Byungchul Park , Jan Kara Subject: Re: [RFC][PATCH v8 1/2] printk: Make printk() completely async Message-ID: <20160401093602.GB503@swordfish> References: <1458834203-3392-1-git-send-email-sergey.senozhatsky@gmail.com> <1458834203-3392-2-git-send-email-sergey.senozhatsky@gmail.com> <20160331111229.GB1023@pathway.suse.cz> <20160401010803.GA501@swordfish> <20160401085912.GO5522@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160401085912.GO5522@pathway.suse.cz> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Petr, On (04/01/16 10:59), Petr Mladek wrote: [..] > CPU0 CPU1 > > printk() > > if (printk_kthread) > # fails and need_flush_console > # stays false > > init_printk_kthread() > # put printk_thread into > # run queue > printk_kthread = ...; > > if (!in_panic && printk_kthread) > wake_up_process(printk_kthread); > > > # printk kthread finally gets > # scheduled > printk_kthread_func() > > set_current_state(TASK_INTERRUPTIBLE); > if (!need_flush_console) > schedule(); > > => printk_kthread is happily sleeping without calling console. oohh, that tiny race. well, looks quite harmless, it's unlikely that we had printk()-s up until late_initcall(init_printk_kthread) and not a single one ever after. but good find! so the check if (printk_kthread) need_flush_console = 1 can be replaced with if (!printk_sync) need_flush_console = 1 or... may be dropped. > I do not see any code that will modify need_flush_console when > printk.synchronous is modified at runtime. printk.synchronous is RO; no runtime modification. > I know that all this is rather theoretical. My main point is to remove > unnecessary checks that make the code harder to read and does not bring > any big advantage. my point is that those checks are just .loads, which help to avoid spurious .stores from various CPUs. CPU1 CPU2 CPU3 ... CPU1024 lock logbuf need_flush=1 unlock logbuf lock logbuf need_flush=1 unlock logbuf lock logbuf need_flush=1 unlock logbuf wakeup kthread ... lock logbuf need_flush=1 unlock logbuf isn't it a bit useless need_flush=1 traffic? -ss