From owner-freebsd-arch@FreeBSD.ORG Mon Jun 5 17:14:09 2006 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D9C3316BFE3 for ; Mon, 5 Jun 2006 17:14:09 +0000 (UTC) (envelope-from guomingyan@gmail.com) Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6B35243D80 for ; Mon, 5 Jun 2006 17:13:54 +0000 (GMT) (envelope-from guomingyan@gmail.com) Received: by wx-out-0102.google.com with SMTP id i31so772055wxd for ; Mon, 05 Jun 2006 10:13:53 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=AywXaRc6bYrktjsvAyCYmDtVhJ8yIlpotBJcSDeQILleaLrz8RaQpFAPfZVYDt7Tpg9mjRb59Xzbv4lr/5Z1aGaUVARM7Y1OV8SBku90evdqFbOLZaXl2bw1klXjs8Wv4uYSTPsnH5qSGA46lTJdswkcAqqU6gVGPOAuCJjcJoU= Received: by 10.70.59.6 with SMTP id h6mr6283148wxa; Mon, 05 Jun 2006 10:13:53 -0700 (PDT) Received: by 10.70.39.18 with HTTP; Mon, 5 Jun 2006 10:13:53 -0700 (PDT) Message-ID: <1fa17f810606051013m38cf08d7i82b6b11c7b119686@mail.gmail.com> Date: Tue, 6 Jun 2006 01:13:53 +0800 From: MingyanGuo To: "Robert Watson" In-Reply-To: <20060605165355.L50057@fledge.watson.org> MIME-Version: 1.0 References: <1fa17f810606050044k2847e4a2i150eb934ed84006f@mail.gmail.com> <1fa17f810606050608l5bd2ec5ch37663375f6fa5b64@mail.gmail.com> <20060605163559.N50057@fledge.watson.org> <448450FD.4030709@FreeBSD.org> <20060605165355.L50057@fledge.watson.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: delphij@gmail.com, freebsd-arch@freebsd.org Subject: Re: Why use `thread' as an argument of Syscalls? 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: Mon, 05 Jun 2006 17:14:19 -0000 On 6/5/06, Robert Watson wrote: > > > On Mon, 5 Jun 2006, Suleiman Souhlal wrote: > > > Robert Watson wrote: > >> > >> On Mon, 5 Jun 2006, Daniel Eischen wrote: > >> > >>>> They are the same questions, I think ;-). Now would you please > explain > >>>> "why use `proc' as an argument of Syscalls" to me :)? I've read > some > >>>> source code of the kernel, but no comments about it found. > >>> > >>> I don't know. Convention? It makes sense to me. > >> > >> Certainly consistency. Most system calls do actually use the argument > at > >> some point -- be it to look up a file descriptor, access control, or > the > >> like, and the calling context has it for free and in-hand anyway. > > > > But couldn't they just use curthread/curproc? > > In the past, in micro-benchmarking, I've measured a small performance hit > from > using per-cpu variables over variables already in the stack. However, > that > was quite a while ago, and I'm not entirely convinced the test results > were > valid. In the general case, it's pretty helpful to be able to pass in, > for > example, explicit credential references, as it means you can do acess > control > checks, auditing, accounting, etc, against arbitrary credentials rather > than > always against curthread->td_ucred. In a number of places, we pass > threads > down the stack where we mean to pass credentials, such as at several spots > in > the network stack. There are also places where the process is passed > around > so it can become a later argument to lockmgr() locking primitives, and > since > those are decreasingly used, the references are increasingly unnecessary. > > Robert N M Watson > Thanks. MingyanGuo -- Three passions, simple but overwhelmingly strong, have governed my life: the longing for love, the search for knowledge, and unbearable pity for the suffering of mankind. ---------Bertrand Russell