From: Andrew Perepechko Date: Tue, 12 Apr 2016 20:14:12 +0000 (-0400) Subject: staging: lustre: lprocfs: implement log2 using bitops X-Git-Tag: v4.7-rc1~90^2~332 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b3ffe666ca1a747ce399d7d0966a132235e40e66;p=karo-tx-linux.git staging: lustre: lprocfs: implement log2 using bitops This patch implements log2 using fls. Signed-off-by: Andrew Perepechko Reviewed-by: Alexander Boyko Reviewed-by: alexander_zarochentsev@xyratex.com Reviewed-by: Vitaly Fertman Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3496 Xyratex-bug-id: MRP-999 Reviewed-on: http://review.whamcloud.com/6757 Reviewed-by: John L. Hammond Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 9824c8868cdf..b2f309d97c85 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1472,10 +1472,10 @@ EXPORT_SYMBOL(lprocfs_oh_tally); void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value) { - unsigned int val; + unsigned int val = 0; - for (val = 0; ((1 << val) < value) && (val <= OBD_HIST_MAX); val++) - ; + if (likely(value != 0)) + val = min(fls(value - 1), OBD_HIST_MAX); lprocfs_oh_tally(oh, val); }