From owner-freebsd-arch Thu Nov 15 6: 6:40 2001 Delivered-To: freebsd-arch@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id AF1E037B416; Thu, 15 Nov 2001 06:06:36 -0800 (PST) Received: from fledge.watson.org (ak82hjs7hex92j@fledge.pr.watson.org [192.0.2.3]) by fledge.watson.org (8.11.6/8.11.5) with SMTP id fAFE6Li87788; Thu, 15 Nov 2001 09:06:21 -0500 (EST) (envelope-from robert@fledge.watson.org) Date: Thu, 15 Nov 2001 09:06:20 -0500 (EST) From: Robert Watson X-Sender: robert@fledge.watson.org To: Matthew Dillon Cc: Alfred Perlstein , Greg Lehey , Bruce Evans , Peter Wemm , freebsd-arch@FreeBSD.ORG Subject: Re: cur{thread/proc}, or not. In-Reply-To: <200111150518.fAF5IMW18730@apollo.backplane.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 14 Nov 2001, Matthew Dillon wrote: > > :If you want to see why curproc sucks then please investigate what > :happens when you NDINIT a nameidata with another thread pointer > :other than your own, then perform a vn_open. kablooey! > : > :My recent addition of vn_open_cred and modification of nfs_lock.c > :was to get around this badness of the API. > : > :-- > :-Alfred Perlstein [alfred@freebsd.org] > > I'm not sure this is a fair argument. Just about all the code > in the system taking a struct thread * pointer assumes that the > thread is the current thread and so avoid much of the locking that > they would normally have to do on it. Passing some other thread > to a good chunk of this code will have very weird broken results. In my mind, that is in fact the primary argument *to* use curproc instead of passing around process and thread pointers. If the routine implicitly assumes curproc or curthread for locking/referencing purposes, either there needs to be a way to assert that: int foobar(struct thread *td, int arg) { PROMISE_ME_ITS_CURTHREAD_OR_DIE_HORRIBLY(td); arg += td->td_only_safe_to_read_without_lock_if_curthread; /* * Contrived example a little less contrived: * return (td->td_ucred->cr_uid == arg); */ return (arg); } or, we simply need to use curthread and curproc, and not allow anything else to be passed in. int foobar(int arg) { arg += curthread->td_only_safe_to_read_without_lock_if_curthread; return (arg); } Robert N M Watson FreeBSD Core Team, TrustedBSD Project robert@fledge.watson.org NAI Labs, Safeport Network Services To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message