From 0096afdb7404f649b69a8c528eed6c48593cb226 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 19 Jun 2019 23:43:30 -0400 Subject: [PATCH] LU-4423 lprocfs: use log2.h macros instead of shift loop. These shift loops seem to be trying to avoid doing a multiplication. The same effect can be achieved more transparently using rounddown_pow_of_two(). Even though there is a multiplication in the C code, the resulting machine code just does a single shift. As rounddown_pow_of_two() is not defined for 0, and as we cannot be positively use the blk_size is non-zero, use blk_size ?: 1. Change-Id: Ie4cec1ca3f30617df0022a9c0dd80fe7e755ed64 Signed-off-by: NeilBrown Reviewed-on: https://review.whamcloud.com/35274 Tested-by: Jenkins Reviewed-by: Petros Koutoupis Tested-by: Maloo Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- lustre/obdclass/lprocfs_status.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 87d2af8..6f81f5d 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -425,9 +425,7 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, u32 blk_size = osfs.os_bsize >> 10; u64 result = osfs.os_blocks; - while (blk_size >>= 1) - result <<= 1; - + result *= rounddown_pow_of_two(blk_size ?: 1); return sprintf(buf, "%llu\n", result); } -- 1.8.3.1