NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-hppa/56849: Wacko kernel memory accounting in current/hppa



Candidate fix...

Nick
Index: sys/arch/hppa/hppa/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/hppa/hppa/pmap.c,v
retrieving revision 1.116
diff -u -p -r1.116 pmap.c
--- sys/arch/hppa/hppa/pmap.c	9 Apr 2022 23:38:32 -0000	1.116
+++ sys/arch/hppa/hppa/pmap.c	24 May 2022 05:49:05 -0000
@@ -1109,7 +1109,7 @@ pmap_bootstrap(vaddr_t vstart)
 		else if (va == uvm_lwp_getuarea(&lwp0) + USPACE - PAGE_SIZE)
 			prot = UVM_PROT_NONE;
 #endif
-		pmap_kenter_pa(va, va, prot, 0);
+		pmap_kenter_pa(va, va, prot, PMAP_DIRECTMAP);
 	}
 
 	/* XXXNH update */
@@ -1990,8 +1993,11 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v
 	    pmap_prot(pmap_kernel(), prot & VM_PROT_ALL));
 	if (IS_IOPAGE_P(pa) || (flags & PMAP_NOCACHE))
 		pte |= PTE_PROT(TLB_UNCACHEABLE);
-	pmap_kernel()->pm_stats.wired_count++;
-	pmap_kernel()->pm_stats.resident_count++;
+
+	if ((flags & PMAP_DIRECTMAP) == 0) {
+		pmap_kernel()->pm_stats.wired_count++;
+		pmap_kernel()->pm_stats.resident_count++;
+	}
 	if (opte)
 		pmap_pte_flush(pmap_kernel(), va, opte);
 
@@ -2071,6 +2077,9 @@ pmap_kremove(vaddr_t va, vsize_t size)
 		pmap_pte_flush(pmap, va, pte);
 		pmap_pte_set(pde, va, 0);
 
+		pmap->pm_stats.wired_count--;
+		pmap->pm_stats.resident_count--;
+
 		pg = pmap_initialized ? PHYS_TO_VM_PAGE(PTE_PAGE(pte)) : NULL;
 		if (pg != NULL) {
 			struct vm_page_md * const md = VM_PAGE_TO_MD(pg);
Index: sys/arch/hppa/include/pmap.h
===================================================================
RCS file: /cvsroot/src/sys/arch/hppa/include/pmap.h,v
retrieving revision 1.40
diff -u -p -r1.40 pmap.h
--- sys/arch/hppa/include/pmap.h	14 Mar 2020 14:05:42 -0000	1.40
+++ sys/arch/hppa/include/pmap.h	24 May 2022 05:49:05 -0000
@@ -72,6 +72,8 @@ struct pmap {
 #define	HPPA_MAX_PID	0xfffa
 #define	HPPA_SID_MAX	0x7ffd
 
+#define	PMAP_DIRECTMAP	0x10000000 /* kenter_pa */
+
 /*
  * DON'T CHANGE THIS - this is assumed in lots of places.
  */


Home | Main Index | Thread Index | Old Index