* spinlock deadlock
@ 2013-02-15 8:52 buyitian
2013-02-15 11:47 ` anish singh
2013-02-17 5:37 ` Mulyadi Santosa
0 siblings, 2 replies; 8+ messages in thread
From: buyitian @ 2013-02-15 8:52 UTC (permalink / raw)
To: kernelnewbies
is it possible that printk cause deadlock? the path is as below:
1. taskA runs on CPU0, and run schedule to acqire the rq->lock.2. taskA calls printk while holding rq->lock.3. taskA holds console_sem.4. taskB runs on CPU1, and call console_lock(), which is blocked by console_sem and queue itslef to the wait list.5. taskB migrates from CPU1 to cpu0. will this step occur?6. taskA calls up(&console_sem)--> wake_up_process()-->try_to_wake_up()-->ttwu_queue()-->raw_spin_lock(&rq->lock). here taskA tries to acquire the rq->lock of CPU0 again.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130215/f5658f4a/attachment.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* spinlock deadlock
2013-02-15 8:52 spinlock deadlock buyitian
@ 2013-02-15 11:47 ` anish singh
2013-02-15 16:12 ` Valdis.Kletnieks at vt.edu
2013-02-17 5:37 ` Mulyadi Santosa
1 sibling, 1 reply; 8+ messages in thread
From: anish singh @ 2013-02-15 11:47 UTC (permalink / raw)
To: kernelnewbies
adding Joe Perches as generally he looks after printk stuff.
On Fri, Feb 15, 2013 at 2:22 PM, buyitian <buyit@live.cn> wrote:
> is it possible that printk cause deadlock? the path is as below:
>
> 1. taskA runs on CPU0, and run schedule to acqire the rq->lock.
> 2. taskA calls printk while holding rq->lock.
> 3. taskA holds console_sem.
> 4. taskB runs on CPU1, and call console_lock(), which is blocked by
> console_sem and queue itslef to the wait list.
> 5. taskB migrates from CPU1 to cpu0. will this step occur?
> 6. taskA calls up(&console_sem)-->
> wake_up_process()-->try_to_wake_up()-->ttwu_queue()-->raw_spin_lock(&rq->lock).
> here taskA tries to acquire the rq->lock of CPU0 again.
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* spinlock deadlock
2013-02-15 11:47 ` anish singh
@ 2013-02-15 16:12 ` Valdis.Kletnieks at vt.edu
2013-02-15 16:34 ` buyitian
0 siblings, 1 reply; 8+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2013-02-15 16:12 UTC (permalink / raw)
To: kernelnewbies
On Fri, 15 Feb 2013 17:17:38 +0530, anish singh said:
> adding Joe Perches as generally he looks after printk stuff.
>
> On Fri, Feb 15, 2013 at 2:22 PM, buyitian <buyit@live.cn> wrote:
> > is it possible that printk cause deadlock? the path is as below:
> >
> > 1. taskA runs on CPU0, and run schedule to acqire the rq->lock.
> > 2. taskA calls printk while holding rq->lock.
> > 3. taskA holds console_sem.
> > 4. taskB runs on CPU1, and call console_lock(), which is blocked by
> > console_sem and queue itslef to the wait list.
> > 5. taskB migrates from CPU1 to cpu0. will this step occur?
> > 6. taskA calls up(&console_sem)-->
> > wake_up_process()-->try_to_wake_up()-->ttwu_queue()-->raw_spin_lock(&rq->lock).
> > here taskA tries to acquire the rq->lock of CPU0 again.
I'm not Joe, but what kernel release are you looking at? ISTR that in
the last few releases (3.5-ish maybe?), that code got overhauled to
prevent a similar issue...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130215/de7b1846/attachment.bin
^ permalink raw reply [flat|nested] 8+ messages in thread
* spinlock deadlock
2013-02-15 16:12 ` Valdis.Kletnieks at vt.edu
@ 2013-02-15 16:34 ` buyitian
2013-02-15 17:51 ` anish kumar
0 siblings, 1 reply; 8+ messages in thread
From: buyitian @ 2013-02-15 16:34 UTC (permalink / raw)
To: kernelnewbies
I am looking at version 3.4
? 2013-2-16?0:17?Valdis.Kletnieks at vt.edu ???
> On Fri, 15 Feb 2013 17:17:38 +0530, anish singh said:
>> adding Joe Perches as generally he looks after printk stuff.
>>
>> On Fri, Feb 15, 2013 at 2:22 PM, buyitian <buyit@live.cn> wrote:
>>> is it possible that printk cause deadlock? the path is as below:
>>>
>>> 1. taskA runs on CPU0, and run schedule to acqire the rq->lock.
>>> 2. taskA calls printk while holding rq->lock.
>>> 3. taskA holds console_sem.
>>> 4. taskB runs on CPU1, and call console_lock(), which is blocked by
>>> console_sem and queue itslef to the wait list.
>>> 5. taskB migrates from CPU1 to cpu0. will this step occur?
>>> 6. taskA calls up(&console_sem)-->
>>> wake_up_process()-->try_to_wake_up()-->ttwu_queue()-->raw_spin_lock(&rq->lock).
>>> here taskA tries to acquire the rq->lock of CPU0 again.
>
> I'm not Joe, but what kernel release are you looking at? ISTR that in
> the last few releases (3.5-ish maybe?), that code got overhauled to
> prevent a similar issue...
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 8+ messages in thread
* spinlock deadlock
2013-02-15 16:34 ` buyitian
@ 2013-02-15 17:51 ` anish kumar
0 siblings, 0 replies; 8+ messages in thread
From: anish kumar @ 2013-02-15 17:51 UTC (permalink / raw)
To: kernelnewbies
On Sat, 2013-02-16 at 00:34 +0800, buyitian wrote:
> I am looking at version 3.4
>
> ? 2013-2-16?0:17?Valdis.Kletnieks at vt.edu ???
>
> > On Fri, 15 Feb 2013 17:17:38 +0530, anish singh said:
> >> adding Joe Perches as generally he looks after printk stuff.
> >>
> >> On Fri, Feb 15, 2013 at 2:22 PM, buyitian <buyit@live.cn> wrote:
> >>> is it possible that printk cause deadlock? the path is as below:
> >>>
> >>> 1. taskA runs on CPU0, and run schedule to acqire the rq->lock.
> >>> 2. taskA calls printk while holding rq->lock.
> >>> 3. taskA holds console_sem.
> >>> 4. taskB runs on CPU1, and call console_lock(), which is blocked by
> >>> console_sem and queue itslef to the wait list.
> >>> 5. taskB migrates from CPU1 to cpu0. will this step occur?
> >>> 6. taskA calls up(&console_sem)-->
> >>> wake_up_process()-->try_to_wake_up()-->ttwu_queue()-->raw_spin_lock(&rq->lock).
> >>> here taskA tries to acquire the rq->lock of CPU0 again.
> >
> > I'm not Joe, but what kernel release are you looking at? ISTR that in
> > the last few releases (3.5-ish maybe?), that code got overhauled to
> > prevent a similar issue..
Can you ask this question in kernel maling list?I think you might get a
better reply to your queries.
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies at kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 8+ messages in thread
* spinlock deadlock
2013-02-15 8:52 spinlock deadlock buyitian
2013-02-15 11:47 ` anish singh
@ 2013-02-17 5:37 ` Mulyadi Santosa
2013-02-17 6:18 ` buyitian
1 sibling, 1 reply; 8+ messages in thread
From: Mulyadi Santosa @ 2013-02-17 5:37 UTC (permalink / raw)
To: kernelnewbies
On Fri, Feb 15, 2013 at 3:52 PM, buyitian <buyit@live.cn> wrote:
> is it possible that printk cause deadlock? the path is as below:
>
> 1. taskA runs on CPU0, and run schedule to acqire the rq->lock.
> 2. taskA calls printk while holding rq->lock.
I began to get rusty on this...but, why do you grab run queue lock?
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* spinlock deadlock
2013-02-17 5:37 ` Mulyadi Santosa
@ 2013-02-17 6:18 ` buyitian
[not found] ` <alpine.LFD.2.02.1302181051350.22263@ionos>
0 siblings, 1 reply; 8+ messages in thread
From: buyitian @ 2013-02-17 6:18 UTC (permalink / raw)
To: kernelnewbies
> From: mulyadi.santosa at gmail.com
> Date: Sun, 17 Feb 2013 12:37:21 +0700
> Subject: Re: spinlock deadlock
> To: buyit at live.cn
> CC: kernelnewbies at kernelnewbies.org
>
> On Fri, Feb 15, 2013 at 3:52 PM, buyitian <buyit@live.cn> wrote:
> > is it possible that printk cause deadlock? the path is as below:
> >
> > 1. taskA runs on CPU0, and run schedule to acqire the rq->lock.
> > 2. taskA calls printk while holding rq->lock.
>
> I began to get rusty on this...but, why do you grab run queue lock?
>
> i want to know why the authors use spinlock and semaphore like this, because the change history is very insteresting:1. in patch 0b5e1c5255e7ee8670e077e8224e5c2281229a5b: Peter did below changes: (1). in function console_trylock_for_printk():if (!can_use_console(cpu)) {
console_locked = 0;
- up(&console_sem);
+ wake = 1;
retval = 0;
}
}
printk_cpu = UINT_MAX;
spin_unlock(&logbuf_lock);
+ if (wake)
+ up(&console_sem); (2). in function console_unlock(): - up(&console_sem);
spin_unlock_irqrestore(&logbuf_lock, flags);
+ up(&console_sem);
if (wake_klogd)
wake_up_klogd();
} this patch is to prevent deadlock between rq->lock and logbuf_lock. i can understand this thanks to Rabin. 2. in patch 07354eb1a74d1e1ece29f8bafe0b46e8c77a95ef, Thomas did changes as below, which reverted the change from peter, i don't know why: in function console_trylock_for_printk(): - spin_unlock(&logbuf_lock);
if (wake)
up(&console_sem);
+ raw_spin_unlock(&logbuf_lock); and this change exists in the latest kernel source code. it seems that deadlock bewteen rq->lock and logbuf_lock comes back, who can explain this, thanks. BTW: if i place printk inside schedule(), i may get rq->lock before calling printk.
> --
> regards,
>
> Mulyadi Santosa
> Freelance Linux trainer and consultant
>
> blog: the-hydra.blogspot.com
> training: mulyaditraining.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130217/8c5fce42/attachment.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* spinlock deadlock
[not found] ` <alpine.LFD.2.02.1302181051350.22263@ionos>
@ 2013-02-18 10:29 ` buyitian
0 siblings, 0 replies; 8+ messages in thread
From: buyitian @ 2013-02-18 10:29 UTC (permalink / raw)
To: kernelnewbies
> Date: Mon, 18 Feb 2013 10:54:44 +0100
> From: tglx at linutronix.de
> To: buyit at live.cn
> CC: mulyadi.santosa at gmail.com; kernelnewbies at kernelnewbies.org; a.p.zijlstra at chello.nl; rabin at rab.in; mingo at kernel.org
> Subject: RE: spinlock deadlock
>
> On Sun, 17 Feb 2013, buyitian wrote:
>
> Could you please use a mail client, which creates readable mail?
>
> > this patch is to prevent deadlock between rq->lock and
> > logbuf_lock. i can understand this thanks to Rabin. 2. in patch
> > 07354eb1a74d1e1ece29f8bafe0b46e8c77a95ef, Thomas did changes as
> > below, which reverted the change from peter, i don't know why: in
> > function console_trylock_for_printk():
>
> > - spin_unlock(&logbuf_lock);
> > if (wake)
> > up(&console_sem);
> > + raw_spin_unlock(&logbuf_lock);
>
> > and this change exists in the latest kernel source code. it seems
> > that deadlock bewteen rq->lock and logbuf_lock comes back, who can
> > explain this, thanks. BTW: if i place printk inside schedule(), i
> > may get rq->lock before calling printk.
>
> That looks like a merge slipup. The patch which converts the lock is
> not supposed to do any other changes. But the patch was based on an
> older kernel version, which did not have Peters changes yet. So the
> fixup of the not longer applying patch failed somehow. i will provide patch, thanks for your reply.
>
> Thanks,
>
> tglx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130218/36428bc9/attachment.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-02-18 10:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-15 8:52 spinlock deadlock buyitian
2013-02-15 11:47 ` anish singh
2013-02-15 16:12 ` Valdis.Kletnieks at vt.edu
2013-02-15 16:34 ` buyitian
2013-02-15 17:51 ` anish kumar
2013-02-17 5:37 ` Mulyadi Santosa
2013-02-17 6:18 ` buyitian
[not found] ` <alpine.LFD.2.02.1302181051350.22263@ionos>
2013-02-18 10:29 ` buyitian
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.