ras_sync: deal with spurious wakeup and add comments.

This commit is contained in:
ad 2007-10-26 17:28:37 +00:00
parent d35530e427
commit 630552ea77
1 changed files with 19 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ras.c,v 1.22 2007/10/24 21:50:09 ad Exp $ */
/* $NetBSD: kern_ras.c,v 1.23 2007/10/26 17:28:37 ad Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.22 2007/10/24 21:50:09 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.23 2007/10/26 17:28:37 ad Exp $");
#include <sys/param.h>
#include <sys/lock.h>
@ -67,6 +67,8 @@ int ras_debug = 0;
/*
* Force all CPUs through cpu_switchto(), waiting until complete.
* Context switching will drain the write buffer on the calling
* CPU.
*/
static void
ras_sync(void)
@ -79,7 +81,21 @@ ras_sync(void)
where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
xc_wait(where);
#else
kpause("ras", false, hz >> 3, NULL);
/*
* Assumptions:
*
* o preemption is disabled by the thread in
* ras_lookup().
* o proc::p_raslist is only inspected with
* preemption disabled.
* o ras_lookup() plus loads reordered in advance
* will take no longer than 1/8s to complete.
*/
const int delta = hz >> 3;
int target = hardclock_ticks + delta;
do {
kpause("ras", false, delta, NULL);
} while (hardclock_ticks < target);
#endif
}
}