Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Aug 2018 17:12:06 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r337466 - stable/11/sys/arm64/arm64
Message-ID:  <201808081712.w78HC62C088785@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Wed Aug  8 17:12:06 2018
New Revision: 337466
URL: https://svnweb.freebsd.org/changeset/base/337466

Log:
  MFC r336714:
  Simplify the arm64 implementation of pmap_mincore().

Modified:
  stable/11/sys/arm64/arm64/pmap.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm64/arm64/pmap.c
==============================================================================
--- stable/11/sys/arm64/arm64/pmap.c	Wed Aug  8 17:11:07 2018	(r337465)
+++ stable/11/sys/arm64/arm64/pmap.c	Wed Aug  8 17:12:06 2018	(r337466)
@@ -4683,76 +4683,45 @@ pmap_demote_l2(pmap_t pmap, pt_entry_t *l2, vm_offset_
 int
 pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *locked_pa)
 {
-	pd_entry_t *l1p, l1;
-	pd_entry_t *l2p, l2;
-	pt_entry_t *l3p, l3;
-	vm_paddr_t pa;
+	pt_entry_t *pte, tpte;
+	vm_paddr_t mask, pa;
+	int lvl, val;
 	bool managed;
-	int val;
 
 	PMAP_LOCK(pmap);
 retry:
-	pa = 0;
 	val = 0;
-	managed = false;
+	pte = pmap_pte(pmap, addr, &lvl);
+	if (pte != NULL) {
+		tpte = pmap_load(pte);
 
-	l1p = pmap_l1(pmap, addr);
-	if (l1p == NULL) /* No l1 */
-		goto done;
+		switch (lvl) {
+		case 3:
+			mask = L3_OFFSET;
+			break;
+		case 2:
+			mask = L2_OFFSET;
+			break;
+		case 1:
+			mask = L1_OFFSET;
+			break;
+		default:
+			panic("pmap_mincore: invalid level %d", lvl);
+		}
 
-	l1 = pmap_load(l1p);
-	if ((l1 & ATTR_DESCR_MASK) == L1_INVAL)
-		goto done;
-
-	if ((l1 & ATTR_DESCR_MASK) == L1_BLOCK) {
-		pa = (l1 & ~ATTR_MASK) | (addr & L1_OFFSET);
-		managed = (l1 & ATTR_SW_MANAGED) == ATTR_SW_MANAGED;
-		val = MINCORE_SUPER | MINCORE_INCORE;
-		if (pmap_page_dirty(l1))
-			val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER;
-		if ((l1 & ATTR_AF) == ATTR_AF)
-			val |= MINCORE_REFERENCED | MINCORE_REFERENCED_OTHER;
-		goto done;
-	}
-
-	l2p = pmap_l1_to_l2(l1p, addr);
-	if (l2p == NULL) /* No l2 */
-		goto done;
-
-	l2 = pmap_load(l2p);
-	if ((l2 & ATTR_DESCR_MASK) == L2_INVAL)
-		goto done;
-
-	if ((l2 & ATTR_DESCR_MASK) == L2_BLOCK) {
-		pa = (l2 & ~ATTR_MASK) | (addr & L2_OFFSET);
-		managed = (l2 & ATTR_SW_MANAGED) == ATTR_SW_MANAGED;
-		val = MINCORE_SUPER | MINCORE_INCORE;
-		if (pmap_page_dirty(l2))
-			val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER;
-		if ((l2 & ATTR_AF) == ATTR_AF)
-			val |= MINCORE_REFERENCED | MINCORE_REFERENCED_OTHER;
-		goto done;
-	}
-
-	l3p = pmap_l2_to_l3(l2p, addr);
-	if (l3p == NULL) /* No l3 */
-		goto done;
-
-	l3 = pmap_load(l2p);
-	if ((l3 & ATTR_DESCR_MASK) == L3_INVAL)
-		goto done;
-
-	if ((l3 & ATTR_DESCR_MASK) == L3_PAGE) {
-		pa = (l3 & ~ATTR_MASK) | (addr & L3_OFFSET);
-		managed = (l3 & ATTR_SW_MANAGED) == ATTR_SW_MANAGED;
 		val = MINCORE_INCORE;
-		if (pmap_page_dirty(l3))
+		if (lvl != 3)
+			val |= MINCORE_SUPER;
+		if (pmap_page_dirty(tpte))
 			val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER;
-		if ((l3 & ATTR_AF) == ATTR_AF)
+		if ((tpte & ATTR_AF) == ATTR_AF)
 			val |= MINCORE_REFERENCED | MINCORE_REFERENCED_OTHER;
-	}
 
-done:
+		managed = (tpte & ATTR_SW_MANAGED) == ATTR_SW_MANAGED;
+		pa = (tpte & ~ATTR_MASK) | (addr & mask);
+	} else
+		managed = false;
+
 	if ((val & (MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER)) !=
 	    (MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER) && managed) {
 		/* Ensure that "PHYS_TO_VM_PAGE(pa)->object" doesn't change. */



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