Possible patch for vm/vm_glue.c

John Baldwin jhb at FreeBSD.org
Mon Aug 11 11:32:37 PDT 2003


On 11-Aug-2003 Rui Lopes wrote:
> Hello,
> 
> I've been reading vm_glue.c and I think I've found a bug regarding the
> lock of `proc.p_sflag' inside `scheduler' function.
> 
>>From proc.h, "int p_sflag; /* (j) PS_* flags. */" and "(j) - locked by
> sched_lock mtx";  but the access is done without having the lock.
> 
> 
> Take a look at the attached patch and tell me if this is ok.
> 
> Patch made against "$FreeBSD: src/sys/vm/vm_glue.c,v 1.172 2003/05/13
> 20:36:02 jhb Exp $", but this is also present in current 1.182.

The lock isn't needed in this case for these flags because the proc
lock is already held and for these flags, both the proc lock and
sched lock are always held when they are set or cleared, so only one
of those locks have to be held to check the flags.

-- 

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


More information about the freebsd-hackers mailing list