do a better job synchronizing %tick across CPUs

ok'ed by mrg
This commit is contained in:
macallan 2010-08-06 00:07:05 +00:00
parent 68f14ab461
commit d940687d9b

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.c,v 1.96 2010/07/28 21:34:57 macallan Exp $ */
/* $NetBSD: cpu.c,v 1.97 2010/08/06 00:07:05 macallan Exp $ */
/*
* Copyright (c) 1996
@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.96 2010/07/28 21:34:57 macallan Exp $");
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.97 2010/08/06 00:07:05 macallan Exp $");
#include "opt_multiprocessor.h"
@ -106,6 +106,8 @@ static const char *ipi_evcnt_names[IPI_EVCNT_NUM] = IPI_EVCNT_NAMES;
static void cpu_reset_fpustate(void);
volatile int sync_tick = 0;
/* The CPU configuration driver. */
void cpu_attach(struct device *, struct device *, void *);
int cpu_match(struct device *, struct cfdata *, void *);
@ -412,6 +414,8 @@ cpu_boot_secondary_processors(void)
int i, pstate;
struct cpu_info *ci;
sync_tick = 0;
sparc64_ipi_init();
if (boothowto & RB_MD1) {
@ -441,7 +445,13 @@ cpu_boot_secondary_processors(void)
break;
delay(10000);
}
/* synchronize %tick ( to some degree at least ) */
delay(1000);
sync_tick = 1;
membar_sync();
settick(0);
setpstate(pstate);
if (!CPUSET_HAS(cpus_active, ci->ci_index))
@ -463,7 +473,13 @@ cpu_hatch(void)
cpu_reset_fpustate();
curlwp = curcpu()->ci_data.cpu_idlelwp;
membar_sync();
/* wait for the boot CPU to flip the switch */
while (sync_tick == 0) {
/* we do nothing here */
}
settick(0);
tickintr_establish(PIL_CLOCK, tickintr);
spl0();
}