Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp268279rdh; Mon, 18 Dec 2023 20:07:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3iGa8kF5Gmkr7+rWG4m6Jb9X4UbDg5z1OTtgKfCk9mAS0W8/NSOTt9XNiYdG4LvG/iSHX X-Received: by 2002:a05:6871:798a:b0:1fb:dc3:782d with SMTP id pb10-20020a056871798a00b001fb0dc3782dmr20681557oac.55.1702958836590; Mon, 18 Dec 2023 20:07:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702958836; cv=none; d=google.com; s=arc-20160816; b=IDYhs7EU/7EnD69oS+M0AGcpRjzcii1FJq4MfzXpwfVKvQ+X/VNMn3ZUPgHmZq6vrS CRGNZJF04kpKPfUkDgwVWK2hqxkX8CEVPH2J6MBpfku2k9EBG0hjsZ3z5T40CPj/5iOs bIjcvcsyB5DsEZdVNkCL34auk2eyw/UUWm7aHtJaz5L0fDw8uMHuvm6Zay8vUUUsBWZ1 Gvl7otqxY559BQ7lvNIrcleUJe5Gv1tn1GGr6GaCLU/oKlALUEQ8oRD1n54odoK1xaAo jUToZMPYzFwG2UW2ZqHNd0GDBoBufhkLhBCe6oUNtaWBJv3SuTkTunzDpiTq1LEUH+Gy A9yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/SEF6/0irzPlvPamDsq84bR9kjT+1u9iAzLJI9PQf8w=; fh=clujZbPAUwM86QRn1WnC5L4505gpd0Fd7jlPElyq4Vg=; b=GpF+5enbri9OuG7X/3nObcGankfR+cr2xEr46OefhceJTY2fYd9UhTdYPcpTcw4eWQ 9088RS8eIjgIZXUZRAyrDlCPEzWp9RnvYEKyzPRvukMGBESkPBamHovRJwWkkBV3uXhs hpMaBeCOW1e0fdr6crrCmOdt2A6/nFTqetEOKZTMZukVoX/TtfhWaFopbGX9HmeEfO7S Q57zHqOne8M1H2TSAzgH9ABHp8QY01yCh1VZ3q3v0c+4zn6fe4gVCxuztgeot8lRzIgB iY1kWwylCgn5naFNzSKzyaU/x3f5Luaqxr5mRKUNVXF0fz8Qif+Y8wsW0dSw3Y9/I255 5sXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vTxZLBCb; spf=pass (google.com: domain of linux-kernel+bounces-4661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4661-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n188-20020a6327c5000000b005c14c9b2d90si5679026pgn.59.2023.12.18.20.07.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 20:07:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vTxZLBCb; spf=pass (google.com: domain of linux-kernel+bounces-4661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4661-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 60356B23BDF for ; Tue, 19 Dec 2023 04:07:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63EB7BE79; Tue, 19 Dec 2023 04:06:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="vTxZLBCb" X-Original-To: linux-kernel@vger.kernel.org Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 4A9828BE1; Tue, 19 Dec 2023 04:06:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/SEF6/0irzPlvPamDsq84bR9kjT+1u9iAzLJI9PQf8w=; b=vTxZLBCbJX7xG8/wyWBJmVznXP BI5vBw/mEikFJCVVWYttJEczkTPZ+0fXTupoYM57veFUTHd9d0HdiuVd27HgRrD2PtA70B/x4LkE6 iUNuUuU1+uy3S8aw0SvGQVaGD+hkHfW7m1YH/WMutIl2ZvTDOp97QJ85eM8eU/orS2YP3EX4+k5Ld hzyyj7sguxNWWitho0g0jVvnWf/6Wi+psP3Fh9gh5Ry18qJLG2c3k6ewnEkox5Lyosd4QWQI/FVrG B6aQfv2iVn07xlZ6bWlntAFN+jQlX7v+8QFulTfmVMf/PFV5p0b405x4f2PA2ndhTbOBmfkLOIQwl IgRGD0/g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rFRNK-00HZi9-G4; Tue, 19 Dec 2023 04:06:34 +0000 Date: Tue, 19 Dec 2023 04:06:34 +0000 From: Matthew Wilcox To: Jingbo Xu 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 Subject: Re: [PATCH v2 2/2] mm: fix arithmetic for max_prop_frac when setting max_ratio Message-ID: References: <20231219024246.65654-1-jefflexu@linux.alibaba.com> <20231219024246.65654-3-jefflexu@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231219024246.65654-3-jefflexu@linux.alibaba.com> 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.