From owner-freebsd-arch@FreeBSD.ORG Sat Feb 2 20:47:57 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 6C84A16A421 for ; Sat, 2 Feb 2008 20:47:57 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 3872313C4E3 for ; Sat, 2 Feb 2008 20:47:57 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (unknown [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id DF15D17104 for ; Sat, 2 Feb 2008 20:47:55 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.2/8.14.2) with ESMTP id m12KltPG012081 for ; Sat, 2 Feb 2008 20:47:55 GMT (envelope-from phk@critter.freebsd.dk) To: arch@freebsd.org From: Poul-Henning Kamp Date: Sat, 02 Feb 2008 20:47:55 +0000 Message-ID: <12080.1201985275@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: Subject: 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: Sat, 02 Feb 2008 20:47:57 -0000 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 ? -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.