From 98f68cf115a30a101d3be2252ecbe1391720ed88 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Sat, 13 Oct 2018 00:56:42 +0300 Subject: Multiple xlators: perform gettimeofday() not under lock While it may slightly reduce accuracy, I think it's better to acquire the time outside a lock and then memcpy the value while under lock. Compile-tested only! updates: bz#1193929 Signed-off-by: Yaniv Kaul Change-Id: Ic8fb94a56c4fa2d3b13e59767e13646fb39342ba --- xlators/debug/io-stats/src/io-stats.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'xlators/debug/io-stats/src') diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index 6f6104033d8..3c7e7cf1ea4 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -275,6 +275,9 @@ is_fop_latency_started(call_frame_t *frame) struct timespec *begin, *end; \ double throughput; \ int flag = 0; \ + struct timeval tv = { \ + 0, \ + }; \ \ begin = &frame->begin; \ end = &frame->end; \ @@ -285,11 +288,13 @@ is_fop_latency_started(call_frame_t *frame) throughput = op_ret / elapsed; \ \ conf = this->private; \ + gettimeofday(&tv, NULL); \ LOCK(&iosstat->lock); \ { \ if (iosstat->thru_counters[type].throughput <= throughput) { \ iosstat->thru_counters[type].throughput = throughput; \ - gettimeofday(&iosstat->thru_counters[type].time, NULL); \ + memcpy(&iosstat->thru_counters[type].time, &tv, \ + sizeof(struct timeval)); \ flag = 1; \ } \ } \ -- cgit