From owner-freebsd-current@FreeBSD.ORG Sun Jan 30 21:23:37 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 13C1516A4D0 for ; Sun, 30 Jan 2005 21:23:37 +0000 (GMT) Received: from relay02.pair.com (relay02.pair.com [209.68.5.16]) by mx1.FreeBSD.org (Postfix) with SMTP id 615A243D4C for ; Sun, 30 Jan 2005 21:23:36 +0000 (GMT) (envelope-from silby@silby.com) Received: (qmail 70142 invoked from network); 30 Jan 2005 21:23:35 -0000 Received: from unknown (HELO localhost) (unknown) by unknown with SMTP; 30 Jan 2005 21:23:35 -0000 X-pair-Authenticated: 209.68.2.70 Date: Sun, 30 Jan 2005 15:23:34 -0600 (CST) From: Mike Silbersack To: Colin Percival In-Reply-To: <41FD24C2.5070700@freebsd.org> Message-ID: <20050130151427.U59844@odysseus.silby.com> References: <41FD24C2.5070700@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Mailman-Approved-At: Mon, 31 Jan 2005 12:46:43 +0000 cc: Poul-Henning Kamp cc: Robert Watson cc: current@freebsd.org Subject: Re: tcp_isn_tick() / dummynet() callout madness ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Jan 2005 21:23:37 -0000 On Sun, 30 Jan 2005, Colin Percival wrote: > Robert Watson wrote: >> since the callout_reset() is one of the more >> expensive parts of this code, Colin has been looking at some locking >> optimizations to lower the cost. > > To elaborate somewhat: I think I can avoid the spinlock cost when > callouts reset themselves (which is the case here). However, while > this will reduce the time spent in the callouts themselves, it's > really only a 50% solution -- softclock locks and unlocks the callout > spin lock each time it launches a callout. If we're spending 5% of > our cpu time in these two callouts, then they're actually responsible > for using 10% of our cpu time; I think I can cut that in half, but in > the end we can't avoid the cost of a mtx_lock_spin / mtx_unlock_spin > pair (in softclock) for each callout. > > Colin Percival Is there any way to get around that cost with some relatively simple change to the callout API? Just a few places in the kernel account for most of the use of callouts, so even if a rewrite of those would be necessary, it should pay off. Or, potentially crazy idea here; instead of incurring the cost of a spinlock to remove a callout entry from a bucket, could you do some atomic operation to mark that entry as done, and then only remove those entries once and a while? I guess if spinlocks weren't so expensive, this wouldn't be a big deal... why do they need to be spinlocks? :) Mike "Silby" Silbersack