Subject: Re: Possible serious bug in NetBSD-1.6.1_RC2
To: Greg Oster <oster@cs.usask.ca>
From: Brian Buhrow <buhrow@lothlorien.nfbcal.org>
List: tech-kern
Date: 04/09/2003 23:57:26
	Hello.  Following up on my own post, I'd like to amend my description
of the problem.  Whenever the machine panics in pmap_change_attrs() it is
always as a result of being called from genfs_putpages in
/usr/src/sys/miscfs/genfs/genfs_vnops.c:1167.
Since there was a report of someone seeing this panic on the sparc port, it
seems like maybe there is a problem in the genfs_vnops.c file.

	while I was writing this, I looked again at the genfs_vnops.c file,
and think I might see the trouble.  Can anyone tell me why the following
patch to genfs_vnops.c might not be a good idea?  I see all other
references to pmap_clear_xxx() functions are protected by
uvm_lock_pageq() and uvm_unlock_pageq() calls.  

	I'll try this patch, but I'm still interested to know if folks think
this is a bad idea for some reason.
-thanks
-Brian

/*      $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;
 		} else {
 			needs_clean = FALSE;