From 9a3d6c2ed76ba902158a101be5b3dce46ca8f630 Mon Sep 17 00:00:00 2001 From: bwzhou Date: Fri, 9 May 2008 18:04:29 +0000 Subject: [PATCH] Branch HEAD b=15521 r=adilger, bobijam fix the wrong lprcfs stats --- lustre/include/lprocfs_status.h | 2 ++ lustre/lvfs/lvfs_lib.c | 2 +- lustre/lvfs/lvfs_linux.c | 2 +- lustre/obdclass/lprocfs_status.c | 12 ++++++------ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 07f5c8f..0f4d9b3 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -121,6 +121,8 @@ struct lprocfs_atomic { atomic_t la_exit; }; +#define LC_MIN_INIT ((~(__u64)0) >> 1) + struct lprocfs_counter { struct lprocfs_atomic lc_cntl; /* may need to move to per set */ unsigned int lc_config; diff --git a/lustre/lvfs/lvfs_lib.c b/lustre/lvfs/lvfs_lib.c index a83c171..5725e25 100644 --- a/lustre/lvfs/lvfs_lib.c +++ b/lustre/lvfs/lvfs_lib.c @@ -145,7 +145,7 @@ void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, if (percpu_cntr->lc_config & LPROCFS_CNTR_AVGMINMAX) { percpu_cntr->lc_sum += amount; if (percpu_cntr->lc_config & LPROCFS_CNTR_STDDEV) - percpu_cntr->lc_sumsquare += (__u64)amount * amount; + percpu_cntr->lc_sumsquare += (__s64)amount * amount; if (amount < percpu_cntr->lc_min) percpu_cntr->lc_min = amount; if (amount > percpu_cntr->lc_max) diff --git a/lustre/lvfs/lvfs_linux.c b/lustre/lvfs/lvfs_linux.c index e342eeb..fef6996 100644 --- a/lustre/lvfs/lvfs_linux.c +++ b/lustre/lvfs/lvfs_linux.c @@ -727,7 +727,7 @@ EXPORT_SYMBOL(obd_memory); __s64 lprocfs_read_helper(struct lprocfs_counter *lc, enum lprocfs_fields_flags field) { - __u64 ret = 0; + __s64 ret = 0; int centry; if (!lc) diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 002b4ae..608af88 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -844,7 +844,7 @@ void lprocfs_clear_stats(struct lprocfs_stats *stats) atomic_inc(&percpu_cntr->lc_cntl.la_entry); percpu_cntr->lc_count = 0; percpu_cntr->lc_sum = 0; - percpu_cntr->lc_min = ~(__u64)0; + percpu_cntr->lc_min = LC_MIN_INIT; percpu_cntr->lc_max = 0; percpu_cntr->lc_sumsquare = 0; atomic_inc(&percpu_cntr->lc_cntl.la_exit); @@ -890,7 +890,7 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v) { struct lprocfs_stats *stats = p->private; struct lprocfs_counter *cntr = v; - struct lprocfs_counter t, ret = { .lc_min = ~(__u64)0 }; + struct lprocfs_counter t, ret = { .lc_min = LC_MIN_INIT }; int i, idx, rc; unsigned int num_cpu; @@ -932,18 +932,18 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v) ret.lc_sumsquare += t.lc_sumsquare; } - rc = seq_printf(p, "%-25s "LPU64" samples [%s]", cntr->lc_name, + rc = seq_printf(p, "%-25s "LPD64" samples [%s]", cntr->lc_name, ret.lc_count, cntr->lc_units); if (rc < 0) goto out; if ((cntr->lc_config & LPROCFS_CNTR_AVGMINMAX) && (ret.lc_count > 0)) { - rc = seq_printf(p, " "LPU64" "LPU64" "LPU64, + rc = seq_printf(p, " "LPD64" "LPD64" "LPD64, ret.lc_min, ret.lc_max, ret.lc_sum); if (rc < 0) goto out; if (cntr->lc_config & LPROCFS_CNTR_STDDEV) - rc = seq_printf(p, " "LPU64, ret.lc_sumsquare); + rc = seq_printf(p, " "LPD64, ret.lc_sumsquare); if (rc < 0) goto out; } @@ -1015,7 +1015,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, c->lc_config = conf; c->lc_count = 0; c->lc_sum = 0; - c->lc_min = ~(__u64)0; + c->lc_min = LC_MIN_INIT; c->lc_max = 0; c->lc_name = name; c->lc_units = units; -- 1.8.3.1