Date: Tue, 29 Oct 2002 01:54:26 -0800 (PST) From: Neal Fachan <neal@isilon.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/44585: bug in lockmgr Message-ID: <200210290954.g9T9sQ9P050011@www.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 44585 >Category: kern >Synopsis: bug in lockmgr >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Oct 29 02:00:03 PST 2002 >Closed-Date: >Last-Modified: >Originator: Neal Fachan >Release: 5.0-CURRENT from a few months back >Organization: Isilon Systems, Inc. >Environment: >Description: Imagine three threads. Threads 1 and 2 get shared lock: lk_sharecount = 2; lk_flags = LK_SHARE_NONZERO; Thread 3 goes to get exclusive. It gets through the first acquire without sleeping (LK_HAVE_EXCL | LK_WANT_EXCL). It then sets LK_WANT_EXCL and then sleeps on the second acquire: lk_sharecount = 2; lk_flags = LK_WANT_EXCL | LK_SHARE_NONZERO; thread 3 sleeping on: !(LK_WANT_UPGRADE | LK_SHARE_NONZERO); Thread 2 goes to sleep waiting on an upgrade: lk_sharecount = 1; lk_flags = LK_WANT_EXCL | LK_WANT_UPGRADE | LK_SHARE_NONZERO; thread 2 sleeping on: !(LK_SHARE_NONZERO); thread 3 sleeping on: !(LK_SHARE_NONZERO | LK_WANT_UPGRADE); Thread 1 unlocks shared lock: lk_sharecount = 0; lk_flags = LK_WANT_EXCL | LK_WANT_UPGRADE; thread 2 sleeping on: !(LK_SHARE_NONZERO); thread 3 sleeping on: !(LK_SHARE_NONZERO | LK_WANT_UPGRADE); Thread 2 wakes up first, and takes exclusive lock: lk_exclusivecount = 1; lk_flags = LK_WANT_EXCL | LK_HAVE_EXCL; thread 3 sleeping on: !(LK_SHARE_NONZERO | LK_WANT_UPGRADE); Thread 3 wakes up second, and also tries to take exclusive lock: lk_exclusivecount = 2; /* !!! big trouble for moose and squirrel */ lk_flags = LK_HAVE_EXCL; >How-To-Repeat: >Fix: The fix is to put LK_HAVE_EXCL in the second acquire of the LK_EXCLUSIVE path: change acquire(LK_WANT_UPGRADE | LK_SHARE_NONZERO) to acquire(LK_HAS_EXCL | LK_WANT_UPGRADE | LK_SHARE_NONZERO). >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210290954.g9T9sQ9P050011>