Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Oct 2014 18:15:14 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r272667 - in stable/9/sys: amd64/amd64 i386/i386
Message-ID:  <201410061815.s96IFEUd025408@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Oct  6 18:15:13 2014
New Revision: 272667
URL: https://svnweb.freebsd.org/changeset/base/272667

Log:
  Account for the mapped pages in the kernel_pmap on x86 in
  pmap_mapdev().  The pmap_unmapdev() on stable/9 calls pmap_remove() to
  clear the range, which decrements kernel_pmap.pm_stats.resident_count.
  Misaccounting causes miscellaneous failures, since pmap_remove() tests
  the counter for zero and does nothing.
  
  This is direct commit to stable/9, since HEAD and stable/10 use vmem
  and do not utilize pmap_remove() etc.
  
  Based on the submission by:	Kohji Okuno <okuno.kohji at jp.panasonic.com>

Modified:
  stable/9/sys/amd64/amd64/pmap.c
  stable/9/sys/i386/i386/pmap.c

Modified: stable/9/sys/amd64/amd64/pmap.c
==============================================================================
--- stable/9/sys/amd64/amd64/pmap.c	Mon Oct  6 18:11:05 2014	(r272666)
+++ stable/9/sys/amd64/amd64/pmap.c	Mon Oct  6 18:15:13 2014	(r272667)
@@ -5040,6 +5040,9 @@ pmap_mapdev_attr(vm_paddr_t pa, vm_size_
 	pa = trunc_page(pa);
 	for (tmpsize = 0; tmpsize < size; tmpsize += PAGE_SIZE)
 		pmap_kenter_attr(va + tmpsize, pa + tmpsize, mode);
+	PMAP_LOCK(kernel_pmap);
+	pmap_resident_count_inc(kernel_pmap, OFF_TO_IDX(size));
+	PMAP_UNLOCK(kernel_pmap);
 	pmap_invalidate_range(kernel_pmap, va, va + tmpsize);
 	pmap_invalidate_cache_range(va, va + tmpsize);
 	return ((void *)(va + offset));

Modified: stable/9/sys/i386/i386/pmap.c
==============================================================================
--- stable/9/sys/i386/i386/pmap.c	Mon Oct  6 18:11:05 2014	(r272666)
+++ stable/9/sys/i386/i386/pmap.c	Mon Oct  6 18:15:13 2014	(r272667)
@@ -5066,10 +5066,14 @@ pmap_mapdev_attr(vm_paddr_t pa, vm_size_
 	size = roundup(offset + size, PAGE_SIZE);
 	pa = pa & PG_FRAME;
 
-	if (pa < KERNLOAD && pa + size <= KERNLOAD)
+	if (pa < KERNLOAD && pa + size <= KERNLOAD) {
 		va = KERNBASE + pa;
-	else
+	} else {
 		va = kmem_alloc_nofault(kernel_map, size);
+		PMAP_LOCK(kernel_pmap);
+		kernel_pmap->pm_stats.resident_count += OFF_TO_IDX(size);
+		PMAP_UNLOCK(kernel_pmap);
+	}
 	if (!va)
 		panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410061815.s96IFEUd025408>