What type of locking is needed for ss/sidtab.c?

John Baldwin john at baldwin.cx
Wed Jul 24 14:35:45 GMT 2002


On 24-Jul-2002 Hiten Pandya wrote:
> On Tue, Jul 23, 2002 at 04:56:16PM -0700, Chris Wright wrote the words in effect of:
>> The Linux case currently does:
>> 
>> #define SIDTAB_LOCK(s, flags) spin_lock_irqsave(&s->lock,flags)
>> #define SIDTAB_UNLOCK(s,flags) spin_unlock_irqrestore(&s->lock,flags)
> 
> OK.  This means that the use of Spin locks should suffice in FreeBSD.  I
> guess the safe_up() and safe_down() stuff in services_private.h is
> deprecated, because I did a google search and it came up with diffs
> which removed it.

No, in FreeBSD you should use default mutexes.  spin mutexes should almost
never be used.  AFAIK, Linux doesn't have mutexes that block when they are
contested and doing priority propagation, etc. just spin locks.

>> This assumes non-sleeping kmalloc in sidtab_get_sids().
> 
> OK.  I have given a _try_ to add/port the locking stuff in the FreeBSD
> case for the security server.  I am not sure how correct it is, but I
> done many checks of what I was up to; patch is attached with this mail.

Well, you would need M_NOWAIT to malloc() to get it to be nonblocking,
or rework the algo to malloc() before you acquire the locks.

-- 

John Baldwin <john at baldwin.cx>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-discuss" in the body of the message



More information about the trustedbsd-discuss mailing list