From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755995AbYAZJvw (ORCPT ); Sat, 26 Jan 2008 04:51:52 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753481AbYAZJvo (ORCPT ); Sat, 26 Jan 2008 04:51:44 -0500 Received: from pentafluge.infradead.org ([213.146.154.40]:45895 "EHLO pentafluge.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753152AbYAZJvm (ORCPT ); Sat, 26 Jan 2008 04:51:42 -0500 Subject: Re: [PATCH 01/23 -v6] printk - dont wakeup klogd with interrupts disabled From: Peter Zijlstra To: Steven Rostedt Cc: LKML , Ingo Molnar , Linus Torvalds , Andrew Morton , Christoph Hellwig , Mathieu Desnoyers , Gregory Haskins , Arnaldo Carvalho de Melo , Thomas Gleixner , Tim Bird , Sam Ravnborg , "Frank Ch. Eigler" , Jan Kiszka , John Stultz , Arjan van de Ven , Pavel Machek , Steven Rostedt In-Reply-To: <20080126042801.280369398@goodmis.org> References: <20080126042152.526086719@goodmis.org> <20080126042801.280369398@goodmis.org> Content-Type: text/plain Date: Sat, 26 Jan 2008 10:50:17 +0100 Message-Id: <1201341017.27573.17.camel@lappy> Mime-Version: 1.0 X-Mailer: Evolution 2.21.5 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2008-01-25 at 23:21 -0500, Steven Rostedt wrote: > @@ -1003,7 +1005,11 @@ void release_console_sem(void) > console_locked = 0; > up(&console_sem); > spin_unlock_irqrestore(&logbuf_lock, flags); > - if (wake_klogd) > + /* > + * If we try to wake up klogd while printing with the runqueue lock > + * held, this will deadlock. > + */ > + if (wake_klogd && !runqueue_is_locked()) > wake_up_klogd(); > } > EXPORT_SYMBOL(release_console_sem); > +/** > + * runqueue_is_locked > + * > + * Returns true if the current cpu runqueue is locked. > + * This interface allows printk to be called with the runqueue lock > + * held and know whether or not it is OK to wake up the klogd. > + */ > +int runqueue_is_locked(void) > +{ > + int cpu = get_cpu(); > + struct rq *rq = cpu_rq(cpu); > + int ret; > + > + ret = spin_is_locked(&rq->lock); > + put_cpu(); > + return ret; > +} Right, while this might appear to be sound, I hate to point out that we only want to exclude it when current holds the rq->lock. This could lead to spuriously missing klogd wakeups because other cpus hold our rq->lock. Now, is this klogd thing only relevant for dumping stuff into the log, or also for writing stuff out to the serial line?