Received: by 2002:a05:7412:b112:b0:f9:3106:f1c0 with SMTP id az18csp30547rdb; Sun, 17 Dec 2023 19:30:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFso8DSAxurt7K4RuyGU5d6smj8Iosymx2LUSAPI7ReJk+dPgYkLKh8aslAkLV6yaYaYdH X-Received: by 2002:a17:907:c914:b0:a23:34f1:b02d with SMTP id ui20-20020a170907c91400b00a2334f1b02dmr2045061ejc.7.1702870213967; Sun, 17 Dec 2023 19:30:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702870213; cv=none; d=google.com; s=arc-20160816; b=jS8Ysv3O8vAX4vlbfboAmdM38/Z/UoUSnrbPhIR1GgYt2Ent/pS1zGBHfflGTVA0IJ la2AekTz1aZzuenZh1nHdFZeC3IZJhkgdypV4HmMq6KzNHwtHvIrZBqUQ+IpmjchGMoL fb5TLMQH+YF3CS5HWdcAwwhBJyBK9YrRaMIaal8EOhNTRY9ErGYWYOfKkp/1Eg4+x00s Bek1RF5YmrrhNhIz+u6N9wwfXHweIo0r0CSxC/9gBa9CsNw9Pz0BZGPClXlzXgTVm+od wcBQbajSGKzUgH7T0ed2N2zdi13J3sZm4tPap70xCyC9g96q/z63H71be/O6FLV1gqbO 1oSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=F7gqXQloaL0taZNL59uwn6vMgd462zTGy0af515z92I=; fh=1bSh28XJDg7phaeB3TvIaNpMbzBLvc18N6bj8EgLLMI=; b=JUJU4Ui2ulgFO5N6XQloPTsx0uLlKWqR6DRi4q+kkvK5JDEayV6Xx3/hGCe7oWClHq q0A9JY9ZWWIPaZQWWJv1ZzcjT7m98+WtgYtGKJ0CfTS9IRYMDN/AOqRlH2coYl36SDLe SrwAvJaL+znqdpC4rZlG6K3YsQnQ/a8t9aaTL0NiOhsl73E4m9UKb1DXcSWWiM2yhMzd g0+NfPRNGYXjJ1+ZBeZgovtGOQbNDbK6MCxoGNyvSnnn98GZiSx36N114hk3fgCBW/mM 0YcZmaCAExzxE7atcNxvOC4LOx1dFTIVzlzj0hzsH2Lu+26KHjCueRH/cYihYXrdvq4A xDXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-2970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2970-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lx27-20020a170906af1b00b00a23607ba95asi157328ejb.71.2023.12.17.19.30.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 19:30:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-2970-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2970-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 B60F71F2241F for ; Mon, 18 Dec 2023 03:30:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2454A538B; Mon, 18 Dec 2023 03:30:02 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (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 4D5D43D64; Mon, 18 Dec 2023 03:29:57 +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=01201311R961e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0Vye8VXv_1702870188; Received: from 30.221.145.126(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vye8VXv_1702870188) by smtp.aliyun-inc.com; Mon, 18 Dec 2023 11:29:49 +0800 Message-ID: <88cf7dcf-ec74-4176-9273-dbbc49dea271@linux.alibaba.com> Date: Mon, 18 Dec 2023 11:29:48 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: fix arithmetic for bdi min_ratio and max_ratio 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, "linux-fsdevel@vger.kernel.org" References: <20231218031640.77983-1-jefflexu@linux.alibaba.com> Content-Language: en-US In-Reply-To: <20231218031640.77983-1-jefflexu@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit +cc fsdevel On 12/18/23 11:16 AM, Jingbo Xu wrote: > 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); > -- Thanks, Jingbo