Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp524689rdh; Tue, 19 Dec 2023 06:13:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGu7lNVD61H2zJMLXY2MJMd52Nh1reahb8L95Zxx+d3cIc+X5Bg0f06zoiUFxNiMvlJRqz X-Received: by 2002:a19:2d02:0:b0:50e:3121:1a12 with SMTP id k2-20020a192d02000000b0050e31211a12mr2199304lfj.110.1702995204718; Tue, 19 Dec 2023 06:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702995204; cv=none; d=google.com; s=arc-20160816; b=wlGe2ggVQr+R27ggvLOJSFNjfmg7Cj5uX2zpnUPMsd5WXvytv80Lzhr7RJjWd3QPVb TIVOElKazROflNpXPfCSpohDAas/PPiGHtqvJQ/2yGhrKNcSsqvNFUVPsv0jnPn4wPp/ uN1QbMqqohLjgmpOhmE8s7nltNwVhHnFIUmAeytMhficwCOnSMUaInV16TPtZsVFEtun qg+6kCkIbjuBq20r6CBGdUC2XuonvuC3O85bJxgZbfbYYqf7BV+SMrbuoHz5S/Oc10S5 rRp4vWG5NcYqV1CbYRRmE0LVv8/0OvDcx5OZm0SjfAa1rScvqYRc5dkVhiHutz6c2A+g KpbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=buk4enNqW9/o6gPifmODdWeFUZDoM4i6k3HiOw8tw14=; fh=mqnS2zA2veWjD/ESFj6gpWqOcfVOCzvDop6rCuUjwJ0=; b=g2m911AG1UVWNa1wGPlqHnDx52G/2EF9pfOjxTEoG7EcYy0ELgjO0Go9LzycbcrhNI vRNvw5MHq1C63q0P9fjugqja3DcCo/XELpoV40X1HAYGImKWxt92kY8UupcL7thc9Gbc Zu98girqPTWfwYUMkO19mtoYfarNIOVg0t8HNndlbSIOqdKYvWFO6AvK42W8u5F2ceO9 4HHO/1eSUR/cWjUefyAeWcNdzJU1vLK8mtpxmKqHrg68CDuFOuRz8SzUoQjZO0OWfvqI spwdB1DXswlkqPwBLJcqvCBX4qBU/8LorX3S/IBnWE8JZZe43PGQLq509EVVQZKtkGeN idog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5334-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5334-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 eb11-20020a0564020d0b00b0054d97562779si11304770edb.616.2023.12.19.06.13.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 06:13:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5334-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-5334-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5334-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 786271F25086 for ; Tue, 19 Dec 2023 14:13:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA77E1D55F; Tue, 19 Dec 2023 14:12:40 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (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 4E4101D528; Tue, 19 Dec 2023 14:12:36 +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=01201311R191e4;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=8;SR=0;TI=SMTPD_---0Vyr8ugS_1702994833; Received: from 192.168.31.58(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vyr8ugS_1702994833) by smtp.aliyun-inc.com; Tue, 19 Dec 2023 22:07:14 +0800 Message-ID: Date: Tue, 19 Dec 2023 22:07:12 +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 v2 2/2] mm: fix arithmetic for max_prop_frac when setting max_ratio Content-Language: en-US To: Matthew Wilcox Cc: shr@devkernel.io, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, joseph.qi@linux.alibaba.com, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org References: <20231219024246.65654-1-jefflexu@linux.alibaba.com> <20231219024246.65654-3-jefflexu@linux.alibaba.com> <5460aaf1-44f6-475f-b980-cb9058cc1df4@linux.alibaba.com> From: Jingbo Xu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/19/23 9:01 PM, Matthew Wilcox wrote: > On Tue, Dec 19, 2023 at 01:58:21PM +0800, Jingbo Xu wrote: >> On 12/19/23 12:06 PM, Matthew Wilcox wrote: >>> On Tue, Dec 19, 2023 at 10:42:46AM +0800, Jingbo Xu wrote: >>>> } 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); >>>> } >>> >>> Why use div64_u64 here? >>> >>> FPROP_FRAC_BASE is an unsigned long. max_ratio is an unsigned int, so >>> the numerator is an unsigned long. BDI_RATIO_SCALE is 10,000, so the >>> numerator is an unsigned int. There's no 64-bit arithmetic needed here. >> >> Yes, div64_u64() is actually not needed here. So it seems >> >> bdi->max_prop_frac = FPROP_FRAC_BASE * max_ratio / 100 / BDI_RATIO_SCALE; >> >> is adequate? > > I'd rather spell that as: > > bdi->max_prop_frac = (FPROP_FRAC_BASE * max_ratio) / > (100 * BDI_RATIO_SCALE); > > It's closer to how you'd write it out mathematically and so it reads > more easily. At least for me. Thanks, I would send v3 soon. -- Thanks, Jingbo