From patchwork Thu Feb 27 21:10:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11409973 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD1671871 for ; Thu, 27 Feb 2020 21:26:58 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B5B84246A0 for ; Thu, 27 Feb 2020 21:26:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5B84246A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 0B15F3490EC; Thu, 27 Feb 2020 13:23:50 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1340021FC50 for ; Thu, 27 Feb 2020 13:19:14 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 75214249C; Thu, 27 Feb 2020 16:18:15 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 73FFD468; Thu, 27 Feb 2020 16:18:15 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:10:53 -0500 Message-Id: <1582838290-17243-186-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 185/622] lustre: headers: define pct(a, b) once X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Ben Evans pct is defined 6 times in different places. Define it in one. Also change it to a static inline to do a better job of enforcing types. WC-bug-id: https://jira.whamcloud.com/browse/LU-10171 Lustre-commit: 9b924e86b27d ("LU-10171 headers: define pct(a,b) once") Signed-off-by: Ben Evans Reviewed-on: https://review.whamcloud.com/29852 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- fs/lustre/fld/fld_cache.c | 12 ++---------- fs/lustre/include/lprocfs_status.h | 5 +++++ fs/lustre/llite/lproc_llite.c | 7 +++---- fs/lustre/obdclass/genops.c | 6 +----- fs/lustre/osc/lproc_osc.c | 10 +++------- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/fs/lustre/fld/fld_cache.c b/fs/lustre/fld/fld_cache.c index d289c29..96be544 100644 --- a/fs/lustre/fld/fld_cache.c +++ b/fs/lustre/fld/fld_cache.c @@ -94,22 +94,14 @@ struct fld_cache *fld_cache_init(const char *name, */ void fld_cache_fini(struct fld_cache *cache) { - u64 pct; - LASSERT(cache); fld_cache_flush(cache); - if (cache->fci_stat.fst_count > 0) { - pct = cache->fci_stat.fst_cache * 100; - do_div(pct, cache->fci_stat.fst_count); - } else { - pct = 0; - } - CDEBUG(D_INFO, "FLD cache statistics (%s):\n", cache->fci_name); CDEBUG(D_INFO, " Total reqs: %llu\n", cache->fci_stat.fst_count); CDEBUG(D_INFO, " Cache reqs: %llu\n", cache->fci_stat.fst_cache); - CDEBUG(D_INFO, " Cache hits: %llu%%\n", pct); + CDEBUG(D_INFO, " Cache hits: %u%%\n", + pct(cache->fci_stat.fst_cache, cache->fci_stat.fst_count)); kfree(cache); } diff --git a/fs/lustre/include/lprocfs_status.h b/fs/lustre/include/lprocfs_status.h index 32d43fb..1ef548ae 100644 --- a/fs/lustre/include/lprocfs_status.h +++ b/fs/lustre/include/lprocfs_status.h @@ -58,6 +58,11 @@ struct lprocfs_vars { umode_t proc_mode; }; +static inline u32 pct(s64 a, s64 b) +{ + return b ? a * 100 / b : 0; +} + struct lprocfs_static_vars { struct lprocfs_vars *obd_vars; const struct attribute_group *sysfs_vars; diff --git a/fs/lustre/llite/lproc_llite.c b/fs/lustre/llite/lproc_llite.c index 5fc7705..4060271 100644 --- a/fs/lustre/llite/lproc_llite.c +++ b/fs/lustre/llite/lproc_llite.c @@ -1483,8 +1483,6 @@ void ll_debugfs_unregister_super(struct super_block *sb) lprocfs_free_stats(&sbi->ll_stats); } -#define pct(a, b) (b ? a * 100 / b : 0) - static void ll_display_extents_info(struct ll_rw_extents_info *io_extents, struct seq_file *seq, int which) { @@ -1508,8 +1506,9 @@ static void ll_display_extents_info(struct ll_rw_extents_info *io_extents, w = pp_info->pp_w_hist.oh_buckets[i]; read_cum += r; write_cum += w; - end = 1 << (i + LL_HIST_START - units); - seq_printf(seq, "%4lu%c - %4lu%c%c: %14lu %4lu %4lu | %14lu %4lu %4lu\n", + end = BIT(i + LL_HIST_START - units); + seq_printf(seq, + "%4lu%c - %4lu%c%c: %14lu %4u %4u | %14lu %4u %4u\n", start, *unitp, end, *unitp, (i == LL_HIST_MAX - 1) ? '+' : ' ', r, pct(r, read_tot), pct(read_cum, read_tot), diff --git a/fs/lustre/obdclass/genops.c b/fs/lustre/obdclass/genops.c index 2254943..fd9dd96 100644 --- a/fs/lustre/obdclass/genops.c +++ b/fs/lustre/obdclass/genops.c @@ -1425,8 +1425,6 @@ int obd_set_max_mod_rpcs_in_flight(struct client_obd *cli, u16 max) } EXPORT_SYMBOL(obd_set_max_mod_rpcs_in_flight); -#define pct(a, b) (b ? (a * 100) / b : 0) - int obd_mod_rpc_stats_seq_show(struct client_obd *cli, struct seq_file *seq) { unsigned long mod_tot = 0, mod_cum; @@ -1452,7 +1450,7 @@ int obd_mod_rpc_stats_seq_show(struct client_obd *cli, struct seq_file *seq) unsigned long mod = cli->cl_mod_rpcs_hist.oh_buckets[i]; mod_cum += mod; - seq_printf(seq, "%d:\t\t%10lu %3lu %3lu\n", + seq_printf(seq, "%d:\t\t%10lu %3u %3u\n", i, mod, pct(mod, mod_tot), pct(mod_cum, mod_tot)); if (mod_cum == mod_tot) @@ -1464,8 +1462,6 @@ int obd_mod_rpc_stats_seq_show(struct client_obd *cli, struct seq_file *seq) return 0; } EXPORT_SYMBOL(obd_mod_rpc_stats_seq_show); -#undef pct - /* * The number of modify RPCs sent in parallel is limited * because the server has a finite number of slots per client to diff --git a/fs/lustre/osc/lproc_osc.c b/fs/lustre/osc/lproc_osc.c index d9030b7..ac64724 100644 --- a/fs/lustre/osc/lproc_osc.c +++ b/fs/lustre/osc/lproc_osc.c @@ -780,8 +780,6 @@ static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr, { NULL } }; -#define pct(a, b) (b ? a * 100 / b : 0) - static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) { struct timespec64 now; @@ -820,7 +818,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) read_cum += r; write_cum += w; - seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", + seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n", 1 << i, r, pct(r, read_tot), pct(read_cum, read_tot), w, pct(w, write_tot), @@ -844,7 +842,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) read_cum += r; write_cum += w; - seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", + seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n", i, r, pct(r, read_tot), pct(read_cum, read_tot), w, pct(w, write_tot), @@ -868,7 +866,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) read_cum += r; write_cum += w; - seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n", + seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n", (i == 0) ? 0 : 1 << (i - 1), r, pct(r, read_tot), pct(read_cum, read_tot), w, pct(w, write_tot), pct(write_cum, write_tot)); @@ -881,8 +879,6 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) return 0; } -#undef pct - static ssize_t osc_rpc_stats_seq_write(struct file *file, const char __user *buf, size_t len, loff_t *off)