summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Simmons <jsimmons@infradead.org>2017-01-28 19:05:26 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-02-03 13:01:38 +0100
commit86df59846c924c2339603f4370779581e594d0e1 (patch)
treeee50820d4fae30b47639e0cf0ddb922cc36b37a1
parent1cf96da241f489fd29fe564c8fc045e51b5269b8 (diff)
downloadop-kernel-dev-86df59846c924c2339603f4370779581e594d0e1.zip
op-kernel-dev-86df59846c924c2339603f4370779581e594d0e1.tar.gz
staging: lustre: osc: avoid 64 divide in osc_cache_too_much
The use of 64 bit time introduces an expensive 64 bit division operation. Since the time lapse being calculated in osc_cache_too_much will never be more than seventy years we can cast the time lapse to an long and perform a normal 32 bit divison operation instead. Signed-off-by: James Simmons <uja.ornl@yahoo.com> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8835 Reviewed-on: https://review.whamcloud.com/23814 Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com> Signed-off-by: James Simmons <jsimmons@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_page.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index 0461408..ab9d0d7 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -370,12 +370,17 @@ static int osc_cache_too_much(struct client_obd *cli)
return lru_shrink_min(cli);
} else {
time64_t duration = ktime_get_real_seconds();
+ long timediff;
/* knock out pages by duration of no IO activity */
duration -= cli->cl_lru_last_used;
- duration >>= 6; /* approximately 1 minute */
- if (duration > 0 &&
- pages >= div64_s64((s64)budget, duration))
+ /*
+ * The difference shouldn't be more than 70 years
+ * so we can safely case to a long. Round to
+ * approximately 1 minute.
+ */
+ timediff = (long)(duration >> 6);
+ if (timediff > 0 && pages >= budget / timediff)
return lru_shrink_min(cli);
}
return 0;
OpenPOWER on IntegriCloud