Skip to content

Commit 5199da0

Browse files
jankaravijay-suman
authored andcommitted
Revert "mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again"
commit 30139c7 upstream. Patch series "mm: Avoid possible overflows in dirty throttling". Dirty throttling logic assumes dirty limits in page units fit into 32-bits. This patch series makes sure this is true (see patch 2/2 for more details). This patch (of 2): This reverts commit 9319b64. The commit is broken in several ways. Firstly, the removed (u64) cast from the multiplication will introduce a multiplication overflow on 32-bit archs if wb_thresh * bg_thresh >= 1<<32 (which is actually common - the default settings with 4GB of RAM will trigger this). Secondly, the div64_u64() is unnecessarily expensive on 32-bit archs. We have div64_ul() in case we want to be safe & cheap. Thirdly, if dirty thresholds are larger than 1<<32 pages, then dirty balancing is going to blow up in many other spectacular ways anyway so trying to fix one possible overflow is just moot. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 9319b64 ("mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again") Signed-off-by: Jan Kara <[email protected]> Reviewed-By: Zach O'Keefe <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 2820005edae13b140f2d54267d1bd6bb23915f59) FOF: 0924 Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 1f03bcb commit 5199da0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/page-writeback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ static inline void wb_dirty_limits(struct dirty_throttle_control *dtc)
15291529
*/
15301530
dtc->wb_thresh = __wb_calc_thresh(dtc);
15311531
dtc->wb_bg_thresh = dtc->thresh ?
1532-
div64_u64(dtc->wb_thresh * dtc->bg_thresh, dtc->thresh) : 0;
1532+
div_u64((u64)dtc->wb_thresh * dtc->bg_thresh, dtc->thresh) : 0;
15331533

15341534
/*
15351535
* In order to avoid the stacked BDI deadlock we need

0 commit comments

Comments
 (0)