Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jun 2002 00:45:15 -0700
From:      Jeffrey Hsu <hsu@FreeBSD.org>
To:        Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp>
Cc:        smp@FreeBSD.org, yangjihui@yahoo.com
Subject:   Re: Sharing a single mutex between a socket and its PCB
Message-ID:  <0GXW00IUY5IPFL@mta6.snfc21.pbi.net>
In-Reply-To: Message from Seigo Tanimura <tanimura@r.dl.itc.u-tokyo.ac.jp> "of Mon, 17 Jun 2002 18:04:33 %2B0900." <200206170904.g5H94X3i076651@rina.r.dl.itc.u-tokyo.ac.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
  > BSD/OS does:

  > tcp_usrreq(so)
  > {
  >	sb = so->so_buf;
  >	SOCKBUF_UNLOCK(sb);
  >	/* XXX What if someone modified the socket? */
  >	INP_LOCK(inp);
  >	SOCKBUF_LOCK(sb);
  >	tcp_do_usrreq();
  >	INP_UNLOCK(inp);
  > }

The XXX comment is yours.  You're thinking locally instead of globally.
SMP locking is tricky and fragile because you have to consider all the
related code together, not individual accesses to structure fields in
isolation.

Find the two actual code paths in the source where a race condition arises
due to the unlocking above.  (Then convince yourself why that race condition
doesn't really matter.)




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0GXW00IUY5IPFL>