Skip to content

Commit 86df598

Browse files
jamesasimmonsgregkh
authored andcommitted
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 <[email protected]> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8835 Reviewed-on: https://review.whamcloud.com/23814 Reviewed-by: Andreas Dilger <[email protected]> Reviewed-by: Dmitry Eremin <[email protected]> Signed-off-by: James Simmons <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1cf96da commit 86df598

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/staging/lustre/lustre/osc/osc_page.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,17 @@ static int osc_cache_too_much(struct client_obd *cli)
370370
return lru_shrink_min(cli);
371371
} else {
372372
time64_t duration = ktime_get_real_seconds();
373+
long timediff;
373374

374375
/* knock out pages by duration of no IO activity */
375376
duration -= cli->cl_lru_last_used;
376-
duration >>= 6; /* approximately 1 minute */
377-
if (duration > 0 &&
378-
pages >= div64_s64((s64)budget, duration))
377+
/*
378+
* The difference shouldn't be more than 70 years
379+
* so we can safely case to a long. Round to
380+
* approximately 1 minute.
381+
*/
382+
timediff = (long)(duration >> 6);
383+
if (timediff > 0 && pages >= budget / timediff)
379384
return lru_shrink_min(cli);
380385
}
381386
return 0;

0 commit comments

Comments
 (0)