From 125fc934e7f4c669f67e5eec5b0e3dae3a2b6d72 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Mon, 25 Sep 2017 16:44:06 +0530 Subject: stack: change gettimeofday() to clock_gettime() For achieving the above, needed below changes too. * more sanity into how 'frame->op' is assigned. * infra to have 'stats' as separate section in 'xlator_t' structure Updates #137 Change-Id: I36679bf9577f3ed00a695b4e7d92870dcb3db8e1 Signed-off-by: Amar Tumballi --- xlators/debug/io-stats/src/io-stats.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'xlators/debug/io-stats/src/io-stats.c') diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index 9c3ca2d0a69..b660e5ac8cb 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -223,7 +223,7 @@ is_fop_latency_started (call_frame_t *frame) \ conf = this->private; \ if (conf && conf->measure_latency) { \ - gettimeofday (&frame->end, NULL); \ + timespec_now (&frame->end); \ update_ios_latency (conf, frame, GF_FOP_##op); \ } \ } while (0) @@ -234,7 +234,7 @@ is_fop_latency_started (call_frame_t *frame) \ conf = this->private; \ if (conf && conf->measure_latency) { \ - gettimeofday (&frame->begin, NULL); \ + timespec_now (&frame->begin); \ } else { \ memset (&frame->begin, 0, sizeof (frame->begin));\ } \ @@ -262,7 +262,7 @@ is_fop_latency_started (call_frame_t *frame) if (conf && conf->measure_latency && \ conf->count_fop_hits) { \ BUMP_FOP (op); \ - gettimeofday (&frame->end, NULL); \ + timespec_now (&frame->end); \ update_ios_latency (conf, frame, GF_FOP_##op); \ } \ } while (0) @@ -271,15 +271,15 @@ is_fop_latency_started (call_frame_t *frame) do { \ struct ios_conf *conf = NULL; \ double elapsed; \ - struct timeval *begin, *end; \ + struct timespec *begin, *end; \ double throughput; \ int flag = 0; \ \ begin = &frame->begin; \ end = &frame->end; \ \ - elapsed = (end->tv_sec - begin->tv_sec) * 1e6 \ - + (end->tv_usec - begin->tv_usec); \ + elapsed = ((end->tv_sec - begin->tv_sec) * 1e9 \ + + (end->tv_nsec - begin->tv_nsec)) / 1000; \ throughput = op_ret / elapsed; \ \ conf = this->private; \ @@ -1695,7 +1695,7 @@ void collect_ios_latency_sample (struct ios_conf *conf, { ios_sample_buf_t *ios_sample_buf = NULL; ios_sample_t *ios_sample = NULL; - struct timeval *timestamp = NULL; + struct timespec *timestamp = NULL; call_stack_t *root = NULL; @@ -1714,7 +1714,7 @@ void collect_ios_latency_sample (struct ios_conf *conf, ios_sample->uid = root->uid; ios_sample->gid = root->gid; (ios_sample->timestamp).tv_sec = timestamp->tv_sec; - (ios_sample->timestamp).tv_usec = timestamp->tv_usec; + (ios_sample->timestamp).tv_usec = timestamp->tv_nsec / 1000; memcpy (&ios_sample->identifier, &root->identifier, sizeof (root->identifier)); @@ -1759,13 +1759,13 @@ update_ios_latency (struct ios_conf *conf, call_frame_t *frame, glusterfs_fop_t op) { double elapsed; - struct timeval *begin, *end; + struct timespec *begin, *end; begin = &frame->begin; end = &frame->end; - elapsed = (end->tv_sec - begin->tv_sec) * 1e6 - + (end->tv_usec - begin->tv_usec); + elapsed = ((end->tv_sec - begin->tv_sec) * 1e9 + + (end->tv_nsec - begin->tv_nsec)) / 1000; update_ios_latency_stats (&conf->cumulative, elapsed, op); update_ios_latency_stats (&conf->incremental, elapsed, op); -- cgit