spinlock debug
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
Signature · 7 lines
Randolph Chung Debian GNU/Linux Developer, hppa/ia64 ports http://www.tausq.org/ _______________________________________________ parisc-linux mailing list [email protected] http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 3 lines
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
Signature · 7 lines
Randolph Chung Debian GNU/Linux Developer, hppa/ia64 ports http://www.tausq.org/ _______________________________________________ parisc-linux mailing list [email protected] http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 1 line · Randolph Chung
I don't think the comment is correct.
The comment is *mostly* correct.
It just doesn't get all the exit criteria right. :^)
Quoted 5 lines
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.
Quoted 1 line
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);Quoted 4 lines
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
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Quoted 2 lines
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
Signature · 7 lines
Randolph Chung Debian GNU/Linux Developer, hppa/ia64 ports http://www.tausq.org/ _______________________________________________ parisc-linux mailing list [email protected] http://lists.parisc-linux.org/mailman/listinfo/parisc-linux