Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc/sparc Optimize xcall() et.al. further by main...
details: https://anonhg.NetBSD.org/src/rev/06165a096aa4
branches: trunk
changeset: 542203:06165a096aa4
user: pk <pk%NetBSD.org@localhost>
date: Thu Jan 23 19:54:35 2003 +0000
description:
Optimize xcall() et.al. further by maintaining a cpuset mask of all CPUs
marked ready. This saves repeated testing for NULL pointers and the
CPUFLG_READY flag.
Also use a separate flag variable to signal xcall completion. This saves a
load and a pipeline stall.
diffstat:
sys/arch/sparc/sparc/cpu.c | 29 +++++++++++++++++++----------
sys/arch/sparc/sparc/cpuvar.h | 4 +++-
sys/arch/sparc/sparc/intr.c | 6 ++++--
3 files changed, 26 insertions(+), 13 deletions(-)
diffs (140 lines):
diff -r b4c726c3c1be -r 06165a096aa4 sys/arch/sparc/sparc/cpu.c
--- a/sys/arch/sparc/sparc/cpu.c Thu Jan 23 18:57:09 2003 +0000
+++ b/sys/arch/sparc/sparc/cpu.c Thu Jan 23 19:54:35 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.172 2003/01/23 14:54:33 pk Exp $ */
+/* $NetBSD: cpu.c,v 1.173 2003/01/23 19:54:35 pk Exp $ */
/*
* Copyright (c) 1996
@@ -102,6 +102,7 @@
int ncpu; /* # of CPUs detected by PROM */
struct cpu_info **cpus;
+u_int cpu_ready_mask; /* the set of CPUs marked as READY */
static int cpu_instance; /* current # of CPUs wired by us */
@@ -466,6 +467,10 @@
cpi->redzone = (void *)((long)cpi->idle_u + REDSIZE);
#endif
+ /*
+ * Allocate a slot in the cpus[] array such that the following
+ * invariant holds: cpus[cpi->ci_cpuid] == cpi;
+ */
cpus[cpu_instance] = cpi;
cpi->ci_cpuid = cpu_instance++;
cpi->mid = mid;
@@ -540,9 +545,6 @@
return;
}
- if (cpus == NULL)
- return;
-
printf("cpu0: booting secondary processors:");
for (n = 0; n < ncpu; n++) {
struct cpu_info *cpi = cpus[n];
@@ -559,13 +561,16 @@
printf(" cpu%d", cpi->ci_cpuid);
cpi->flags |= CPUFLG_READY;
+ cpu_ready_mask |= (1 << n);
}
+ /* Mark the boot CPU as ready */
+ cpuinfo.flags |= CPUFLG_READY;
+ cpu_ready_mask |= (1 << 0);
+
/* Tell the other CPU's to start up. */
go_smp_cpus = 1;
- /* OK, we're done. */
- cpuinfo.flags |= CPUFLG_READY;
printf("\n");
}
#endif /* MULTIPROCESSOR */
@@ -664,6 +669,9 @@
return;
}
+ /* Mask any CPUs that are not ready */
+ cpuset &= cpu_ready_mask;
+
/* prevent interrupts that grab the kernel lock */
s = splsched();
#ifdef DEBUG
@@ -685,11 +693,12 @@
for (n = 0; n < ncpu; n++) {
struct cpu_info *cpi = cpus[n];
- if (cpi == NULL || (cpuset & (1 << cpi->ci_cpuid)) == 0)
+ /* Note: n == cpi->ci_cpuid */
+ if ((cpuset & (1 << n)) == 0)
continue;
cpi->msg.tag = XPMSG_FUNC;
- cpi->flags &= ~CPUFLG_GOTMSG;
+ cpi->msg.complete = 0;
p = &cpi->msg.u.xpmsg_func;
p->func = func;
p->arg0 = arg0;
@@ -723,10 +732,10 @@
for (n = 0; n < ncpu; n++) {
struct cpu_info *cpi = cpus[n];
- if (cpi == NULL || (cpuset & (1 << cpi->ci_cpuid)) == 0)
+ if ((cpuset & (1 << n)) == 0)
continue;
- if ((cpi->flags & CPUFLG_GOTMSG) == 0) {
+ if (cpi->msg.complete == 0) {
if (i < 0) {
printf_nolog(" cpu%d", cpi->ci_cpuid);
} else {
diff -r b4c726c3c1be -r 06165a096aa4 sys/arch/sparc/sparc/cpuvar.h
--- a/sys/arch/sparc/sparc/cpuvar.h Thu Jan 23 18:57:09 2003 +0000
+++ b/sys/arch/sparc/sparc/cpuvar.h Thu Jan 23 19:54:35 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuvar.h,v 1.56 2003/01/23 18:49:08 pk Exp $ */
+/* $NetBSD: cpuvar.h,v 1.57 2003/01/23 19:54:35 pk Exp $ */
/*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -103,6 +103,8 @@
int retval;
} xpmsg_func;
} u;
+ __volatile int received;
+ __volatile int complete;
};
/*
diff -r b4c726c3c1be -r 06165a096aa4 sys/arch/sparc/sparc/intr.c
--- a/sys/arch/sparc/sparc/intr.c Thu Jan 23 18:57:09 2003 +0000
+++ b/sys/arch/sparc/sparc/intr.c Thu Jan 23 19:54:35 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.c,v 1.77 2003/01/23 14:56:06 pk Exp $ */
+/* $NetBSD: intr.c,v 1.78 2003/01/23 19:54:35 pk Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -357,6 +357,7 @@
static void xcallintr(void *v)
{
+ /* notyet - cpuinfo.msg.received = 1; */
switch (cpuinfo.msg.tag) {
case XPMSG_FUNC:
{
@@ -367,7 +368,8 @@
break;
}
}
- cpuinfo.flags |= CPUFLG_GOTMSG;
+ cpuinfo.msg.tag = 0;
+ cpuinfo.msg.complete = 1;
}
#endif /* MULTIPROCESSOR */
#endif /* SUN4M || SUN4D */
Home |
Main Index |
Thread Index |
Old Index