From owner-cvs-src@FreeBSD.ORG Wed Feb 28 08:19:42 2007 Return-Path: X-Original-To: cvs-src@FreeBSD.org Delivered-To: cvs-src@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C5F4A16A401; Wed, 28 Feb 2007 08:19:42 +0000 (UTC) (envelope-from kris@obsecurity.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id A885613C4B6; Wed, 28 Feb 2007 08:19:42 +0000 (UTC) (envelope-from kris@obsecurity.org) Received: from obsecurity.dyndns.org (elvis.mu.org [192.203.228.196]) by elvis.mu.org (Postfix) with ESMTP id 804FD1A3C19; Wed, 28 Feb 2007 00:19:42 -0800 (PST) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 42CBE5247B; Wed, 28 Feb 2007 03:19:41 -0500 (EST) Date: Wed, 28 Feb 2007 03:19:41 -0500 From: Kris Kennaway To: Greg 'groggy' Lehey Message-ID: <20070228081940.GA64315@xor.obsecurity.org> References: <200702272309.l1RN9Xum011236@repoman.freebsd.org> <20070227235843.GA59138@xor.obsecurity.org> <20070228064334.GG8399@wantadilla.lemis.com> <20070228070904.GA63343@xor.obsecurity.org> <20070228075755.GL8399@wantadilla.lemis.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070228075755.GL8399@wantadilla.lemis.com> User-Agent: Mutt/1.4.2.2i Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org, Kris Kennaway Subject: Re: cvs commit: src/share/man/man9 sleep.9 X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Feb 2007 08:19:42 -0000 On Wed, Feb 28, 2007 at 06:27:55PM +1030, Greg 'groggy' Lehey wrote: > On Wednesday, 28 February 2007 at 2:09:04 -0500, Kris Kennaway wrote: > > On Wed, Feb 28, 2007 at 05:13:34PM +1030, Greg 'groggy' Lehey wrote: > >> How would you address the case? Recall that we're talking here about > >> two different programmers, and you don't even know who the second one > >> is. It would be nice to have some mechanism like WITLESS to detect > >> the problem, but I can't see how it would work. > > > > Who are the two different programmers, you and who else? :-) > > You're obviously one of them. Otherwise you're not involved. And as > I said, you don't know who the other one is. OK, I can't parse this, but I can't help but think that you're trying to pose as a general situation a bug that you found in your own code, and you're proceeding to assume that this problem is wide-spread. > > If there are parts of the FreeBSD kernel that are abusing a sleep > > channel to create this situation, we should fix them. > > See the rest of the thread. A "sleep channel" is a memory address. > It's usually in the kernel, so you're talking about a 30 bit address > space on ia32. That's really not very many. You can use e.g. the address of a structure, which you know is globally unique for its lifetime (since no other structure will have the same address) and you structure your code so that it is only slept on by threads which are all equivalent, i.e. any of them can be woken up with the same effect. If you can't find or allocate a suitable address local only to your set of threads, that's a pretty good indication that they're not really equivalent for the purposes of wakeups, and you should re-think the way you're approaching the problem. > > If not, the most that should be done in the FreeBSD manpage is to > > clearly explain how not to introduce such a bug in a programmer's > > own code. > > Until the advent of wakeup_one, this wasn't a bug. wakeup works fine > under these circumstances. Advocating the use of wakeup was perhaps acceptable when uniprocessor machines were the norm. Now that we're in the 21st century and SMP kernels are ubiquitous, it is no longer responsible advice. > > As far as I'm aware, nowhere else in our manpages do we provide > > advice for the lazy programmer who cannot be bothered figuring out > > whether his code is correct and who just wants an expedient hack in > > case it's not. > > Maybe you should be a little less combative and consider that the > paradigms have changed. The whole idea of sleeping on memory > addresses is an expedient hack. The fact that people usually choose > different addresses means that even wakeup_one seldom has problems. > But most people aren't even aware of the issue. As I say, how would > you address the status quo? The status quo does not appear to require addressing. If you have evidence that this problem exists in the FreeBSD kernel, provide it so it can be fixed. Kris