From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933007AbcBCDsV (ORCPT ); Tue, 2 Feb 2016 22:48:21 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35274 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755371AbcBCDsS (ORCPT ); Tue, 2 Feb 2016 22:48:18 -0500 Date: Wed, 3 Feb 2016 12:49:30 +0900 From: Sergey Senozhatsky To: Andrew Morton Cc: Petr Mladek , Jan Kara , Tejun Heo , Kyle McMartin , Dave Jones , Calvin Owens , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Sergey Senozhatsky Subject: Re: [RFC][PATCH v3 0/4] let printk()/console_trylock() callers to cond_resched() Message-ID: <20160203034930.GA718@swordfish> References: <1453536913-9545-1-git-send-email-sergey.senozhatsky@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1453536913-9545-1-git-send-email-sergey.senozhatsky@gmail.com> 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, On (01/23/16 17:15), Sergey Senozhatsky wrote: > [was: cond_resched() some of console_trylock callers] > > Hello, > > console_unlock() allows to cond_resched() if its caller has > set `console_may_schedule' to 1 (this functionality present > since commit 'printk: do cond_resched() between lines while > outputting to consoles'). gentlemen, did you get a chance to look into this? -ss > The rules are: > -- console_lock() always sets `console_may_schedule' to 1 > -- console_trylock() always sets `console_may_schedule' to 0 > > printk() calls console_unlock() with preemption desabled, which > basically can lead to RCU stalls, watchdog soft lockups, etc. if > something is simultaneously calling printk() frequent enough (IOW, > console_sem owner always has new data to send to console divers > and can't leave console_unlock() for a long time). > > printk()->console_trylock() callers do not necessarily execute in > atomic contexts, and some of them can cond_resched() in > console_unlock(). console_trylock() can set `console_may_schedule' > to 1 (allow cond_resched() later in consoe_unlock()) when it's safe. > > 0001 addresses a theoretical loss of printk messages. > 0002 is an optional optimization patch > 0003 drops console_trylock_for_printk > 0004 lets some of printk()/console_trylock() callers to cond_resched() > in console_unlock() > > v2-v3 (thanks to Petr Mladek for reviews): > -- do not call can_use_console() on every iteration in console_unlock() (Petr Mladek) > -- move "This stops the holder of console_sem.." comment (noted by Petr Mladek) > -- take extra care of !PREEMPT_COUNT kernels (Petr Mladek) > -- call_console_drivers() still must check cpu_online && CON_ANYTIME (Petr Mladek) > -- removed console_trylock_for_printk() (noted by Petr Mladek) > > v1-v2: > -- make have_callable_console() available for !PRINTK configs (lkp@intel.com) > -- take care of RCU preempt kernels in console_trylock() > > > Sergey Senozhatsky (4): > printk: move can_use_console out of console_trylock_for_printk > printk: do not console_cont_flush() on every jump to again > printk: remove console_trylock_for_printk > printk: set may_schedule for some of console_trylock callers > > kernel/printk/printk.c | 121 ++++++++++++++++++++++--------------------------- > 1 file changed, 55 insertions(+), 66 deletions(-) > > -- > 2.7.0 >