From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751962AbcBAG3X (ORCPT ); Mon, 1 Feb 2016 01:29:23 -0500 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:58404 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751071AbcBAG3W (ORCPT ); Mon, 1 Feb 2016 01:29:22 -0500 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Mon, 1 Feb 2016 15:28:52 +0900 From: Byungchul Park To: Sergey Senozhatsky Cc: akpm@linux-foundation.org, mingo@kernel.org, linux-kernel@vger.kernel.org, akinobu.mita@gmail.com, jack@suse.cz, peter@hurleysoftware.com, torvalds@linux-foundation.org Subject: Re: [PATCH v5] lib/spinlock_debug.c: prevent a recursive cycle in the debug code Message-ID: <20160201062852.GB29804@X58A-UD3R> References: <1454071417-20685-1-git-send-email-byungchul.park@lge.com> <20160201023112.GC1033@swordfish> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160201023112.GC1033@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 Mon, Feb 01, 2016 at 11:31:12AM +0900, Sergey Senozhatsky wrote: > On (01/29/16 21:43), Byungchul Park wrote: > [..] > > +extern int is_console_lock(raw_spinlock_t *lock); > > + > > static void __spin_lock_debug(raw_spinlock_t *lock) > > { > > u64 i; > > @@ -113,11 +115,19 @@ static void __spin_lock_debug(raw_spinlock_t *lock) > > return; > > __delay(1); > > } > > - /* lockup suspected: */ > > - spin_dump(lock, "lockup suspected"); > > + > > + /* > > + * If this function is called from printk(), then we should > > + * not call printk() more. Or it will cause an infinite > > + * recursive cycle! > > + */ > > + if (likely(!is_console_lock(lock))) { > > + /* lockup suspected: */ > > + spin_dump(lock, "lockup suspected"); > > #ifdef CONFIG_SMP > > - trigger_all_cpu_backtrace(); > > + trigger_all_cpu_backtrace(); > > #endif > > + } > > /* speaking in a context of printk locks only */ > > ... may be for a recoverable "lockup suspected" spin_dump() > we can switch to deferred printk of the messages, which is a > bit better than nothing. but for unrecoverable "lockup suspected" > spin_dump() -- an actual bug (spin lock owner is not going to > release the lock any more) -- we need something else, I think. > the bug will neither be reported nor fixed. Agree. > > -ss > > > /* > > * The trylock above was causing a livelock. Give the lower level arch > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > > index 2ce8826..568ab11 100644 > > --- a/kernel/printk/printk.c > > +++ b/kernel/printk/printk.c > > @@ -1981,6 +1981,11 @@ asmlinkage __visible void early_printk(const char *fmt, ...) > > } > > #endif > > > > +int is_console_lock(raw_spinlock_t *lock) > > +{ > > + return lock == &console_sem.lock; > > +} > > + > > static int __add_preferred_console(char *name, int idx, char *options, > > char *brl_options) > > { > > -- > > 1.9.1 > >