From owner-freebsd-smp Sat Jan 12 17:30:42 2002 Delivered-To: freebsd-smp@freebsd.org Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by hub.freebsd.org (Postfix) with ESMTP id 5AF0637B404; Sat, 12 Jan 2002 17:30:38 -0800 (PST) Received: by elvis.mu.org (Postfix, from userid 1192) id 361CF10DDF9; Sat, 12 Jan 2002 17:30:38 -0800 (PST) Date: Sat, 12 Jan 2002 17:30:38 -0800 From: Alfred Perlstein To: smp@freebsd.org Cc: dillon@freebsd.org, tanimura@freebsd.org Subject: Re: fd locking. Message-ID: <20020112173038.H7984@elvis.mu.org> References: <20020112031144.F7984@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020112031144.F7984@elvis.mu.org>; from bright@mu.org on Sat, Jan 12, 2002 at 03:11:44AM -0800 Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org * Alfred Perlstein [020112 03:11] wrote: > I've got world building with these patches. > > http://people.freebsd.org/~alfred/fd.diff > > or > > http://people.freebsd.org/~alfred/fd.diff.gz I've been asked for an archetectural overview. Here we go: Locks: 1 mutex in each filedesc protects all the fields. protects "struct file" initialization, while a struct file is being changed from &badfileops -> &pipeops or something the filedesc should be locked. 1 mutex in each struct file protects the refcount fields. doesn't protect anything else. the flags used for garbage collection have been moved to f_gcflag which was the FILLER short, this doesn't need locking because the garbage collection is a single threaded container. could likely be made to use a pool mutex. 1 sx lock for the filelist. void fhold(struct file *fp); /* increments reference count on a file */ void fhold_locked(struct file *fp); /* like fhold but expects file to locked */ struct file *ffind_hold(struct thread *, int fd); /* finds the struct file in thread, adds one reference and returns it unlocked */ struct file *ffind_lock(struct thread *, int fd); /* ffind_hold, but returns file locked */ I still have to smp-safe Dillon's fget cruft, but I'll get to that asap. -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' Tax deductable donations for FreeBSD: http://www.freebsdfoundation.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message