[09/11] mm/page-writeback.c: improve arithmetic divisions
diff mbox series

Message ID 20200114002929.P5URA%akpm@linux-foundation.org
State New
Headers show
Series
  • [01/11] mm, thp: tweak reclaim/compaction effort of local-only and all-node allocations
Related show

Commit Message

Andrew Morton Jan. 14, 2020, 12:29 a.m. UTC
From: Wen Yang <wenyang@linux.alibaba.com>
Subject: mm/page-writeback.c: improve arithmetic divisions

Use div64_ul() instead of do_div() if the divisor is unsigned long, to
avoid truncation to 32-bit on 64-bit platforms.

Link: http://lkml.kernel.org/r/20200102081442.8273-4-wenyang@linux.alibaba.com
Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Qian Cai <cai@lca.pw>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/page-writeback.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch
diff mbox series

--- a/mm/page-writeback.c~mm-page-writebackc-improve-arithmetic-divisions
+++ a/mm/page-writeback.c
@@ -1102,7 +1102,7 @@  static void wb_update_write_bandwidth(st
 	bw = written - min(written, wb->written_stamp);
 	bw *= HZ;
 	if (unlikely(elapsed > period)) {
-		do_div(bw, elapsed);
+		bw = div64_ul(bw, elapsed);
 		avg = bw;
 		goto out;
 	}