From patchwork Tue Dec 19 02:42:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 13497802 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 DCB8AC35274 for ; Tue, 19 Dec 2023 02:42:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B0746B0087; Mon, 18 Dec 2023 21:42:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C3526B0088; Mon, 18 Dec 2023 21:42:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C8BA6B0089; Mon, 18 Dec 2023 21:42:55 -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 1613E6B0087 for ; Mon, 18 Dec 2023 21:42:55 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E0647160211 for ; Tue, 19 Dec 2023 02:42:54 +0000 (UTC) X-FDA: 81582020268.02.542B5EC Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by imf18.hostedemail.com (Postfix) with ESMTP id DE0FB1C001C for ; Tue, 19 Dec 2023 02:42:52 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf18.hostedemail.com: domain of jefflexu@linux.alibaba.com designates 115.124.30.100 as permitted sender) smtp.mailfrom=jefflexu@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702953773; 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:in-reply-to:references:references; bh=JlE4XJUUwV2KLFNjzT//uSZMf3onk5ZKbvoCASYWm4M=; b=ySmVljw/jdvgMnskm/KrHjSYjfZ0kXlsYQ/butbRD8aiQ15MgXULM1YZZ0ypS7DYAyyayw rATlqkS963eK5y/stOklhiNgILs+KcaxlePtpSsfkVD9blLdTb7zoCqMJSnBleW3VIi6he Z4gqlIjWLCKTZgkCZNpL89UELAVlBbo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf18.hostedemail.com: domain of jefflexu@linux.alibaba.com designates 115.124.30.100 as permitted sender) smtp.mailfrom=jefflexu@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702953773; a=rsa-sha256; cv=none; b=xgXvEmQwENtGZYmRjv9YHB9g00sx07nY8MjYPClrHyg8UaZdfzsR5xjweNNP9DNsykevHA /c+fMCxaaajoiOCgMqWgh00IZYrWgpQUoTVYHG7elq3g0VI1z6gAPKZpeLrrYEG6m5v45I kgU2dfTsxaUEU2j27wQmdfUx1v6KNmI= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R491e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Vyp79GX_1702953768; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vyp79GX_1702953768) by smtp.aliyun-inc.com; Tue, 19 Dec 2023 10:42:49 +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, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH v2 2/2] mm: fix arithmetic for max_prop_frac when setting max_ratio Date: Tue, 19 Dec 2023 10:42:46 +0800 Message-Id: <20231219024246.65654-3-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20231219024246.65654-1-jefflexu@linux.alibaba.com> References: <20231219024246.65654-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: DE0FB1C001C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 7c5g4uhe8fnmqjdsiackc1stfdu9u515 X-HE-Tag: 1702953772-409458 X-HE-Meta: U2FsdGVkX19hr8dVt0yui7DnwJLUcUsBVwqtwNucRFifwurx2upTbbLlChva41FC1Jt4A0/SpvXWXzvNgEYBTbngPX386BPtyz5n08NdO/mU+sRqxv9iI0cLDwFEaE/9DCPlBw9m60VBG6FcFENt/mL/KaGtUiXzaQClxdvrD6PEpUsSYV69rEDAqgF/vk5Npwnc0oUTQwcPFkYFQ/KYfRF7qzuKOCbcynlLkmaYmE2NpHMKAUPtFjPPuhCXNQOqZKgg8gvyD9Age8u0NISnwa6pFIxJ8qRYSrzFrCbxwvO7gtPZxMhIXjdrRorcCvzEKTZMi4DWX9R+iVAqpGOCR2XP8rw0pH+AfPXr8e7rBdzz8faRReZevtY9TUUPs8ocp/3+PmWSAi946RfDmBAHG19qh1BsAwoFjaXQeXJaXq8bj1DNaPDg7uBew8vO1+89qOoGrvlh8JaDUsTqZDv1d+RGpO81x6pdWFk9raXab7Q22PdrTEIsLVNjuR9jD+GjLiXITMUjSpLKqXLc7AzYFwtFra7+n8iL9PNidFr2QNY+pftMFS1MlYZV0H1FA+J3hShnChXV8JRaiUDiusaiPh4Qc8ZUTTYD10MGoaNinUPDcQNxj1yRyL/hDSKFcitl9OswCXAerqjM/jJoeMenYWmrzk7BgdE4oep2+3u03uUKUJzqc/S5i1ioOAsCjKYCUIE+OeHXTQbQMiyb+C9EVu04v3jzR2262cz56v3V91LDDKyHFzsWhtHUBq3JW5iFUJ5j79662S/eQKYCqXlT0USCRchWq/hbCCUVZnKtn5l7Ic4AbghdluyyKg2R7Xfz/ghGtftiJUYvNiQBus1intshe04TftJAaO0GYfvsjUtK2wUJIMzyYDUZDYudEfAyBwil4B9mGLLBnvyCXmMTKmBfxyt5q2+rnBUrv2TheAuXdqfD77FIUo6/+aczclX2ycSGUzSxYz9mMyLkIol Tj84luv3 XMjn0AMkb/txdJGfaqF+tPvc1RHjGZg6p99kXy2fLF0m54m3YDyR7BaIK4jwN5vdx1uZIfXKokQGSCft9SFD+Da3mt0Bqxz9lM19KMWaKveIPK37Mfztng6cGLPoxo2OIxcg+s3vs8KFINRKQSwfSzaKFm2WZXDuvWQ4k X-Bogosity: Ham, tests=bogofilter, spamicity=0.000042, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since now bdi->max_ratio is part per million, fix the wrong arithmetic for max_prop_frac when setting max_ratio. Otherwise the miscalculated max_prop_frac will affect the incrementing of writeout completion count when max_ratio is not 100%. Fixes: efc3e6ad53ea ("mm: split off __bdi_set_max_ratio() function") Signed-off-by: Jingbo Xu --- mm/page-writeback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 2140382dd768..dda59b368c01 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -728,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, + 100 * BDI_RATIO_SCALE); } spin_unlock_bh(&bdi_lock);