From c35065fe9783a0b41ac5c86190d338c9e8c3d7f5 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 10 Feb 2015 11:33:20 +0100 Subject: [PATCH] infra: report global IO hangs --- kernel/lib_timing.c | 8 ++++++++ kernel/lib_timing.h | 17 ++++++++++++----- kernel/mars_aio.c | 3 +++ kernel/mars_bio.c | 3 +++ kernel/sy_old/mars_proc.c | 1 + 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/kernel/lib_timing.c b/kernel/lib_timing.c index 6f8cf364..b2811342 100644 --- a/kernel/lib_timing.c +++ b/kernel/lib_timing.c @@ -63,3 +63,11 @@ int report_timing(struct timing_stats *tim, char *str, int maxlen) EXPORT_SYMBOL_GPL(report_timing); #endif + +struct threshold global_io_threshold = { + .thr_limit = 30 * 1000000, // 30 seconds + .thr_factor = 100, + .thr_plus = 0, +}; +EXPORT_SYMBOL_GPL(global_io_threshold); + diff --git a/kernel/lib_timing.h b/kernel/lib_timing.h index 25ee79a5..51cd6922 100644 --- a/kernel/lib_timing.h +++ b/kernel/lib_timing.h @@ -152,6 +152,7 @@ void banning_reset(struct banning *ban) */ struct threshold { struct banning *thr_ban; + struct threshold *thr_parent; /* support hierarchies */ // tunables int thr_limit; // in us int thr_factor; // in % @@ -164,12 +165,18 @@ struct threshold { extern inline void threshold_check(struct threshold *thr, long long latency) { - if (thr->thr_limit && - latency > (long long)thr->thr_limit * 1000) { - thr->thr_triggered++; - if (!banning_hit(thr->thr_ban, latency * thr->thr_factor / 100 + thr->thr_plus * 1000)) - thr->thr_true_hit++; + while (thr) { + if (thr->thr_limit && + latency > (long long)thr->thr_limit * 1000) { + thr->thr_triggered++; + if (thr->thr_ban && + !banning_hit(thr->thr_ban, latency * thr->thr_factor / 100 + thr->thr_plus * 1000)) + thr->thr_true_hit++; + } + thr = thr->thr_parent; } } +extern struct threshold global_io_threshold; + #endif diff --git a/kernel/mars_aio.c b/kernel/mars_aio.c index 24b21cf2..949c6a66 100644 --- a/kernel/mars_aio.c +++ b/kernel/mars_aio.c @@ -50,6 +50,7 @@ static struct timing_stats timings[3] = {}; struct threshold aio_submit_threshold = { .thr_ban = &mars_global_ban, + .thr_parent = &global_io_threshold, .thr_limit = AIO_SUBMIT_MAX_LATENCY, .thr_factor = 10, .thr_plus = 10000, @@ -59,12 +60,14 @@ EXPORT_SYMBOL_GPL(aio_submit_threshold); struct threshold aio_io_threshold[2] = { [0] = { .thr_ban = &mars_global_ban, + .thr_parent = &global_io_threshold, .thr_limit = AIO_IO_R_MAX_LATENCY, .thr_factor = 100, .thr_plus = 0, }, [1] = { .thr_ban = &mars_global_ban, + .thr_parent = &global_io_threshold, .thr_limit = AIO_IO_W_MAX_LATENCY, .thr_factor = 100, .thr_plus = 0, diff --git a/kernel/mars_bio.c b/kernel/mars_bio.c index e56ba118..6f7f17ac 100644 --- a/kernel/mars_bio.c +++ b/kernel/mars_bio.c @@ -51,6 +51,7 @@ static struct timing_stats timings[2] = {}; struct threshold bio_submit_threshold = { .thr_ban = &mars_global_ban, + .thr_parent = &global_io_threshold, .thr_limit = BIO_SUBMIT_MAX_LATENCY, .thr_factor = 100, .thr_plus = 0, @@ -60,12 +61,14 @@ EXPORT_SYMBOL_GPL(bio_submit_threshold); struct threshold bio_io_threshold[2] = { [0] = { .thr_ban = &mars_global_ban, + .thr_parent = &global_io_threshold, .thr_limit = BIO_IO_R_MAX_LATENCY, .thr_factor = 10, .thr_plus = 10000, }, [1] = { .thr_ban = &mars_global_ban, + .thr_parent = &global_io_threshold, .thr_limit = BIO_IO_W_MAX_LATENCY, .thr_factor = 10, .thr_plus = 10000, diff --git a/kernel/sy_old/mars_proc.c b/kernel/sy_old/mars_proc.c index 44d311c0..22435e67 100644 --- a/kernel/sy_old/mars_proc.c +++ b/kernel/sy_old/mars_proc.c @@ -234,6 +234,7 @@ static ctl_table io_tuning_table[] = { LIMITER_ENTRIES(&global_writeback.limiter, "writeback", "kb"), INT_ENTRY("writeback_until_percent", global_writeback.until_percent, 0600), + THRESHOLD_ENTRIES(&global_io_threshold, "global_io"), THRESHOLD_ENTRIES(&bio_submit_threshold, "bio_submit"), THRESHOLD_ENTRIES(&bio_io_threshold[0], "bio_io_r"), THRESHOLD_ENTRIES(&bio_io_threshold[1], "bio_io_w"),