Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751325AbeAPKKg (ORCPT + 1 other); Tue, 16 Jan 2018 05:10:36 -0500 Received: from mail-pl0-f46.google.com ([209.85.160.46]:35807 "EHLO mail-pl0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750807AbeAPKKe (ORCPT ); Tue, 16 Jan 2018 05:10:34 -0500 X-Google-Smtp-Source: ACJfBotU7PI0ONeY8Irc/voyJfDbPBAG4Z7cJvw96zs42ZJFML6UNAZaGbpPUizwLl2yMMWyVmSxAw== Date: Tue, 16 Jan 2018 19:10:29 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Tejun Heo , akpm@linux-foundation.org, linux-mm@kvack.org, Cong Wang , Dave Hansen , Johannes Weiner , Mel Gorman , Michal Hocko , Vlastimil Babka , Peter Zijlstra , Linus Torvalds , Jan Kara , Mathieu Desnoyers , Tetsuo Handa , rostedt@home.goodmis.org, Byungchul Park , Pavel Machek , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 0/2] printk: Console owner and waiter logic cleanup Message-ID: <20180116101029.GA485@jagdpanzerIV> References: <20180111112908.50de440a@vmware.local.home> <20180112025612.GB6419@jagdpanzerIV> <20180111222140.7fd89d52@gandalf.local.home> <20180112100544.GA441@jagdpanzerIV> <20180112072123.33bb567d@gandalf.local.home> <20180113072834.GA1701@tigerII.localdomain> <20180115101743.qh5whicsn6hmac32@pathway.suse.cz> <20180115115013.cyeocszurvguc3xu@pathway.suse.cz> <20180116061013.GA19801@jagdpanzerIV> <20180116093622.ybippgmw3bdsicgg@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180116093622.ybippgmw3bdsicgg@pathway.suse.cz> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On (01/16/18 10:36), Petr Mladek wrote: [..] > > unfortunately disabling preemtion in console_unlock() is a bit > > dangerous :( we have paths that call console_unlock() exactly > > to flush everything (not only new pending messages, but everything) > > that is in logbuf and we cannot return from console_unlock() > > preliminary in that case. > > You are right. Just to be sure. Are you talking about replaying > the entire log when a new console is registered? Or do you know > about more paths? to the best of my knowledge CON_PRINTBUFFER is the only thing that explicitly states "I want everything what's in logbuf, even if it has been already printed on other consoles" the rest want to have only pending messages, so we can offload from there. CON_PRINTBUFFER registration can happen any time. e.g. via modprobe netconsole. we can be up and running for some time when netconsole joins in, so that CON_PRINTBUFFER thing can be painful. > If I get it correctly, we allow to hand off the lock even when > replying the entire log. But you are right that we should > enable preemption in this case because there are many messages > even without printk() activity. > IMHO, the best solution would be to reply the log in a > separate process asynchronously and do not block existing > consoles in the meantime. But I am not sure if it is worth > the complexity. Anyway, it is a future work. [..] > > > int printk_kthread_func(void *data) > > > { > > > while(1) { > > > if (!pending_messaged) > > > schedule(); > > > > > > if (console_trylock_spinning()) > > > console_unlock(); > > > > > > cond_resched(); > > > } > > > } > > > > overall that's very close to what I have in one of my private branches. > > console_trylock_spinning() for some reason does not perform really > > well on my made-up internal printk torture tests. it seems that I > > have a much better stability (no lockups and so on) when I also let > > printk_kthread to sleep on console_sem(). but I will look further. > > I believe that it is not trivial. console_trylock_spinning() is > tricky and the timing is important. yes, timing seems to be very important. *as far as I can see from the traces on my printk torture tests* > For example, it might be tricky if a torture test affects the normal > workflow by many interrupts. We might need to call even more > console_unlock() code with spinning enabled to improve the success > ratio. Another problem is that the kthread must be scheduled on > another CPU. yes, I always schedule it on another CPU [if any]. > And so on. I believe that there are many more problems and areas > for improvement. right. -ss