Date: 11 Aug 2003 13:10:24 +0100 From: Rui Lopes <rui@ruilopes.com> To: freebsd-hackers@freebsd.org Subject: Possible patch for vm/vm_glue.c Message-ID: <1060603824.650.12.camel@localhost>
next in thread | raw e-mail | index | archive | help
--=-yEYvogjQ9gwJbuBvo2E9 Content-Type: text/plain Content-Transfer-Encoding: 7bit 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. Regards, Rui Lopes --=-yEYvogjQ9gwJbuBvo2E9 Content-Disposition: attachment; filename=vm_glue.c.patch Content-Type: text/plain; name=vm_glue.c.patch; charset= Content-Transfer-Encoding: 7bit # we should only access `proc.p_sflag' when `sched_lock' is locked. # From proc.h: # int p_sflag; /* (j) PS_* flags. */ # and j means: "(j) - locked by sched_lock mtx" # -- Rui Lopes <rui@ruilopes.com> --- vm_glue.c.orig Mon Aug 11 12:41:33 2003 +++ vm_glue.c Mon Aug 11 12:45:58 2003 @@ -596,10 +596,11 @@ sx_slock(&allproc_lock); FOREACH_PROC_IN_SYSTEM(p) { struct ksegrp *kg; + mtx_lock_spin(&sched_lock); if (p->p_sflag & (PS_INMEM | PS_SWAPPINGOUT | PS_SWAPPINGIN)) { + mtx_unlock_spin(&sched_lock); continue; } - mtx_lock_spin(&sched_lock); FOREACH_THREAD_IN_PROC(p, td) { /* * An otherwise runnable thread of a process --=-yEYvogjQ9gwJbuBvo2E9--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1060603824.650.12.camel>