From: Bobi Jam Date: Mon, 4 Jun 2012 15:38:17 +0000 (+0800) Subject: LU-1282 lprocfs: free stat memory as it is cleared X-Git-Tag: 2.2.55~25 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8c831cb8a05f0d6f63b88e9b2dfb85ba4eca217a LU-1282 lprocfs: free stat memory as it is cleared Clear stats also free the stat memory occupation. Signed-off-by: Bobi Jam Change-Id: Ie0050eb716883aaeca08f4b3bacc772e83b87679 Reviewed-on: http://review.whamcloud.com/3026 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 765d017..4b957f7 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -1272,24 +1272,36 @@ void lprocfs_clear_stats(struct lprocfs_stats *stats) int i; int j; unsigned int num_entry; + unsigned int percpusize; unsigned long flags = 0; num_entry = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags); + percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]); + if (num_entry > 1) + percpusize = CFS_L1_CACHE_ALIGN(percpusize); + for (i = 0; i < num_entry; i++) { if (stats->ls_percpu[i] == NULL) continue; - for (j = 0; j < stats->ls_num; j++) { - percpu_cntr = &(stats->ls_percpu[i])->lp_cntr[j]; - cfs_atomic_inc(&percpu_cntr->lc_cntl.la_entry); - percpu_cntr->lc_count = 0; - percpu_cntr->lc_sum = 0; - percpu_cntr->lc_min = LC_MIN_INIT; - percpu_cntr->lc_max = 0; - percpu_cntr->lc_sumsquare = 0; - cfs_atomic_inc(&percpu_cntr->lc_cntl.la_exit); - } - } + /* the 1st percpu entry was statically allocated in + * lprocfs_alloc_stats() */ + if (i > 0) { + OBD_FREE(stats->ls_percpu[i], percpusize); + stats->ls_percpu[i] = NULL; + continue; + } + for (j = 0; j < stats->ls_num; j++) { + percpu_cntr = &(stats->ls_percpu[i])->lp_cntr[j]; + cfs_atomic_inc(&percpu_cntr->lc_cntl.la_entry); + percpu_cntr->lc_count = 0; + percpu_cntr->lc_sum = 0; + percpu_cntr->lc_min = LC_MIN_INIT; + percpu_cntr->lc_max = 0; + percpu_cntr->lc_sumsquare = 0; + cfs_atomic_inc(&percpu_cntr->lc_cntl.la_exit); + } + } lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags); }