Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17194448ybl; Thu, 2 Jan 2020 00:17:22 -0800 (PST) X-Google-Smtp-Source: APXvYqyJiHFT1+t7HWlQhCzbZ7yVO+IR5cjc2fEK8ADy4CoLzauRGrXdZqCJdUTBgRwydGVkyEcD X-Received: by 2002:a05:6830:1116:: with SMTP id w22mr93033993otq.63.1577953042610; Thu, 02 Jan 2020 00:17:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577953042; cv=none; d=google.com; s=arc-20160816; b=EsTrWJJe3iEcDeUFAIAK3Ri2Wf801GAx1SmpM0BprKvU0hKu1WhFvTOFfoWYx58uaO QMLhd5SrmoPnYanweH4DJVI9NAAoRMrzPClwO4mDA6aDH4jWoDVfKBy/ZCNJYxxNcXnq zOKSGoY9070PibExU/CiivschBZwtzO7CGT/go4s/Pl9VT3zkmxwmUVD+ijLw5Gy8UmO GLyul4TBH0d+3jFaPZiWjejC5P4nkBJeHbwWASl64DH8nnZhvNJjJC81rh4KqIRVTUso iaUjlF60WJxRPlrcvecxEZqWGx7rgnLpfh+CyrcyqgsxsKeVN3iuAbdy80J/TWbdpCAh V2yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jZr5WGgb6IkefqcEiVqayeC+8Svay1pwpxQEbIdmtnU=; b=dBAKGThlilhaG5/M5cAWHzhbGu9cyK2DTbdM5Rx6ExTgsc0Nbv75NKW2Af8JEbqKvY y2/fb86rETtkJ/2fPJmriQ4G+dXsSuHe9kLd9Ew7mUEzI/uQ/qpZv0K41xhlbnELtuyK gM7OISgctWUzuQ4BWtxdCSiUbrEoUdF787yV3GLyZFYUCG6AZvCCfghL1c8naMDqCzwF ntJhIFYWuYBQze0EX/b0F0MHcxdcSIL6Dck6rRgSF1dshSOymQ39IgPxiWmbw5/jwEmL Qxpg9FHWsTy3P4xdPZL6pjWdPQlPNp/U/w1a0t+XMoSdWdd/sEAhgCYfqbaJD2LwJr39 ZJeA== 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=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g126si21465422oif.106.2020.01.02.00.17.10; Thu, 02 Jan 2020 00:17:22 -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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727850AbgABIPZ (ORCPT + 99 others); Thu, 2 Jan 2020 03:15:25 -0500 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:51859 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727714AbgABIPY (ORCPT ); Thu, 2 Jan 2020 03:15:24 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07487;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0TmanhFc_1577952914; Received: from localhost(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0TmanhFc_1577952914) by smtp.aliyun-inc.com(127.0.0.1); Thu, 02 Jan 2020 16:15:21 +0800 From: Wen Yang To: Andrew Morton , Qian Cai Cc: xlpang@linux.alibaba.com, Wen Yang , Tejun Heo , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mm/page-writeback.c: use div64_ul() for u64-by-unsigned-long divide Date: Thu, 2 Jan 2020 16:14:41 +0800 Message-Id: <20200102081442.8273-3-wenyang@linux.alibaba.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200102081442.8273-1-wenyang@linux.alibaba.com> References: <20200102081442.8273-1-wenyang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Signed-off-by: Wen Yang Cc: Andrew Morton Cc: Qian Cai Cc: Tejun Heo Cc: Jens Axboe Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/page-writeback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 2d658b2..c74c6bd 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -766,7 +766,7 @@ static unsigned long __wb_calc_thresh(struct dirty_throttle_control *dtc) 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(struct dirty_throttle_control *dtc) 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); -- 1.8.3.1