From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754984AbYKNTeh (ORCPT ); Fri, 14 Nov 2008 14:34:37 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754274AbYKNTeZ (ORCPT ); Fri, 14 Nov 2008 14:34:25 -0500 Received: from mx1.redhat.com ([66.187.233.31]:36543 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754279AbYKNTeZ (ORCPT ); Fri, 14 Nov 2008 14:34:25 -0500 Date: Fri, 14 Nov 2008 14:34:11 -0500 (EST) From: Mikulas Patocka X-X-Sender: mpatocka@hs20-bc2-1.build.redhat.com To: Alan Cox cc: linux-kernel@vger.kernel.org, mingo@elte.hu, rml@tech9.net, Alasdair G Kergon , Milan Broz Subject: Re: Active waiting with yield() In-Reply-To: <20081114190616.30dd273e@lxorguk.ukuu.org.uk> Message-ID: References: <20081114190616.30dd273e@lxorguk.ukuu.org.uk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 14 Nov 2008, Alan Cox wrote: > > * driver unload --- check the count of outstanding requests and call > > yield() repeatedly until it goes to zero, then unload. > > Use a wakeup when the request count hits zero > > > * reduced size of data structures (and reduced cache footprint for the hot > > path that actually processes requests) > > The CPU will predict the non-wakeup path if that is normal. You can even > make the wakeup use something like > > if (exiting & count == 0) > > to get the prediction righ > > > The downside of yield is slower unloading of the driver by few tens of > > miliseconds, but the user doesn't really care about fractions of a second > > when unloading drivers. > > And more power usage, plus extremely rude behaviour when virtualising. How these unlikely cases can be rude? If I have a race condition that gets triggered just for one user in the world when repeatedly loading & unloading a driver for an hour, and I use yield() to solve it, what's wrong with it? A wait queue increases cache footprint for every user. (even if I use preallocated hashed wait queue, it still eats a cacheline to access it and find out that it's empty) Mikulas > There are cases you have to use cpu_relax/spins or yield simply because > the hardware doesn't feel like providing interrupts when you need them, > but for the general case its best to use proper sleeping. > > Remember also you can use a single wait queue for an entire driver for > obscure happenings like unloads. > > Alan >