From owner-freebsd-current Mon Feb 11 17:22:19 2002 Delivered-To: freebsd-current@freebsd.org Received: from hawk.mail.pas.earthlink.net (hawk.mail.pas.earthlink.net [207.217.120.22]) by hub.freebsd.org (Postfix) with ESMTP id D107737B416; Mon, 11 Feb 2002 17:22:08 -0800 (PST) Received: from pool0022.cvx40-bradley.dialup.earthlink.net ([216.244.42.22] helo=mindspring.com) by hawk.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 16aRe1-0007eW-00; Mon, 11 Feb 2002 17:22:05 -0800 Message-ID: <3C686E1E.84A42678@mindspring.com> Date: Mon, 11 Feb 2002 17:21:34 -0800 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Julian Elischer Cc: Alfred Perlstein , jhb@freebsd.org, bde@freebsd.org, current@freebsd.org Subject: Re: ucred holding patch, BDE version References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Julian Elischer wrote: > > This makes little sense to me. > > > > Maybe I'm missing something, but by virtue of ownership we don't > > have to worry about the ucred's refcount on entry into the kernel > > because it is the owner and no one else is allowed to change our > > privledges besideds ourselves via set[ug]id(). > > multiple threads can do it.. > > The proclock is needed to get the reference, > guarding against other threads, and giant is needed fo rnot to free it > because if it reaches a refcount of 0 it needs to call free(). (which john > assures me needs Giant at this time). > We could avoid the proclock with judicious use of an atomic refcount > incrementing method. > > When Giant goes away it won't be so bad but it will STILL be quicker to > not drop it across userland. The "multiple threads" argument is bogus, since the calls to [gs]et[ug]id() are on a per process, not a per thread basis. An argument which *may* not be bogus (I am unconvinced) is that creds are immutable once instanced, and that the calls to [gs]et[ug]id() instance a new cred and replace, rather than changing an existing cred (this logically follows from credential inheritance, or the first set call would change the cred used by "init" and all other processes). Personally, I still do not understand the need to have a cred reference per thread, the only thing that makes any sense about that is to optimize the degenerate case of a daemon that makes calls as another ID, on behalf of a lot of users (or, sequentially, at least, different users). One example of such a program would be SAMBA (but *not* NFS, due to "access" semantics on objects based on path component access exclusion by credential not being an effective mechanism for NFS file handles). I think that you would need to have [gs]et[ug]id() be on a per thread basis for this to be an efficiency, and I think trying to do this pessimizes everything else. My gut tells me that creds should be per process, and that the references to them should be taken sparingly, and then only if a need can be justified, rather than "just in case some day". Kirk at one time called vnodes "the structure that ate the kernel"; he was wrong: it was creds. Perhaps this dicsussion is enough impetus to justify revisiting the atomic_t type definitions, which would be useful as reference counted hold/release mechanisms that would obviate the need for locks here? This would at least let you defer getting rid of the per thread cred instances until later. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message