summaryrefslogtreecommitdiffstats
path: root/kernel/power
diff options
context:
space:
mode:
authorWen Yang <wenyang@linux.alibaba.com>2020-01-03 23:54:58 +0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2020-01-07 12:42:56 +0100
commit809ed78a832df8b4ef81fee03570566c8f088f3a (patch)
treef6d2756479859f245c57e13cbb045bf637d38832 /kernel/power
parente976eb4b91e906f20ec25b20c152d53c472fc3fd (diff)
downloadlinux-809ed78a832df8b4ef81fee03570566c8f088f3a.tar.bz2
PM: hibernate: improve arithmetic division in preallocate_highmem_fraction()
do_div() does a 64-by-32 division. Use div64_u64() instead of do_div() if the divisor is u64, to avoid truncation to 32-bit. This change also cleans up code a tad. Signed-off-by: Wen Yang <wenyang@linux.alibaba.com> [ rjw: Subject ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/power')
-rw-r--r--kernel/power/snapshot.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 26b9168321e7..8a6eaf7367f3 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1566,9 +1566,7 @@ static unsigned long preallocate_image_highmem(unsigned long nr_pages)
*/
static unsigned long __fraction(u64 x, u64 multiplier, u64 base)
{
- x *= multiplier;
- do_div(x, base);
- return (unsigned long)x;
+ return div64_u64(x * multiplier, base);
}
static unsigned long preallocate_highmem_fraction(unsigned long nr_pages,