+ mm-page-writebackc-use-div64_ul-for-u64-by-unsigned-long-divide.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm/page-writeback.c: use div64_ul() for u64-by-unsigned-long divide
has been added to the -mm tree.  Its filename is
     mm-page-writebackc-use-div64_ul-for-u64-by-unsigned-long-divide.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/mm-page-writebackc-use-div64_ul-for-u64-by-unsigned-long-divide.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/mm-page-writebackc-use-div64_ul-for-u64-by-unsigned-long-divide.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Wen Yang <wenyang@xxxxxxxxxxxxxxxxx>
Subject: mm/page-writeback.c: use div64_ul() for u64-by-unsigned-long divide

The two variables 'numerator' and 'denominator', though they are declared
as long, they should actually be unsigned long (according to the
implementation of the fprop_fraction_percpu() function)

And do_div() does a 64-by-32 division, while the divisor 'denominator' is
unsigned long, thus 64-bit on 64-bit platforms.  Hence the proper function
to call is div64_ul().

Link: http://lkml.kernel.org/r/20200102081442.8273-3-wenyang@xxxxxxxxxxxxxxxxx
Signed-off-by: Wen Yang <wenyang@xxxxxxxxxxxxxxxxx>
Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Qian Cai <cai@xxxxxx>
Cc: Tejun Heo <tj@xxxxxxxxxx>
Cc: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/page-writeback.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/mm/page-writeback.c~mm-page-writebackc-use-div64_ul-for-u64-by-unsigned-long-divide
+++ a/mm/page-writeback.c
@@ -766,7 +766,7 @@ static unsigned long __wb_calc_thresh(st
 	struct wb_domain *dom = dtc_dom(dtc);
 	unsigned long thresh = dtc->thresh;
 	u64 wb_thresh;
-	long numerator, denominator;
+	unsigned long numerator, denominator;
 	unsigned long wb_min_ratio, wb_max_ratio;
 
 	/*
@@ -777,7 +777,7 @@ static unsigned long __wb_calc_thresh(st
 
 	wb_thresh = (thresh * (100 - bdi_min_ratio)) / 100;
 	wb_thresh *= numerator;
-	do_div(wb_thresh, denominator);
+	wb_thresh = div64_ul(wb_thresh, denominator);
 
 	wb_min_max_ratio(dtc->wb, &wb_min_ratio, &wb_max_ratio);
 
_

Patches currently in -mm which might be from wenyang@xxxxxxxxxxxxxxxxx are

mm-page-writebackc-avoid-potential-division-by-zero-in-wb_min_max_ratio.patch
mm-page-writebackc-use-div64_ul-for-u64-by-unsigned-long-divide.patch
mm-page-writebackc-improve-arithmetic-divisions.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux