From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754583AbcCWKE1 (ORCPT ); Wed, 23 Mar 2016 06:04:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:58332 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751611AbcCWKEW (ORCPT ); Wed, 23 Mar 2016 06:04:22 -0400 Date: Wed, 23 Mar 2016 11:04:20 +0100 From: Petr Mladek To: Sergey Senozhatsky Cc: Sergey Senozhatsky , Andrew Morton , Jan Kara , Tejun Heo , Tetsuo Handa , linux-kernel@vger.kernel.org, Byungchul Park , Jan Kara Subject: Re: [RFC][PATCH v6 1/2] printk: Make printk() completely async Message-ID: <20160323100420.GD5522@pathway.suse.cz> References: <1458581130-8677-1-git-send-email-sergey.senozhatsky@gmail.com> <1458581130-8677-2-git-send-email-sergey.senozhatsky@gmail.com> <20160322131106.GA5522@pathway.suse.cz> <20160323003725.GA641@swordfish> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160323003725.GA641@swordfish> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2016-03-23 09:37:25, Sergey Senozhatsky wrote: > Hello Petr, > > On (03/22/16 14:11), Petr Mladek wrote: > > > + * Set printing_func() sleep condition early, under the @logbuf_lock. > > > + * So printing kthread (if RUNNING) will go to console_lock() and spin > > > + * on @logbuf_lock. > > > + */ > > > + if (!printk_sync) > > > + need_flush_console = true; > > > > We set this variable for each call and also when printk_kthread is > > NULL or when sync_printk is false. > > hm, yes. (printk_kthread && !need_flush_console) makes more sense. > so we it doesn't get re-dirty if already set. This does not solve the problem mentioned below. There still might be extra cycle if the kthread is inside console_unclock(). > > We migth want to clear it also from console_unlock(). I think that > > a good place would be in the check: > > > > raw_spin_lock(&logbuf_lock); > > retry = console_seq != log_next_seq; > > raw_spin_unlock_irqrestore(&logbuf_lock, flags); > > hm, what's wrong with clearing it in printk_kthread printing function? I though about the following scenario: CPU0 CPU1 vprintk_emit() need_flush_console = true; wake_up_process(printk_thread) printing_func() need_flush_console = false; console_lock() console_unlock() vprintk_emit() need_flush_console = true; # flush 1st message # flush 2nd message if (!need_flush_console) # fails and continues console_lock() console_unlock() # nope because 2nd # message already flushed if (!need_flush_console) schedule() # did one unnecessary # cycle to get asleep Best Regards, Petr PS: If you touch the code, please rename printing_func() to printk_kthread_func() to make it more clear what it does. I am sorry for nitpicking.