Received: by 2002:a05:7412:b112:b0:f9:3106:f1c0 with SMTP id az18csp27085rdb; Sun, 17 Dec 2023 19:17:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHazaxRLhmENgKKBQWkmQ5oPAasCSYk2MetQGWl9o/11Iw3egzivzMqg22ozxGMP9iedSR3 X-Received: by 2002:a05:600c:4591:b0:40c:6c80:efa4 with SMTP id r17-20020a05600c459100b0040c6c80efa4mr2201997wmo.35.1702869419895; Sun, 17 Dec 2023 19:16:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702869419; cv=none; d=google.com; s=arc-20160816; b=IpTzVwvhO/gxooOzkBnZJLvUoszf4N71BbgPpD8SJIU7qXiryj87uClkWVfH0rr+MF KunnYlKB+xGLgUtyNBBH92jh6fA2grAXXyQAdU4GcseDGTM3CED3YrYLGdT5F47aTf/o GEuqdzMNtt8BZlX0TSI2F7mPXAe9nnI10Z5Sx1OqnakYxZ57t6Z0mDaGwKKyKpmCzKHE HGaas93hv7qkixB9H894gYyJMIl7RzIJTm5wLC+gey3a9wSIzDnqFKQ245G3jBhmnULR m0KGsWmnBtcmBogQc+k5+fxt6xEcGNdYYlLEnxd59QlncaYS76jTr1KLLvEPat/gk8zp INjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=9i8ATnrDTtVyCKMwexeRFdWe1kstlzXZSL3LNRBLCPQ=; fh=soeW4PH8uPvaMjzm9+qAYQ/kF4sfX0MpVe9LwJ4W9bA=; b=shEvOLpyCjf7u/r+/EE2gUu9+4jQP6O6riFhqOVnjq004XsJXfOboYZYHrR5pYN+VN O8pV2SaPOh292+bWPe7hxzERFT5qm80NrowMZoUj39Q88fuVAzyqULN3Q0EgnXA5YmSm pZ+bm1Cx6bHvvaCquqlHacnsLcf8IBbQB0sbrX2Gex7ZCxEu8vPpJ/6q1lnxXoNhqvEG 5xNFyKCiw/AWtK0MPc9jVsc/mlvhWkRlMsv3T9JDrVbQMdkX82Q1JOHwQIwkK5I0f1K7 hTTRdVKlRojZJ3SLPrNPAOZzEy1YqHjNuwudMLSDdNlEgV4fMKdmwDbJjoIzPI3M/Fv7 Wyew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-2965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o18-20020a1709061d5200b00a234a63a46asi907886ejh.168.2023.12.17.19.16.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 19:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-2965-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 711CF1F21AB4 for ; Mon, 18 Dec 2023 03:16:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2804F3C3F; Mon, 18 Dec 2023 03:16:52 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC3642582 for ; Mon, 18 Dec 2023 03:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.19.1.6.gb485710b