Subject: Re: CVS commit: src/sys
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-kern
Date: 08/03/2006 16:40:47
On Aug 3, 2006, at 3:51 PM, YAMAMOTO Takashi wrote:
>> On Sat, Jul 22, 2006 at 03:36:08PM +0900, YAMAMOTO Takashi wrote:
>>
>>>> Log Message:
>>>> - Use the LWP cached credentials where sane.
>>>> - Minor cosmetic changes.
>>>
>>> how about using kauth_cred_get()?
>>
>> Could you provide some context, please?
>
> instead of "curlwp->l_cred".
>
>> kauth_cred_get() embeds use of curlwp at a fairly low level. I
>> can't come
>> up with solid arguments against curlwp other than it could be
>> slower than
>> passing an lwp into a function as an argument, and it discourages
>> caching
>> the address locally. Anyone?
>
> i'm not sure if this kind of micro-optimization makes much sense.
> i'm not sure which of using curlwp or passing an lwp pointer around is
> generally faster. if the latter is significantly preferable,
> how about kauth_cred_get_lwp which takes an lwp pointer and KASSERT
> that it's curlwp?
> given that it's generally unsafe to use l->l_cred unless l == curlwp,
> having raw "l->l_cred" sprinkled is not a good idea, IMO.
...and actually, if you want to cache something, do:
kauth_cred_t cred;
...
cred = kauth_cred_get();
...rather than caching the address of the lwp.
-- thorpej