-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
return -1;
}
- fprintf(stdout, "%s ID: %Lu@%s, KEY: %d NODES: %d\n",
+ fprintf(stdout, "%s ID: "LPU64"@%s, KEY: %d NODES: %d\n",
name, sid.ses_stamp, libcfs_nid2str(sid.ses_nid),
key, ndinfo.nle_nnode);
static void
lst_timeval_diff(struct timeval *tv1,
- struct timeval *tv2, struct timeval *df)
+ 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;
- }
+ 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;
+ df->tv_sec = tv1->tv_sec - 1 - tv2->tv_sec;
+ df->tv_usec = tv1->tv_usec + 1000000 - tv2->tv_usec;
- return;
+ return;
}
void
void
lst_print_stat(char *name, cfs_list_t *resultp,
- int idx, int lnet, int bwrt, int rdwr, int type)
+ int idx, int lnet, int bwrt, int rdwr, int type)
{
cfs_list_t tmp[2];
lstcon_rpc_ent_t *new;
srpc_counters_t *srpc_old;
lnet_counters_t *lnet_new;
lnet_counters_t *lnet_old;
- struct timeval tv;
float delta;
int errcount = 0;
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);
+ /* Prior to version 2.3, the running_ms field was a counter for
+ * the number of running tests. We are looking at this value
+ * to determine if it is a millisecond timestamep (>= 2.3) or a
+ * test counter (< 2.3). The number 500 is being used for this
+ * barrier as the test counter should never get this high, and
+ * the timestamp should never get this low. */
+
+ if (sfwk_new->running_ms > 500) {
+ /* 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;
+ } else {
+ struct timeval tv;
+
+ lst_timeval_diff(&new->rpe_stamp, &old->rpe_stamp, &tv);
+ delta = tv.tv_sec + (float)tv.tv_usec / 1000000;
+ }
if (!lnet) /* TODO */
continue;
int optidx = 0;
int timeout = 5; /* default timeout, 5 sec */
int delay = 5; /* default delay, 5 sec */
+ int count = -1; /* run forever */
int lnet = 1; /* lnet stat by default */
int bwrt = 0;
int rdwr = 0;
static struct option stat_opts[] =
{
- {"timeout", required_argument, 0, 't' },
- {"delay" , required_argument, 0, 'd' },
- {"lnet" , no_argument, 0, 'l' },
- {"rpc" , no_argument, 0, 'c' },
- {"bw" , no_argument, 0, 'b' },
- {"rate" , no_argument, 0, 'a' },
- {"read" , no_argument, 0, 'r' },
- {"write" , no_argument, 0, 'w' },
- {"avg" , no_argument, 0, 'g' },
- {"min" , no_argument, 0, 'n' },
- {"max" , no_argument, 0, 'x' },
- {0, 0, 0, 0 }
+ {"timeout" , required_argument, 0, 't' },
+ {"delay" , required_argument, 0, 'd' },
+ {"count" , required_argument, 0, 'o' },
+ {"lnet" , no_argument, 0, 'l' },
+ {"rpc" , no_argument, 0, 'c' },
+ {"bw" , no_argument, 0, 'b' },
+ {"rate" , no_argument, 0, 'a' },
+ {"read" , no_argument, 0, 'r' },
+ {"write" , no_argument, 0, 'w' },
+ {"avg" , no_argument, 0, 'g' },
+ {"min" , no_argument, 0, 'n' },
+ {"max" , no_argument, 0, 'x' },
+ {0, 0, 0, 0 }
};
if (session_key == 0) {
}
while (1) {
- c = getopt_long(argc, argv, "t:d:lcbarwgnx", stat_opts, &optidx);
+ c = getopt_long(argc, argv, "t:d:lcbarwgnx", stat_opts, &optidx);
if (c == -1)
break;
case 'd':
delay = atoi(optarg);
break;
+ case 'o':
+ count = atoi(optarg);
+ break;
case 'l':
lnet = 1;
break;
}
type |= 4;
break;
+
default:
lst_print_usage(argv[0]);
return -1;
return -1;
}
+ if (count < -1) {
+ fprintf(stderr, "Invalid count value\n");
+ return -1;
+ }
+
+ /* extra count to get first data point */
+ if (count != -1)
+ count++;
+
CFS_INIT_LIST_HEAD(&head);
while (optind < argc) {
cfs_list_add_tail(&srp->srp_link, &head);
}
- while (1) {
+ do {
time_t now = time(NULL);
if (now - last < delay) {
goto out;
}
- lst_print_stat(srp->srp_name, srp->srp_result,
- idx, lnet, bwrt, rdwr, type);
+ lst_print_stat(srp->srp_name, srp->srp_result,
+ idx, lnet, bwrt, rdwr, type);
lst_reset_rpcent(&srp->srp_result[1 - idx]);
}
idx = 1 - idx;
- }
+
+ if (count > 0)
+ count--;
+ } while (count == -1 || count > 0);
out:
while (!cfs_list_empty(&head)) {
cfs_list_for_each_entry_typed(srp, &head, lst_stat_req_param_t,
srp_link) {
rc = lst_stat_ioctl(srp->srp_name, srp->srp_count,
- srp->srp_ids, 5, &srp->srp_result[0]);
+ srp->srp_ids, 10, &srp->srp_result[0]);
if (rc == -1) {
lst_print_error(srp->srp_name, "Failed to show errors of %s: %s\n",
"Usage: lst update_group NAME [--clean] [--refresh] [--remove IDs]" },
{"list_group", jt_lst_list_group, NULL,
"Usage: lst list_group [--active] [--busy] [--down] [--unknown] GROUP ..." },
- {"stat", jt_lst_stat, NULL,
- "Usage: lst stat [--bw] [--rate] [--read] [--write] [--max] [--min] [--avg] "
- " [--timeout #] [--delay #] GROUP [GROUP]" },
+ {"stat", jt_lst_stat, NULL,
+ "Usage: lst stat [--bw] [--rate] [--read] [--write] [--max] [--min] [--avg] "
+ " [--timeout #] [--delay #] [--count #] GROUP [GROUP]" },
{"show_error", jt_lst_show_error, NULL,
"Usage: lst show_error NAME | IDS ..." },
{"add_batch", jt_lst_add_batch, NULL,