* [parisc-linux] spinlock debug
@ 2004-07-14 4:29 Randolph Chung
2004-07-14 5:08 ` Randolph Chung
2004-07-14 5:28 ` Grant Grundler
0 siblings, 2 replies; 4+ messages in thread
From: Randolph Chung @ 2004-07-14 4:29 UTC (permalink / raw)
To: varenet; +Cc: parisc-linux
Thibaut,
I'm just looking at your debuglocks stuff again. It doesn't look right
to me.
/* Do the actual locking */
/* <T-Bone> ggg: we can't get stuck on the outter loop?
* <ggg> T-Bone: We only hit the outer loop when the data
* changes and the first time. We can hit the outer one
* alot if multiple CPUs are constantly racing for a lock
* and the backplane is NOT fair about which CPU sees
* the update first. But it won't hang since every failed
* attempt will drop us back into the inner loop and
* decrement `stuck'.
* <ggg> K-class and some of the others are NOT fair in the HW
* implementation so we could see false positives.
* But fixing the lock contention is easier than
* fixing the HW to be fair.
*/
a = __ldcw_align(lock);
while ((__ldcw(a) == 0))
while ((*a == 0) && --stuck);
I don't think the comment is correct. Lets say someone is holding the
lock when you enter this code, your outer loop test always succeeds, and
you spin on the inner loop until stuck == 0. At that point you go back
to the outer loop, the lock is still held, so you go back to the inner
loop and continue spinning, and you never timeout the lock.
you probably need a "&& stuck > 0" in the outer loop.
for some reason this still doesn't work for me though, but i don't see
why :( with a TOC i see we are spinning and i never see the printk.
it might be that it's actually printing and just that the output is not
going to the console... dunno
what am i missing? :)
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [parisc-linux] spinlock debug
2004-07-14 4:29 [parisc-linux] spinlock debug Randolph Chung
@ 2004-07-14 5:08 ` Randolph Chung
2004-07-14 5:28 ` Grant Grundler
1 sibling, 0 replies; 4+ messages in thread
From: Randolph Chung @ 2004-07-14 5:08 UTC (permalink / raw)
To: varenet; +Cc: parisc-linux
> a = __ldcw_align(lock);
> while ((__ldcw(a) == 0))
> while ((*a == 0) && --stuck);
There's another race in the code. Suppose stuck becomes 0, so you go
back to the outer loop, and you manage to acquire the lock, then you
will hit the next if:
52 if (unlikely(stuck <= 0)) {
53 printk(KERN_ERR
54 "%s:%d: spin_lock(%s/%p) stuck in %s at %p(%d)"
55 " owned by %s:%d in %s at %p(%d)\n",
56 base_file, line_no, lock->module, lock,
57 current->comm, inline_pc, cpu,
58 lock->bfile, lock->bline, lock->task->comm,
59 lock->previous, lock->oncpu);
60 stuck = INIT_STUCK;
61 printed = 1;
62 goto try_again;
63 }
so you erroneously detect that the lock was not taken, print an error,
and go back to get the lock again. now you will not be able to acquire
the lock and you are deadlocked.
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [parisc-linux] spinlock debug
2004-07-14 4:29 [parisc-linux] spinlock debug Randolph Chung
2004-07-14 5:08 ` Randolph Chung
@ 2004-07-14 5:28 ` Grant Grundler
2004-07-14 5:30 ` Randolph Chung
1 sibling, 1 reply; 4+ messages in thread
From: Grant Grundler @ 2004-07-14 5:28 UTC (permalink / raw)
To: Randolph Chung; +Cc: parisc-linux, varenet
On Tue, Jul 13, 2004 at 09:29:10PM -0700, Randolph Chung wrote:
> I don't think the comment is correct.
The comment is *mostly* correct.
It just doesn't get all the exit criteria right. :^)
> Lets say someone is holding the
> lock when you enter this code, your outer loop test always succeeds, and
> you spin on the inner loop until stuck == 0. At that point you go back
> to the outer loop, the lock is still held, so you go back to the inner
> loop and continue spinning, and you never timeout the lock.
Yup - good catch.
> you probably need a "&& stuck > 0" in the outer loop.
Yes. This should be sufficient:
a = __ldcw_align(lock);
while ((__ldcw(a) == 0) && stuck)
while ((*a == 0) && --stuck);
> for some reason this still doesn't work for me though, but i don't see
> why :( with a TOC i see we are spinning and i never see the printk.
> it might be that it's actually printing and just that the output is not
> going to the console... dunno
Do you happen to know which lock it's spinning on?
That should at least reduce the subset of code we need to look at.
grant
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [parisc-linux] spinlock debug
2004-07-14 5:28 ` Grant Grundler
@ 2004-07-14 5:30 ` Randolph Chung
0 siblings, 0 replies; 4+ messages in thread
From: Randolph Chung @ 2004-07-14 5:30 UTC (permalink / raw)
To: Grant Grundler; +Cc: parisc-linux, varenet
> Do you happen to know which lock it's spinning on?
> That should at least reduce the subset of code we need to look at.
Nope, which is why i wanted to get the printk output :-)
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-07-14 5:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-14 4:29 [parisc-linux] spinlock debug Randolph Chung
2004-07-14 5:08 ` Randolph Chung
2004-07-14 5:28 ` Grant Grundler
2004-07-14 5:30 ` Randolph Chung
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.