Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jul 2019 03:47:27 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350313 - in head/sys: conf powerpc/aim powerpc/ps3 powerpc/pseries
Message-ID:  <201907250347.x6P3lRpT006278@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Thu Jul 25 03:47:27 2019
New Revision: 350313
URL: https://svnweb.freebsd.org/changeset/base/350313

Log:
  powerpc/pmap64: Make moea64 statistics optional
  
  Summary:
  It turns out statistics accounting is very expensive in the pmap driver,
  and doesn't seem necessary in the common case.  Make this optional
  behind a MOEA64_STATS #define, which one can set if they really need
  statistics.
  
  This saves ~7-8% on buildworld time on a POWER9.
  
  Found by bdragon.
  
  Reviewed by:	luporl
  Differential Revision: https://reviews.freebsd.org/D20903

Modified:
  head/sys/conf/options.powerpc
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/mmu_oea64.h
  head/sys/powerpc/aim/moea64_native.c
  head/sys/powerpc/ps3/mmu_ps3.c
  head/sys/powerpc/pseries/mmu_phyp.c

Modified: head/sys/conf/options.powerpc
==============================================================================
--- head/sys/conf/options.powerpc	Thu Jul 25 00:07:10 2019	(r350312)
+++ head/sys/conf/options.powerpc	Thu Jul 25 03:47:27 2019	(r350313)
@@ -19,6 +19,7 @@ GFB_DEBUG		opt_gfb.h
 GFB_NO_FONT_LOADING	opt_gfb.h
 GFB_NO_MODE_CHANGE	opt_gfb.h
 
+MOEA64_STATS		opt_pmap.h
 MPC85XX			opt_platform.h
 POWERMAC		opt_platform.h
 PS3			opt_platform.h

Modified: head/sys/powerpc/aim/mmu_oea64.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea64.c	Thu Jul 25 00:07:10 2019	(r350312)
+++ head/sys/powerpc/aim/mmu_oea64.c	Thu Jul 25 03:47:27 2019	(r350313)
@@ -200,6 +200,7 @@ static u_int	moea64_vsid_bitmap[NVSIDS / VSID_NBPW];
 
 static boolean_t moea64_initialized = FALSE;
 
+#ifdef MOEA64_STATS
 /*
  * Statistics.
  */
@@ -218,6 +219,7 @@ SYSCTL_INT(_machdep, OID_AUTO, moea64_pvo_enter_calls,
     &moea64_pvo_enter_calls, 0, "");
 SYSCTL_INT(_machdep, OID_AUTO, moea64_pvo_remove_calls, CTLFLAG_RD,
     &moea64_pvo_remove_calls, 0, "");
+#endif
 
 vm_offset_t	moea64_scratchpage_va[2];
 struct pvo_entry *moea64_scratchpage_pvo[2];
@@ -1434,7 +1436,7 @@ moea64_enter(mmu_t mmu, pmap_t pmap, vm_offset_t va, v
 
 				/* If not in page table, reinsert it */
 				if (MOEA64_PTE_SYNCH(mmu, oldpvo) < 0) {
-					moea64_pte_overflow--;
+					STAT_MOEA64(moea64_pte_overflow--);
 					MOEA64_PTE_INSERT(mmu, oldpvo);
 				}
 
@@ -2522,7 +2524,7 @@ moea64_pvo_enter(mmu_t mmu, struct pvo_entry *pvo, str
 
 	PMAP_LOCK_ASSERT(pvo->pvo_pmap, MA_OWNED);
 
-	moea64_pvo_enter_calls++;
+	STAT_MOEA64(moea64_pvo_enter_calls++);
 
 	/*
 	 * Add to pmap list
@@ -2557,7 +2559,7 @@ moea64_pvo_enter(mmu_t mmu, struct pvo_entry *pvo, str
 		panic("moea64_pvo_enter: overflow");
 	}
 
-	moea64_pvo_entries++;
+	STAT_MOEA64(moea64_pvo_entries++);
 
 	if (pvo->pvo_pmap == kernel_pmap)
 		isync();
@@ -2656,8 +2658,8 @@ moea64_pvo_remove_from_page_locked(mmu_t mmu, struct p
 		}
 	}
 
-	moea64_pvo_entries--;
-	moea64_pvo_remove_calls++;
+	STAT_MOEA64(moea64_pvo_entries--);
+	STAT_MOEA64(moea64_pvo_remove_calls++);
 }
 
 static void

Modified: head/sys/powerpc/aim/mmu_oea64.h
==============================================================================
--- head/sys/powerpc/aim/mmu_oea64.h	Thu Jul 25 00:07:10 2019	(r350312)
+++ head/sys/powerpc/aim/mmu_oea64.h	Thu Jul 25 03:47:27 2019	(r350313)
@@ -30,6 +30,8 @@
 #ifndef _POWERPC_AIM_MMU_OEA64_H
 #define _POWERPC_AIM_MMU_OEA64_H
 
+#include "opt_pmap.h"
+
 #include <machine/mmuvar.h>
 
 extern mmu_def_t oea64_mmu;
@@ -72,8 +74,13 @@ void		moea64_late_bootstrap(mmu_t mmup, vm_offset_t ke
  * Statistics
  */
 
+#ifdef MOEA64_STATS
 extern u_int	moea64_pte_valid;
 extern u_int	moea64_pte_overflow;
+#define STAT_MOEA64(x)	x
+#else
+#define	STAT_MOEA64(x) ((void)0)
+#endif
 
 /*
  * State variables

Modified: head/sys/powerpc/aim/moea64_native.c
==============================================================================
--- head/sys/powerpc/aim/moea64_native.c	Thu Jul 25 00:07:10 2019	(r350312)
+++ head/sys/powerpc/aim/moea64_native.c	Thu Jul 25 03:47:27 2019	(r350313)
@@ -332,7 +332,7 @@ moea64_pte_unset_native(mmu_t mmu, struct pvo_entry *p
 	if ((be64toh(pt->pte_hi & LPTE_AVPN_MASK)) !=
 	    (properpt.pte_hi & LPTE_AVPN_MASK)) {
 		/* Evicted */
-		moea64_pte_overflow--;
+		STAT_MOEA64(moea64_pte_overflow--);
 		rw_runlock(&moea64_eviction_lock);
 		return (-1);
 	}
@@ -352,7 +352,7 @@ moea64_pte_unset_native(mmu_t mmu, struct pvo_entry *p
 	rw_runlock(&moea64_eviction_lock);
 
 	/* Keep statistics */
-	moea64_pte_valid--;
+	STAT_MOEA64(moea64_pte_valid--);
 
 	return (ptelo & (LPTE_CHG | LPTE_REF));
 }
@@ -656,8 +656,8 @@ moea64_insert_to_pteg_native(struct lpte *pvo_pt, uint
 		    (ADDR_API_SHFT64 - ADDR_PIDX_SHFT);
 		PTESYNC();
 		TLBIE(va);
-		moea64_pte_valid--;
-		moea64_pte_overflow++;
+		STAT_MOEA64(moea64_pte_valid--);
+		STAT_MOEA64(moea64_pte_overflow++);
 	}
 
 	/*
@@ -670,7 +670,7 @@ moea64_insert_to_pteg_native(struct lpte *pvo_pt, uint
 	PTESYNC();
 
 	/* Keep statistics */
-	moea64_pte_valid++;
+	STAT_MOEA64(moea64_pte_valid++);
 
 	return (k);
 }

Modified: head/sys/powerpc/ps3/mmu_ps3.c
==============================================================================
--- head/sys/powerpc/ps3/mmu_ps3.c	Thu Jul 25 00:07:10 2019	(r350312)
+++ head/sys/powerpc/ps3/mmu_ps3.c	Thu Jul 25 03:47:27 2019	(r350313)
@@ -224,14 +224,14 @@ mps3_pte_unset(mmu_t mmu, struct pvo_entry *pvo)
 	mtx_lock(&mps3_table_lock);
 	refchg = mps3_pte_synch_locked(pvo);
 	if (refchg < 0) {
-		moea64_pte_overflow--;
+		STAT_MOEA64(moea64_pte_overflow--);
 		mtx_unlock(&mps3_table_lock);
 		return (-1);
 	}
 	/* XXX: race on RC bits between unset and sync. Anything to do? */
 	lv1_write_htab_entry(mps3_vas_id, pvo->pvo_pte.slot, 0, 0);
 	mtx_unlock(&mps3_table_lock);
-	moea64_pte_valid--;
+	STAT_MOEA64(moea64_pte_valid--);
 
 	return (refchg & (LPTE_REF | LPTE_CHG));
 }
@@ -272,13 +272,13 @@ mps3_pte_insert(mmu_t mmu, struct pvo_entry *pvo)
 		pvo->pvo_vaddr |= PVO_HID;
 	pvo->pvo_pte.slot = index;
 
-	moea64_pte_valid++;
+	STAT_MOEA64(moea64_pte_valid++);
 
 	if (evicted.pte_hi) {
 		KASSERT((evicted.pte_hi & (LPTE_WIRED | LPTE_LOCKED)) == 0,
 		    ("Evicted a wired PTE"));
-		moea64_pte_valid--;
-		moea64_pte_overflow++;
+		STAT_MOEA64(moea64_pte_valid--);
+		STAT_MOEA64(moea64_pte_overflow++);
 	}
 
 	return (0);

Modified: head/sys/powerpc/pseries/mmu_phyp.c
==============================================================================
--- head/sys/powerpc/pseries/mmu_phyp.c	Thu Jul 25 00:07:10 2019	(r350312)
+++ head/sys/powerpc/pseries/mmu_phyp.c	Thu Jul 25 03:47:27 2019	(r350313)
@@ -364,7 +364,7 @@ mphyp_pte_unset(mmu_t mmu, struct pvo_entry *pvo)
 	    ("Error removing page: %d", err));
 
 	if (err == H_NOT_FOUND) {
-		moea64_pte_overflow--;
+		STAT_MOEA64(moea64_pte_overflow--);
 		return (-1);
 	}
 
@@ -485,7 +485,7 @@ mphyp_pte_insert(mmu_t mmu, struct pvo_entry *pvo)
 		result = phyp_pft_hcall(H_REMOVE, H_AVPN, index,
 		    evicted.pte_hi & LPTE_AVPN_MASK, 0, &junk, &lastptelo,
 		    &junk);
-		moea64_pte_overflow++;
+		STAT_MOEA64(moea64_pte_overflow++);
 		KASSERT(result == H_SUCCESS || result == H_NOT_FOUND,
 		    ("Error evicting page: %d", (int)result));
 	}



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