Subject: Re: kern/21107: genfs_putpages modifies page tables without proper locking
To: Brian Buhrow <buhrow@lothlorien.nfbcal.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: netbsd-bugs
Date: 04/15/2003 12:33:59
On Fri, Apr 11, 2003 at 11:55:17PM -0700, Brian Buhrow wrote:
> 	
> 	/usr/src/sys/miscfs/genfs/genfs_vnops.c:genfs_putpages() attempts to
> clean pages with the pmap_clear_modify() routine without locking the uvm
> page queues.  On some systems, including I386 and Sparc architectures, this
> results in intermittent illegal page faults which panic the system.
> 	The following patches for the 1.6 branch and the current branch,
> respectively, fix this problem.  On my production machine, uptimes before
> the patch were measured in minutes and hours.  After the patch, the machine
> has been completely stable.
> -Brian
> 
> [1.6 branc patch...]
> /*      $NetBSD: genfs_vnops.c,v 1.63.2.2 2002/10/23 12:18:12 lukem Exp $
> */
> --- genfs_vnops.c.fcs	Wed Oct 23 05:18:12 2002
> +++ genfs_vnops.c	Wed Apr  9 23:48:18 2003
> @@ -1164,8 +1164,10 @@
>  			pmap_page_protect(pg, VM_PROT_NONE);
>  		}
>  		if (flags & PGO_CLEANIT) {
> +			uvm_lock_pageq();
>  			needs_clean = pmap_clear_modify(pg) ||
>  			    (pg->flags & PG_CLEAN) == 0;
> +			uvm_unlock_pageq();
>  			pg->flags |= PG_CLEAN;

Hum, while this probably correct, I can't see why it makes a difference in
your case: uvm_lock_pageq() is just:
uvm_page.h:#define uvm_lock_pageq()     simple_lock(&uvm.pageqlock)
and simple_lock() is, for the non-MP non-LOCKDEBUG case
lock.h:#define  simple_lock(alp)        /* nothing */

Are you using MULTIPROCESSOR or LOCKDEBUG in your kernel config file ?

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
     NetBSD: 24 ans d'experience feront toujours la difference
--