Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17194116ybl; Thu, 2 Jan 2020 00:16:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwMaBsKjplXxO5fKPGAIYm4VDonfJFt79CL2pFg9k2L8dWc7HPBt8pwXd4ZFlzCrsxnw4IU X-Received: by 2002:a9d:4c94:: with SMTP id m20mr89993421otf.341.1577953014062; Thu, 02 Jan 2020 00:16:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577953014; cv=none; d=google.com; s=arc-20160816; b=xZOWMO1pAftpAn7kXsA6xuen5fif87Wq57p6roB4Ds7NobS3lFdjzuROXJFfsu9G9b zh0cuEd3g6GX18Y1Z0daH6K3KNyhiDmPjBcHa1ffhlYYG62nsNSGcuoZGjkfdRuV1JQL 794H9nfsnzl9Zd+3trXvMcvUlEjb1EaNuLiGGZRwRsjUIJpWJLsvkVgmSlomoiqCTIDF dw6XwmTBGvfF5tANeHOUQzpLutE6SNfeLdtyEiqd6Po7o67c21n7D1WeuUQ20n7yW82l fxbhC9QOHGrW8IpUkyoqdIybeMmCXlvxEWlPF9ORzNLjQIRJIChBTHrkiy8WmXj3SEa9 hO9Q== 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=GDBXOkETL0FL34u+OCAiEuFyTrIjX1dbwmra7cuyIi4=; b=OcfhGOSEKffNt53hb2gX4no5uFk1ktIv9X3DNWWCDo8sDSVI97FYJLd9LjulvH4gNe sJ+yr+zmvykxm3VctpQD0wqj+uobiPRYeiUsAz7zED7gpHlBigi7DMIkjwXiVkadSj7Y AKRM5R+4Vf4rusCPFe92jz94dMsD3Ffg3pkVSyoaN21d3HEDySV97a8d2EfKycn0uXIi WPHUvbjcfJdgnjw6JcABF6gA5NN60Pdjckg76BC3c7sV0Li7pZXp/q4QRAiGwu0RxSTC OW9pgKWOut+y4+vtEUJJIPUXVf/q9W5U/y0JjQhJZ+q7VFSaOrk9vP9egOXOtdr5cPly A1/A== 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 v124si20760464oib.173.2020.01.02.00.16.42; Thu, 02 Jan 2020 00:16:54 -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 S1727861AbgABIPc (ORCPT + 99 others); Thu, 2 Jan 2020 03:15:32 -0500 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:35298 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727714AbgABIPb (ORCPT ); Thu, 2 Jan 2020 03:15:31 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04446;MF=wenyang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0TmaHn71_1577952921; Received: from localhost(mailfrom:wenyang@linux.alibaba.com fp:SMTPD_---0TmaHn71_1577952921) by smtp.aliyun-inc.com(127.0.0.1); Thu, 02 Jan 2020 16:15:28 +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 3/3] mm/page-writeback.c: improve arithmetic divisions Date: Thu, 2 Jan 2020 16:14:42 +0800 Message-Id: <20200102081442.8273-4-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 Use div64_ul() instead of do_div() if the divisor is unsigned long, to avoid truncation to 32-bit on 64-bit platforms. 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index c74c6bd..2caf780 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -1102,7 +1102,7 @@ static void wb_update_write_bandwidth(struct bdi_writeback *wb, bw = written - min(written, wb->written_stamp); bw *= HZ; if (unlikely(elapsed > period)) { - do_div(bw, elapsed); + bw = div64_ul(bw, elapsed); avg = bw; goto out; } -- 1.8.3.1