From owner-freebsd-arch@FreeBSD.ORG Sun Feb 3 05:26:15 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A49A816A417 for ; Sun, 3 Feb 2008 05:26:15 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outN.internet-mail-service.net (outN.internet-mail-service.net [216.240.47.237]) by mx1.freebsd.org (Postfix) with ESMTP id 8A79A13C46A for ; Sun, 3 Feb 2008 05:26:15 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.40) with ESMTP; Sat, 02 Feb 2008 21:26:14 -0800 Received: from julian-mac.elischer.org (localhost [127.0.0.1]) by idiom.com (Postfix) with ESMTP id 5E6441270B2; Sat, 2 Feb 2008 21:26:14 -0800 (PST) Message-ID: <47A55075.2090706@elischer.org> Date: Sat, 02 Feb 2008 21:26:13 -0800 From: Julian Elischer User-Agent: Thunderbird 2.0.0.9 (Macintosh/20071031) MIME-Version: 1.0 To: Poul-Henning Kamp References: <12080.1201985275@critter.freebsd.dk> In-Reply-To: <12080.1201985275@critter.freebsd.dk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: arch@freebsd.org Subject: Re: adding general purpose mtx+cv to kthread X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Feb 2008 05:26:15 -0000 Poul-Henning Kamp wrote: > The select(2) system call has a dirty little secret data structure > (struct seltd) which it hangs off the kthread (->td_sel), amongst > the reasons for this is to avoid a mtx_init() and cv_init() and associated > destroy calls with each call to select(2). > > I'm working on an enhancement to sendfile(2) that has the exact same > need for a mtx+cv combo and the question is how many other such > we have, once we get through the code. > > Various solutions present themselves, from swallowing the overhead > for sendfile(2) since it's probably delta anyway over sharing selects > data structure (safe for the locks, since both syscalls are stateless) > to what seems most sensible to me: > > Add a general purpose mtx+cv to struct kthread for use by syscalls > that need to keep track of things and sleep on stuff. > > This wouldn't make the seltd structure go away, it contains other > stuff as well, it would just eliminate the mtx+cv combo from it. > > Any comment or insights ? [...] void *td_syscal_priv; /* valid for duration of syscall only */ [...] seems a reasonably useful thing