From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933050AbcBPPrP (ORCPT ); Tue, 16 Feb 2016 10:47:15 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:35790 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932300AbcBPPrL (ORCPT ); Tue, 16 Feb 2016 10:47:11 -0500 Date: Wed, 17 Feb 2016 00:45:17 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Sergey Senozhatsky , Andrew Morton , Jan Kara , Tejun Heo , Kyle McMartin , Dave Jones , Calvin Owens , linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [PATCH v4 2/3] printk: set may_schedule for some of console_trylock callers Message-ID: <20160216154517.GB542@swordfish> References: <1455302232-2252-1-git-send-email-sergey.senozhatsky@gmail.com> <1455302232-2252-3-git-send-email-sergey.senozhatsky@gmail.com> <20160216144306.GU12548@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160216144306.GU12548@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 On (02/16/16 15:43), Petr Mladek wrote: > On Sat 2016-02-13 03:37:11, Sergey Senozhatsky wrote: > > console_unlock() allows to cond_resched() if its caller has > > set `console_may_schedule' to 1, since > > 'commit 8d91f8b15361 ("printk: do cond_resched() between lines while > > outputting to consoles")'. > > > > The rules are: > > -- console_lock() always sets `console_may_schedule' to 1 > > -- console_trylock() always sets `console_may_schedule' to 0 > > > > However, console_trylock() callers (among them is printk()) do > > not always call printk() from atomic contexts, and some of them > > can cond_resched() in console_unlock(), so console_trylock() > > can set `console_may_schedule' to 1 for such processes. > > > > For !CONFIG_PREEMPT_COUNT kernels, however, console_trylock() > > always sets `console_may_schedule' to 0. > > > > It's possible to drop explicit preempt_disable()/preempt_enable() > > in vprintk_emit(), because console_unlock() and console_trylock() > > are now smart enough: > > a) console_unlock() does not cond_resched() when it's unsafe > > (console_trylock() takes care of that) > > b) console_unlock() does can_use_console() check. > > > > Signed-off-by: Sergey Senozhatsky > > It looks safe after all. > > Reviewed-by: Petr Mladek > thanks. -ss