From owner-svn-src-head@freebsd.org Thu Dec 22 18:39:18 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 706DCC8CD54; Thu, 22 Dec 2016 18:39:18 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5115A1C9B; Thu, 22 Dec 2016 18:39:18 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 31A6010A761; Thu, 22 Dec 2016 13:39:17 -0500 (EST) From: John Baldwin To: Mark Johnston Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310423 - head/sys/kern Date: Thu, 22 Dec 2016 10:39:12 -0800 Message-ID: <6562460.a4qdZuDa0s@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: <201612221751.uBMHpim4062786@repo.freebsd.org> References: <201612221751.uBMHpim4062786@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Thu, 22 Dec 2016 13:39:17 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Dec 2016 18:39:18 -0000 On Thursday, December 22, 2016 05:51:44 PM Mark Johnston wrote: > Author: markj > Date: Thu Dec 22 17:51:44 2016 > New Revision: 310423 > URL: https://svnweb.freebsd.org/changeset/base/310423 > > Log: > Revert part of r300109. > > The removal of TAILQ_FOREACH_SAFE introduced a small race: when the last > thread on a sleepqueue is awoken, it reclaims the sleepqueue and may begin > executing on a different CPU before sleepq_resume_thread() returns. This > leaves a window during which it may go back to sleep and incorrectly be > awoken again by the caller of sleepq_broadcast(). This is very subtle. The issue is that the last sleepq_resume_thread transfers ownership of 'sq' from the wait channel that the sleepq_broadcast has locked, to the thread being resumed. I thought about using a local TAILQ_HEAD and using TAILQ_CONCAT to move the list of threads out of the sleep queue and then walking that list. However, a comment explaining this transfer of ownership (and that we can't safely access 'sq' after the last thread is resumed) is probably sufficient (but necessary I think). Do you feel like adding one? -- John Baldwin