From bc5b01bba4a6d934bb1092fab37adc9295a98487 Mon Sep 17 00:00:00 2001 From: Wally Wang Date: Wed, 22 Jun 2011 10:53:03 -0700 Subject: [PATCH] LU-445 lnet: Send timestamps with LNet counters We use a millisecond timer on a per-session basis. Each node then sends the milliseconds since session start over with the LNet counters. With 32bits and millisecond resolution, this should allow ~49 days of session age before the timers would wrap. This will change the wire attribute and not backward compatible. Change-Id: I0dc6498d187ccc900b86d21b0460e1d419770033 Signed-off-by: Wally Wang Signed-off-by: Liang Zhen Reviewed-on: http://review.whamcloud.com/1000 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao --- lnet/include/lnet/lnetst.h | 3 ++- lnet/selftest/framework.c | 22 +++++++++++++--------- lnet/selftest/selftest.h | 1 + lnet/utils/lst.c | 23 ++++------------------- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/lnet/include/lnet/lnetst.h b/lnet/include/lnet/lnetst.h index 6ca9020..3f4f3fc 100644 --- a/lnet/include/lnet/lnetst.h +++ b/lnet/include/lnet/lnetst.h @@ -469,7 +469,8 @@ typedef struct { } WIRE_ATTR srpc_counters_t; typedef struct { - __u32 active_tests; + /** milliseconds since current session started */ + __u32 running_ms; __u32 active_batches; __u32 zombie_sessions; __u32 brw_errors; diff --git a/lnet/selftest/framework.c b/lnet/selftest/framework.c index 4bf02d9..4e14a78 100644 --- a/lnet/selftest/framework.c +++ b/lnet/selftest/framework.c @@ -76,11 +76,11 @@ do { \ #define sfw_unpack_fw_counters(fc) \ do { \ - __swab32s(&(fc).brw_errors); \ - __swab32s(&(fc).ping_errors); \ - __swab32s(&(fc).active_tests); \ + __swab32s(&(fc).running_ms); \ __swab32s(&(fc).active_batches); \ __swab32s(&(fc).zombie_sessions); \ + __swab32s(&(fc).brw_errors); \ + __swab32s(&(fc).ping_errors); \ } while (0) #define sfw_unpack_rpc_counters(rc) \ @@ -302,6 +302,7 @@ sfw_init_session (sfw_session_t *sn, lst_sid_t sid, const char *name) sn->sn_timer_active = 0; sn->sn_id = sid; sn->sn_timeout = session_timeout; + sn->sn_started = cfs_time_current(); timer->stt_data = sn; timer->stt_func = sfw_session_expired; @@ -403,6 +404,7 @@ sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply) sfw_session_t *sn = sfw_data.fw_session; sfw_counters_t *cnt = &reply->str_fw; sfw_batch_t *bat; + struct timeval tv; reply->str_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id; @@ -422,19 +424,21 @@ sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply) srpc_get_counters(&reply->str_rpc); + /* send over the msecs since the session was started + - with 32 bits to send, this is ~49 days */ + cfs_duration_usec(cfs_time_sub(cfs_time_current(), + sn->sn_started), &tv); + + cnt->running_ms = (__u32)(tv.tv_sec * 1000 + tv.tv_usec / 1000); cnt->brw_errors = cfs_atomic_read(&sn->sn_brw_errors); cnt->ping_errors = cfs_atomic_read(&sn->sn_ping_errors); cnt->zombie_sessions = cfs_atomic_read(&sfw_data.fw_nzombies); - cnt->active_tests = cnt->active_batches = 0; + cnt->active_batches = 0; cfs_list_for_each_entry_typed (bat, &sn->sn_batches, sfw_batch_t, bat_list) { - int n = cfs_atomic_read(&bat->bat_nactive); - - if (n > 0) { + if (cfs_atomic_read(&bat->bat_nactive) > 0) cnt->active_batches++; - cnt->active_tests += n; - } } reply->str_status = 0; diff --git a/lnet/selftest/selftest.h b/lnet/selftest/selftest.h index 9856472..5bbb28e 100644 --- a/lnet/selftest/selftest.h +++ b/lnet/selftest/selftest.h @@ -306,6 +306,7 @@ typedef struct { cfs_atomic_t sn_refcount; cfs_atomic_t sn_brw_errors; cfs_atomic_t sn_ping_errors; + cfs_time_t sn_started; } sfw_session_t; #define sfw_sid_equal(sid0, sid1) ((sid0).ses_nid == (sid1).ses_nid && \ diff --git a/lnet/utils/lst.c b/lnet/utils/lst.c index 30428db..01d2d22 100644 --- a/lnet/utils/lst.c +++ b/lnet/utils/lst.c @@ -1556,22 +1556,6 @@ lst_lnet_stat_value(int bw, int send, int off) return *p; } -static void -lst_timeval_diff(struct timeval *tv1, - struct timeval *tv2, struct timeval *df) -{ - if (tv1->tv_usec >= tv2->tv_usec) { - df->tv_sec = tv1->tv_sec - tv2->tv_sec; - df->tv_usec = tv1->tv_usec - tv2->tv_usec; - return; - } - - df->tv_sec = tv1->tv_sec - 1 - tv2->tv_sec; - df->tv_usec = tv1->tv_sec + 1000000 - tv2->tv_usec; - - return; -} - void lst_cal_lnet_stat(float delta, lnet_counters_t *lnet_new, lnet_counters_t *lnet_old) @@ -1703,7 +1687,6 @@ lst_print_stat(char *name, cfs_list_t *resultp, srpc_counters_t *srpc_old; lnet_counters_t *lnet_new; lnet_counters_t *lnet_old; - struct timeval tv; float delta; int errcount = 0; @@ -1754,9 +1737,11 @@ lst_print_stat(char *name, cfs_list_t *resultp, lnet_new = (lnet_counters_t *)((char *)srpc_new + sizeof(*srpc_new)); lnet_old = (lnet_counters_t *)((char *)srpc_old + sizeof(*srpc_old)); - lst_timeval_diff(&new->rpe_stamp, &old->rpe_stamp, &tv); + /* use the timestamp from the remote node, not our rpe_stamp + * from when we copied up the data out of the kernel */ - delta = tv.tv_sec + (float)tv.tv_usec/1000000; + delta = (float) (sfwk_new->running_ms - + sfwk_old->running_ms) / 1000; if (!lnet) /* TODO */ continue; -- 1.8.3.1