Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp164193ybl; Tue, 7 Jan 2020 04:09:11 -0800 (PST) X-Google-Smtp-Source: APXvYqy9CLGczoPwESx+U9gB2VPErW0s3+YdDNr6tkcCQAzRIDasSGXyDEmSskQ84gUskC2ic+tV X-Received: by 2002:a9d:1e88:: with SMTP id n8mr123784027otn.369.1578398950914; Tue, 07 Jan 2020 04:09:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578398950; cv=none; d=google.com; s=arc-20160816; b=L/mdnxc8hJPQ6U8HqqxhuCROLNPThDJ39GSRB8rHjAq/7Oeh6rl6XzdkUvv2UeUSn5 7f3qhn/ViN072jaJbCw6eOR2cHQ3IQpFP4hCR9w4iY8duGzQd3KyTJoML7CnUB13/ncX bv6BtRbewbqyClS7W3CW787iJftV1FLIcq0YeDTR+DP4mmCHIaaZPWBHWuBYxCjZwgqj nT7DI0VCtCi/Pu4ybAUTKBCX4eUXC1nudOUnud7v64LhcUgXxElI7+j6vjRIhyqfX23S 1CT0OlYc5fmSM9veAYtqp4TZvpb1ful7PYXZdQvTT2hoQPxwiK+slbLnqKgJ25O0CO8E TD6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=zJ7Soe4Ipf76O97lFC/HUE2dza3yg3mUCQ8NQLtNlnw=; b=AUMbwmK0/6RtyUO8sr/bGWo82/K6uGlyF/m2fDlFHNFwi21WbEI/JjKC8s5ED6KLna FJhdWBQhz1DGyE02rGVG8EO/4cwqqDLiWMTXcc2L5w2giR7UdAdHyOkX/mFWFalrpFf4 xt3ndtI1KSAmHTLI9k9k7w8HhqMvvLgQmVd/lJCu3jrSo0Yqf9U0tMqYiC78NdqNVaVI 9IL4/DFEBXyW7XEy4VQmey3ILQNmIB2R1VKGV8Kkk5r+JiTWI5hUYq6o4xpD0EczkV8I V7jX3LwTrA0SphkZmTyNzir6oAdWZ9boI/NQrJ8nzhnw20MfJ4zIZbUl9a/EC9qg5muD 2f9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12si3291336otn.90.2020.01.07.04.08.57; Tue, 07 Jan 2020 04:09:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727940AbgAGLnx (ORCPT + 99 others); Tue, 7 Jan 2020 06:43:53 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:34422 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726690AbgAGLnx (ORCPT ); Tue, 7 Jan 2020 06:43:53 -0500 Received: by mail-ot1-f68.google.com with SMTP id a15so76062126otf.1; Tue, 07 Jan 2020 03:43:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zJ7Soe4Ipf76O97lFC/HUE2dza3yg3mUCQ8NQLtNlnw=; b=lkgZ8aa1AIVKUV2EGHcXkmkOU5S/2wz3ZW5rrb87BOb3AxAFphlRRcxrC3HpqO3l1q 8/WNh/leB1S1V1de/kaAfmGAC0xYsn28nUU6EHUfe1NMxjcKAmiewE/TJWRLqztI6uWZ hMOlKMGV3mpnyskM4Hxu5abiwq8cSR8gl3566R1DHEhfg93KOYAEkXQX3vfbJhUtIsRC lQS0D425axUl3EmRKZFZeigpH5i0qbzWPeMBIwyqmhlXzHaUHftqS7p38GB+SU0oNmGZ PG9Uwpok6ux4/20izCbMb1domRr3vbtzvsDtdFNQGmNLG4VduzGYsFv3IkZpxuxVon5M tLnw== X-Gm-Message-State: APjAAAWii/xo/5G34xH/DfjHW3k0+bUiJFNhAZQFOHbS5m+bvleRDDkj fgTeWACCbRahtGpSftaep6yv20HNYGSXx6RmQKBiUBYR X-Received: by 2002:a05:6830:3003:: with SMTP id a3mr15682871otn.118.1578397432443; Tue, 07 Jan 2020 03:43:52 -0800 (PST) MIME-Version: 1.0 References: <20200103155458.21707-1-wenyang@linux.alibaba.com> In-Reply-To: <20200103155458.21707-1-wenyang@linux.alibaba.com> From: "Rafael J. Wysocki" Date: Tue, 7 Jan 2020 12:43:41 +0100 Message-ID: Subject: Re: [PATCH] kernel/power/snapshot.c: improve arithmetic divisions To: Wen Yang Cc: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Linux PM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 3, 2020 at 4:55 PM Wen Yang wrote: > > 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 > Cc: "Rafael J. Wysocki" > Cc: Len Brown > Cc: Pavel Machek > Cc: linux-pm@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- > kernel/power/snapshot.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c > index 26b9168..8a6eaf7 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, > -- Applied as 5.6 material under a new subject ("PM: hibernate: improve arithmetic division in preallocate_highmem_fraction()"), thanks!