Subject: Re: kmem_map panic status...
To: None <phiber@radicalmedia.com>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: port-sun3
Date: 11/03/2000 19:23:21
In <20001103032403.F12144@radicalmedia.com>
phiber@radicalmedia.com wrote:

> So what's the current status of the kmem_map panic problem?  Seems like you
> had tracked it down and were about to fix it.  Were you successful?  If so,

I believe it was fixed.

> would you mind making a diff available against 1.4.2 for those of us who don't
> live life in the fast lane?

Here it is. (Mostly same with diffs between rev 1.54 and 1.55)
I have not tried on 1.4.x, but it should work.
---
Izumi Tsutsui
tsutsui@ceres.dti.ne.jp


--- pmap.c.orig	Fri Nov  3 18:49:37 2000
+++ pmap.c	Fri Nov  3 18:53:29 2000
@@ -364,9 +364,11 @@
 #define	NUM_KERN_PTES	(KVAS_SIZE >> MMU_TIC_SHIFT)
 
 /*************************** MISCELANEOUS MACROS *************************/
-#define PMAP_LOCK()	;	/* Nothing, for now */
-#define PMAP_UNLOCK()	;	/* same. */
-#define	NULL 0
+#define pmap_lock(pmap) simple_lock(&pmap->pm_lock)
+#define pmap_unlock(pmap) simple_unlock(&pmap->pm_lock)
+#define pmap_add_ref(pmap) ++pmap->pm_refcount
+#define pmap_del_ref(pmap) --pmap->pm_refcount
+#define pmap_refcount(pmap) pmap->pm_refcount
 
 static INLINE void *      mmu_ptov __P((vm_offset_t pa));
 static INLINE vm_offset_t mmu_vtop __P((void * va));
@@ -843,6 +845,7 @@
 	kernel_pmap.pm_a_tmgr = NULL;
 	kernel_pmap.pm_a_phys = kernAphys;
 	kernel_pmap.pm_refcount = 1; /* always in use */
+	simple_lock_init(&kernel_pmap.pm_lock);
 
 	kernel_crp.rp_attr = MMU_LONG_DTE_LU | MMU_DT_LONG;
 	kernel_crp.rp_addr = kernAphys;
@@ -2560,6 +2563,8 @@
 	bzero(pmap, sizeof(struct pmap));
 	pmap->pm_a_tmgr = NULL;
 	pmap->pm_a_phys = kernAphys;
+	pmap->pm_refcount = 1;
+	simple_lock_init(&pmap->pm_lock);
 }
 
 /* pmap_release				INTERFACE
@@ -2622,9 +2627,9 @@
 	if (pmap == NULL)
 		return;
 
-	/* pmap_lock(pmap); */
-	pmap->pm_refcount++;
-	/* pmap_unlock(pmap); */
+	pmap_lock(pmap);
+	pmap_add_ref(pmap);
+	pmap_unlock(pmap);
 }
 
 /* pmap_dereference			INTERNAL
@@ -2641,9 +2646,9 @@
 	if (pmap == NULL)
 		return 0;
 
-	/* pmap_lock(pmap); */
-	rtn = --pmap->pm_refcount;
-	/* pmap_unlock(pmap); */
+	pmap_lock(pmap);
+	rtn = pmap_del_ref(pmap);
+	pmap_unlock(pmap);
 
 	return rtn;
 }