From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yong Zhang Subject: Re: [PATCH -rt 4/5] workqueue: hotplug fix Date: Mon, 24 Oct 2011 10:26:48 +0800 Message-ID: <20111024022648.GA24581@zhy> References: <1318762607-2261-1-git-send-email-yong.zhang0@gmail.com> <1318762607-2261-5-git-send-email-yong.zhang0@gmail.com> Reply-To: Yong Zhang Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org To: Thomas Gleixner Return-path: Received: from mail-bw0-f46.google.com ([209.85.214.46]:51425 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751244Ab1JXC1A (ORCPT ); Sun, 23 Oct 2011 22:27:00 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-rt-users-owner@vger.kernel.org List-ID: On Wed, Oct 19, 2011 at 09:14:28AM +0200, Thomas Gleixner wrote: > On Sun, 16 Oct 2011, Yong Zhang wrote: > > --- a/kernel/workqueue.c > > +++ b/kernel/workqueue.c > > @@ -3195,30 +3195,34 @@ static int __devinit workqueue_cpu_up_callback(struct notifier_block *nfb, > > } > > > > /* some are called w/ irq disabled, don't disturb irq status */ > > - spin_lock_irqsave(&gcwq->lock, flags); > > > > switch (action) { > > case CPU_UP_PREPARE: > > + spin_lock_irqsave(&gcwq->lock, flags); > > BUG_ON(gcwq->first_idle); > > gcwq->first_idle = new_worker; > > + spin_unlock_irqrestore(&gcwq->lock, flags); > > break; > > > > case CPU_UP_CANCELED: > > + spin_lock_irqsave(&gcwq->lock, flags); > > destroy_worker(gcwq->first_idle); > > gcwq->first_idle = NULL; > > + spin_unlock_irqrestore(&gcwq->lock, flags); > > break; > > > > case CPU_ONLINE: > > + spin_lock_irqsave(&gcwq->lock, flags); > > spin_unlock_irq(&gcwq->lock); > > kthread_bind(gcwq->first_idle->task, cpu); > > spin_lock_irq(&gcwq->lock); > > gcwq->flags |= GCWQ_MANAGE_WORKERS; > > start_worker(gcwq->first_idle); > > gcwq->first_idle = NULL; > > + spin_unlock_irqrestore(&gcwq->lock, flags); > > break; > > } > > > > - spin_unlock_irqrestore(&gcwq->lock, flags); > > This part of the patch is pretty pointless. But CPU_STARTING is called with irq disabled, and it will take the lock unconditionally. Thus below warning is triggered: BUG: sleeping function called from invalid context at kernel/rtmutex.c:645 in_atomic(): 1, irqs_disabled(): 1, pid: 0, name: kworker/0:0 Pid: 0, comm: kworker/0:0 Not tainted 3.0.6-rt17-00284-gb76d419 #3 Call Trace: [] ? printk+0x1d/0x20 [] __might_sleep+0xe6/0x110 [] rt_spin_lock+0x1c/0x30 [] workqueue_cpu_up_callback+0x56/0xf3 [] notifier_call_chain+0x45/0x60 [] __raw_notifier_call_chain+0x1e/0x30 [] __cpu_notify+0x24/0x40 [] cpu_notify+0x1c/0x20 [] notify_cpu_starting+0x1e/0x20 [] smp_callin+0xfb/0x10e [] start_secondary+0x19/0xd7 Thanks, Yong