9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] ilock funny?
@ 2008-05-29  1:34 erik quanstrom
  2008-05-29 13:40 ` Gorka Guardiola
  2008-05-29 13:59 ` Russ Cox
  0 siblings, 2 replies; 6+ messages in thread
From: erik quanstrom @ 2008-05-29  1:34 UTC (permalink / raw)
  To: 9fans

i've got a panic that appears to be a race in ilock.
but perhaps i'm missing something and it's actually
a h/w problem.

in this situation there are 128 kernel procs that all
increment the same counter with some code
that looks like so:

void
incref(void)
{
	ilock(&somelock);
	someval++;
	iunlock(&somelock);
}

(i realize there are probablly better ways to do this.)
there is a similar function to decrease the value.
other than this, there are no references to somelock.

what i'm seeing is a panic with someval = 5. (gathered
from the fact that someval is stored immediately after
the somelock and is dumped with dumplockmem())
and the panic message:

corrupt ilock &somelock pc=&incref m=0 isilock=1

since the value of isilock is exactly 1, it's hard to imagine
this is a bad memory stick or a wild ptr.

i can't see how this could be unless on very first
reference of the lock there is a race with the looser
evaluateing !l->isilock before that processor can see
the winner setting l->isilock to 1.

if this diagnosis is correct, what is the proper fix?
ken does lock and unlock each lock he uses them in the fs
code before using them.  is this this required for kernel
ilocks, too?

- erik



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-05-29 18:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-29  1:34 [9fans] ilock funny? erik quanstrom
2008-05-29 13:40 ` Gorka Guardiola
2008-05-29 14:01   ` erik quanstrom
2008-05-29 18:47   ` Gorka Guardiola
2008-05-29 13:59 ` Russ Cox
2008-05-29 14:00   ` erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).