From 654a51ea6cb528b9b2bb7fe3731b71cd689fab94 Mon Sep 17 00:00:00 2001 From: Alex Hornung Date: Tue, 20 Apr 2010 22:31:12 +0000 Subject: [PATCH] dsched_fq - correct disk busy% calculation * Previously old_tv was static, causing problems when several disks had the fq policy enabled, as the start time of the interval was taken from some other disk. * Avoid this issue by keeping the information in diskctx, where it belongs. --- sys/dsched/fq/dsched_fq.h | 1 + sys/dsched/fq/dsched_fq_core.c | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/dsched/fq/dsched_fq.h b/sys/dsched/fq/dsched_fq.h index 6b31c875ef..001e5eb5e7 100644 --- a/sys/dsched/fq/dsched_fq.h +++ b/sys/dsched/fq/dsched_fq.h @@ -161,6 +161,7 @@ struct fq_disk_ctx { struct timeval start_idle; /* disk idleness start time */ int idle_time; /* aggregate idle time in interval */ int die; /* flag to kill related threads */ + struct timeval start_interval; /* current interval start time */ int prev_full; /* disk >90% busy during prev. to last interval? */ diff --git a/sys/dsched/fq/dsched_fq_core.c b/sys/dsched/fq/dsched_fq_core.c index 21a6d40cfa..01addf6889 100644 --- a/sys/dsched/fq/dsched_fq_core.c +++ b/sys/dsched/fq/dsched_fq_core.c @@ -417,16 +417,16 @@ void fq_balance_thread(struct fq_disk_ctx *diskctx) { struct fq_thread_io *tdio, *tdio2; - static struct timeval old_tv; - struct timeval tv; + struct timeval tv, old_tv; int64_t total_budget, product; int64_t budget[FQ_PRIO_MAX+1]; int n, i, sum, total_disk_time; int lost_bits; - getmicrotime(&old_tv); - FQ_DISK_CTX_LOCK(diskctx); + + getmicrotime(&diskctx->start_interval); + for (;;) { /* sleep ~1s */ if ((lksleep(curthread, &diskctx->lock, 0, "fq_balancer", hz/2) == 0)) { @@ -440,6 +440,7 @@ fq_balance_thread(struct fq_disk_ctx *diskctx) total_budget = 0; n = 0; + old_tv = diskctx->start_interval; getmicrotime(&tv); total_disk_time = (int)(1000000*((tv.tv_sec - old_tv.tv_sec)) + @@ -450,7 +451,7 @@ fq_balance_thread(struct fq_disk_ctx *diskctx) dsched_debug(LOG_INFO, "total_disk_time = %d\n", total_disk_time); - old_tv = tv; + diskctx->start_interval = tv; diskctx->disk_busy = (100*(total_disk_time - diskctx->idle_time)) / total_disk_time; if (diskctx->disk_busy < 0) -- 2.41.0