Module Name:    src
Committed By:   martin
Date:           Fri Jan  1 12:38:50 UTC 2021

Modified Files:
        src/sys/arch/aarch64/aarch64 [netbsd-9]: cpufunc.c pmap.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #1170):

        sys/arch/aarch64/aarch64/cpufunc.c: revision 1.22 (patch)
        sys/arch/aarch64/aarch64/cpufunc.c: revision 1.23 (patch)
        sys/arch/aarch64/aarch64/pmap.c: revision 1.81

Set uvmexp.ncolors appropriately, which is required for some CPU
models with VIPT icache.

Otherwise, alias in virtual address results in inconsistent results,
at least for applications that rewrite text of other process, e.g.,
GDB for arm32.

Also, this hopefully fixes other unexpected failures due to alias.
Confirmed that there's no observable regression in performance;
difference in ``time make -j8'' for GENERIC64 kernel on BCM2837
with and without setting uvmexp.ncolors is within 0.1%.

Thanks to ryo@ for discussion.

Fix uvmexp.ncolors for some big.LITTLE configuration; it is uncertain
which CPU is used as primary, and as a result, secondary CPUs can
require larger number of colors.

In order to solve this problem, update uvmexp.ncolors via
uvm_page_recolor(9) when secondary CPUs are attached, as done for
other ports like x86.

Pointed out by jmcneill@, and discussed on port-arm@:
http://mail-index.netbsd.org/port-arm/2020/07/03/msg006837.html
Tested and OK'd by ryo@.

Fix previous; add missing <uvm/uvm.h> include.


To generate a diff of this commit:
cvs rdiff -u -r1.5.4.1 -r1.5.4.2 src/sys/arch/aarch64/aarch64/cpufunc.c
cvs rdiff -u -r1.41.2.6 -r1.41.2.7 src/sys/arch/aarch64/aarch64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/aarch64/aarch64/cpufunc.c
diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.5.4.1 src/sys/arch/aarch64/aarch64/cpufunc.c:1.5.4.2
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.5.4.1	Sun Sep 22 12:27:22 2019
+++ src/sys/arch/aarch64/aarch64/cpufunc.c	Fri Jan  1 12:38:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.5.4.1 2019/09/22 12:27:22 martin Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.5.4.2 2021/01/01 12:38:49 martin Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org>
@@ -29,12 +29,15 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.5.4.1 2019/09/22 12:27:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.5.4.2 2021/01/01 12:38:49 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/kmem.h>
 
+#include <uvm/uvm.h>
+#include <uvm/uvm_page.h>
+
 #include <aarch64/cpu.h>
 #include <aarch64/cpufunc.h>
 
@@ -91,6 +94,7 @@ void
 aarch64_getcacheinfo(void)
 {
 	uint32_t clidr, ctr;
+	u_int vindexsize;
 	int level, cachetype;
 	struct aarch64_cache_info *cinfo;
 
@@ -201,14 +205,20 @@ aarch64_getcacheinfo(void)
 	    ((cinfo[0].cacheable == CACHE_CACHEABLE_ICACHE) ||
 	     (cinfo[0].cacheable == CACHE_CACHEABLE_IDCACHE))) {
 
-		aarch64_cache_vindexsize =
+		vindexsize =
 		    cinfo[0].icache.cache_size /
 		    cinfo[0].icache.cache_ways;
 
-		KASSERT(aarch64_cache_vindexsize != 0);
-		aarch64_cache_prefer_mask = aarch64_cache_vindexsize - 1;
+		KASSERT(vindexsize != 0);
 	} else {
-		aarch64_cache_vindexsize = 0;
+		vindexsize = 0;
+	}
+
+	if (vindexsize > aarch64_cache_vindexsize) {
+		aarch64_cache_vindexsize = vindexsize;
+		aarch64_cache_prefer_mask = vindexsize - 1;
+		if (uvm.page_init_done)
+			uvm_page_recolor(vindexsize / PAGE_SIZE);
 	}
 }
 

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.6 src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.7
--- src/sys/arch/aarch64/aarch64/pmap.c:1.41.2.6	Tue Jun 30 18:39:37 2020
+++ src/sys/arch/aarch64/aarch64/pmap.c	Fri Jan  1 12:38:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.41.2.6 2020/06/30 18:39:37 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.41.2.7 2021/01/01 12:38:49 martin Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.41.2.6 2020/06/30 18:39:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.41.2.7 2021/01/01 12:38:49 martin Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -418,10 +418,7 @@ pmap_bootstrap(vaddr_t vstart, vaddr_t v
 	UVMHIST_FUNC(__func__);
 	UVMHIST_CALLED(pmaphist);
 
-#if 0
-	/* uvmexp.ncolors = icachesize / icacheways / PAGE_SIZE; */
 	uvmexp.ncolors = aarch64_cache_vindexsize / PAGE_SIZE;
-#endif
 
 	/* devmap already uses last of va? */
 	if ((virtual_devmap_addr != 0) && (virtual_devmap_addr < vend))

Reply via email to