summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPeter Galbavy <peter@cvs.openbsd.org>1999-08-02 15:42:49 +0000
committerPeter Galbavy <peter@cvs.openbsd.org>1999-08-02 15:42:49 +0000
commitec2394ca325ad0555a4ba589ca140a8623d96d21 (patch)
tree43ff7d550bb28414ee297ee142747c9badc7a539 /sys
parent4f6aac596a6dc9d3bba86d7ce2ba3fc815da8e72 (diff)
fix reconstruction performance. the old code used home-grown timers
based upon hardcoded CPU speed values and an assumtion that the number of clock cycles was available. This is/was silly. redone rf_GetNextReconEvent so that is now runs for 1/10th second before sleeping for a short time (1/50th sec). Locally, this is using about 25% of the CPU while rebuilding a disk in a four disk IDE RAID5 array. It was 22% of the way through when I last looked... much much faster. An even better way is sought - suggestions welcome. Lots of code that the old routines relied on canm be harvested later. Patches also being sent to Greg Oster @ NetBSD group.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/raidframe/rf_revent.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/sys/dev/raidframe/rf_revent.c b/sys/dev/raidframe/rf_revent.c
index f57dc5e5cbb..6b54f94bf6c 100644
--- a/sys/dev/raidframe/rf_revent.c
+++ b/sys/dev/raidframe/rf_revent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rf_revent.c,v 1.4 1999/08/02 12:35:33 peter Exp $ */
+/* $OpenBSD: rf_revent.c,v 1.5 1999/08/02 15:42:48 peter Exp $ */
/* $NetBSD: rf_revent.c,v 1.4 1999/03/14 21:53:31 oster Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
@@ -40,6 +40,8 @@
#include "rf_desc.h"
#include "rf_shutdown.h"
+#include <sys/kernel.h>
+
static RF_FreeList_t *rf_revent_freelist;
#define RF_MAX_FREE_REVENT 128
#define RF_REVENT_INC 8
@@ -107,6 +109,8 @@ rf_GetNextReconEvent(reconDesc, row, continueFunc, continueArg)
void (*continueFunc) (void *);
void *continueArg;
{
+ int s;
+
RF_Raid_t *raidPtr = reconDesc->raidPtr;
RF_ReconCtrl_t *rctrl = raidPtr->reconControl[row];
RF_ReconEvent_t *event;
@@ -121,47 +125,42 @@ rf_GetNextReconEvent(reconDesc, row, continueFunc, continueArg)
rctrl->continueFunc = continueFunc;
rctrl->continueArg = continueArg;
+/* start with a simple premise. Allow 100 ms for recon, and then
+ * sleep for the 2 ms to allow use of the CPU. This resulted in a CPU
+ * utilisation of about 25% locally, and a very responsive system - PMG
+ */
+#define RECON_TIME ((100 * hz) / 1000)
-/* mpsleep timeout value: secs = timo_val/hz. 'ticks' here is defined as cycle-counter ticks, not softclock ticks */
-#define MAX_RECON_EXEC_TICKS 15000000 /* 150 Mhz => this many ticks in 100
- * ms */
-#define RECON_DELAY_MS 25
-#define RECON_TIMO ((RECON_DELAY_MS * hz) / 1000)
-
- /* we are not pre-emptible in the kernel, but we don't want to run
- * forever. If we run w/o blocking for more than MAX_RECON_EXEC_TICKS
- * ticks of the cycle counter, delay for RECON_DELAY before
- * continuing. this may murder us with context switches, so we may
- * need to increase both the MAX...TICKS and the RECON_DELAY_MS. */
if (reconDesc->reconExecTimerRunning) {
int status;
+ RF_int64 ticks;
- RF_ETIMER_STOP(reconDesc->recon_exec_timer);
- RF_ETIMER_EVAL(reconDesc->recon_exec_timer);
- reconDesc->reconExecTicks += RF_ETIMER_VAL_TICKS(reconDesc->recon_exec_timer);
- if (reconDesc->reconExecTicks > reconDesc->maxReconExecTicks)
- reconDesc->maxReconExecTicks = reconDesc->reconExecTicks;
- if (reconDesc->reconExecTicks >= MAX_RECON_EXEC_TICKS) {
- /* we've been running too long. delay for
- * RECON_DELAY_MS */
+ s = splclock();
+ ticks = (mono_time.tv_sec * 1000000 + mono_time.tv_usec) -
+ reconDesc->reconExecTimerRunning;
+ splx(s);
+
+ if (ticks >= (1000000 / RECON_TIME)) {
+ /* we've been running too long. delay for RECON_TIME */
#if RF_RECON_STATS > 0
reconDesc->numReconExecDelays++;
-#endif /* RF_RECON_STATS > 0 */
- status = tsleep(&reconDesc->reconExecTicks, PRIBIO, "recon delay", RECON_TIMO);
+#endif /* RF_RECON_STATS > 0 */
+ status = tsleep(&reconDesc->reconExecTicks, PRIBIO, "recon delay", RECON_TIME / 5);
RF_ASSERT(status == EWOULDBLOCK);
- reconDesc->reconExecTicks = 0;
}
}
+
while (!rctrl->eventQueue) {
#if RF_RECON_STATS > 0
reconDesc->numReconEventWaits++;
#endif /* RF_RECON_STATS > 0 */
DO_WAIT(rctrl);
- reconDesc->reconExecTicks = 0; /* we've just waited */
}
-
- reconDesc->reconExecTimerRunning = 1;
- RF_ETIMER_START(reconDesc->recon_exec_timer);
+ s = splclock();
+ /* set time to now */
+ reconDesc->reconExecTimerRunning = mono_time.tv_sec * 1000000 +
+ mono_time.tv_usec;
+ splx(s);
event = rctrl->eventQueue;
rctrl->eventQueue = event->next;