summaryrefslogtreecommitdiffstats
path: root/xlators/debug/io-stats/src
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-10-13 00:56:42 +0300
committerAmar Tumballi <amarts@redhat.com>2018-10-16 06:33:29 +0000
commit98f68cf115a30a101d3be2252ecbe1391720ed88 (patch)
tree4a9da66f8833a936eba95fc078a4605acd632f4f /xlators/debug/io-stats/src
parentfd70a7d790710da01a8ddd56785a28ab54e07550 (diff)
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 <ykaul@redhat.com> Change-Id: Ic8fb94a56c4fa2d3b13e59767e13646fb39342ba
Diffstat (limited to 'xlators/debug/io-stats/src')
-rw-r--r--xlators/debug/io-stats/src/io-stats.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 6f61040..3c7e7cf 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; \
} \
} \