From patchwork Mon Dec 18 03:16:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13496162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23C57C35274 for ; Mon, 18 Dec 2023 03:16:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89A106B0072; Sun, 17 Dec 2023 22:16:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8493D6B0074; Sun, 17 Dec 2023 22:16:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 737C86B0075; Sun, 17 Dec 2023 22:16:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 65D276B0072 for ; Sun, 17 Dec 2023 22:16:48 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 326CDC0924 for ; Mon, 18 Dec 2023 03:16:48 +0000 (UTC) X-FDA: 81578476896.29.4B40752 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by imf19.hostedemail.com (Postfix) with ESMTP id 2BF321A000A for ; Mon, 18 Dec 2023 03:16:44 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of jefflexu@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=jefflexu@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702869406; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=9i8ATnrDTtVyCKMwexeRFdWe1kstlzXZSL3LNRBLCPQ=; b=hM/CXG/h+6DdqfI3rfk9YBR2h2L6//jUEQ9kxQFPF1xo32oyNC3K89BEvKcdokd1Za0DTa KkWW7+camIaJ1eTtgN7juT1leQVQ+3QlDi+OzCJUWOmhLTl8qaWEqQKSzd+tgTihBVHrgJ 5h3erEFvKgEFXeIl0qUjTx8HjoA7mBE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702869406; a=rsa-sha256; cv=none; b=3IdTujUlZoz47LSVRQ0vOHA7apJMj/wVplOkJ6Qe3jM2jSCJeeQmnA8Q6iycSvaWGv+/Wp LzzgCA5j6ZRpZv+pQSX0kmJq+iOyyeQod7o9aBOgcPpZ2vcA+UpSi/iRBiNT13kki/hlEb plRj1aBbyCRSX1N0rQBXeP243KK6ZWI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of jefflexu@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=jefflexu@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Vye3FGX_1702869400; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vye3FGX_1702869400) by smtp.aliyun-inc.com; Mon, 18 Dec 2023 11:16:40 +0800 From: Jingbo Xu To: shr@devkernel.io, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, joseph.qi@linux.alibaba.com Subject: [PATCH] mm: fix arithmetic for bdi min_ratio and max_ratio Date: Mon, 18 Dec 2023 11:16:40 +0800 Message-Id: <20231218031640.77983-1-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 X-Rspamd-Queue-Id: 2BF321A000A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: fzdkoagt349z4xraqzprdd6fiqj5yuyi X-HE-Tag: 1702869404-876349 X-HE-Meta: U2FsdGVkX1/a1SDGz8Cppw1IrJvBzKbWxPXDRQz76geCRMKx+1U7kewdtD8s/h6cU56ttIS4zTp9xgwNa0IgHSyzcg4g8ILvFLTKkmVxRyNDWV2fn5R+YsSaBOHxhVNJ4zPQZeUDb+4Z6uZf86SZ91GAqlPL1+8C0LnqM7JufeQLGnuAadUiGjZdbr9SwrXCLvoTGCgqN9jIIpWdM0afEK1CYMjNsq+e1akIBhMcBGCBmsZdFHQXAokHIYM5/hq0/O9xbTBnHW2bDmTm/az/nGEkxadjVYSN+Vmnqak1arGt21Lo9ulCUjErMuT3WyW1cHTvkf8y6/HgTvtbmMzF6zecBf+74JXblKM8jN5QPG7Td3cVwtgwARvpGMgULFGCIkjlLFINBuCgcG22V9G+HlcuKcsA40fA7CElA5ScxhsJP/o36QOh557BZS7VdkFz2TW+LNJh56iOLD50JW8Hjc1wltSCCh+/+U03ZL+FabWhRfIkrsl2scjUowt5wkTQi9IJJUzenGVoXBGtglfAUTjqcb7sv38csrsGrLlr00sBQbwfPhDIUNLfuKjojYQobMyxviJ0u436Nv+VTGYQVsQ5ejSRsQpclhR0DsX3A353f257USMO9D/zUSMl2VO9Ahg2ifXtxn2j1pYvVB9amfg7/vT1Nd0x5Z4l/odRtRdoSo3XNKJzVK0xUGBqxThYFxdASI69aX2ywllryXw68FfMEQ2YYdv2fC1yZSI/CBMX/PyykQQ/JOZQ2qD/qfQJpKPJFBkWY9EVOGghtr5ki7sYZZK22IUqrT0B6iAR6QfLpvYd3RhNKVq3XVikiYckXXtDhqMDwZHgrPfgGhKaYkbW3MF7XazsRd+iT4SplLNsk7gPDo/F0mDc+QpQbgDTrGAunK5bcREIpjh2O1lALEAMcp1nTtYbZIGRzfDXXGHX9XfJKFGysNqM1UIpndKYsNNsKvcmly74Y0ajUmR fkiq7LF0 QsE22YKERTLDoef04aZ+XwuUmwneSs+bPmtHai/tN6qUeTgTmgKCDz9P9efDwWX/wFLB8lZ4E4LBlr+sAsSaabB+DJLjPJ7ZJjW8HMMjDo1rHgnXLQtXMmzJAYyOLACZiC/x6akajfcasHplyFgRdc7smqq5S2NGZnl4w X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: bdi->[min|max]_ratio are both part per million. Fix the wrong arithmetic when setting bdi's min_ratio and max_ratio. Fixes: efc3e6ad53ea ("mm: split off __bdi_set_max_ratio() function") Fixes: 8021fb3232f2 ("mm: split off __bdi_set_min_ratio() function") Reported-by: Joseph Qi Signed-off-by: Jingbo Xu --- 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 ee2fd6a6af40..b393b3281ce9 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -692,7 +692,6 @@ static int __bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ra if (min_ratio > 100 * BDI_RATIO_SCALE) return -EINVAL; - min_ratio *= BDI_RATIO_SCALE; spin_lock_bh(&bdi_lock); if (min_ratio > bdi->max_ratio) { @@ -729,7 +728,8 @@ static int __bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ra ret = -EINVAL; } else { bdi->max_ratio = max_ratio; - bdi->max_prop_frac = (FPROP_FRAC_BASE * max_ratio) / 100; + bdi->max_prop_frac = div64_u64(FPROP_FRAC_BASE * max_ratio, + 100UL * BDI_RATIO_SCALE); } spin_unlock_bh(&bdi_lock);