Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp534462rdh; Tue, 19 Dec 2023 06:27:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUqd5FfJGKivf93ssfGW9l/j+rJ5tDJG/u86fKT6qdgwoRhizuT2Rjj5ETY9Ia5tJL53w0 X-Received: by 2002:a05:6a20:a11f:b0:190:4c11:28a3 with SMTP id q31-20020a056a20a11f00b001904c1128a3mr10873424pzk.6.1702996059236; Tue, 19 Dec 2023 06:27:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702996059; cv=none; d=google.com; s=arc-20160816; b=eDXWT9JgSC3QlNFMC1hFvuZ7xDwWa63dzSGSrHedvBeSG8p9VorT52z+pfLWQe9S13 XXrdQzri5Ar0F7Ru2u6ERubwl0YifBnpt7e/uWK3FH2BKcmCl8szqEvyMGmCv78mHOZO EQe0Jauo+BYvCpNf3cliT1jlrSbyq8O3fwdfQkAlE6BK6KamJxED776qZSXy4EAhoSAo 7ZfUqbfKA13T0+vFlMWUTYSFTFJLorFADgVmgscZ2RzW3MvkpVaDn0LPBRKye+Cqexei lPzpGIL/GTlICfCiussttLWGjgoaWO1b5ijPVDzW4IAISPDLYCWYMniXWbRoyTwwr0ST 5P0w== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=JzvlAyfuSBNRCYc7e0SW2Z5eCaS2ryGgH9YUXOqWS3Q=; fh=e/E5Z5uKag/MmdmVaHa/8oiovY/7OlXJBsHI95ofI58=; b=cODb+J+Je2kT9pTbreibX7QRUxK01J/FI9+SwaojwaA409x8AuborgQFUQHo80LznK pFz1ocHkb6ponsZJThOK0CDF0Vm747CyD9FOcANHPhLcETbzalGgVjgUEK+ZlWLZhfFP pzatNDnRlwfeNSXG1NRP/LuBSLJJ+YyjaGcTdIDaEdmERHACw0Diz4b47HLbH4p3CHY+ cF0nfXvkwdgRxraOVK8GFsiNaosKtUJpELYzvJl3hcf/xxJEZTa0HWSSDLFfdrud86Ij xqq8q1bE7BMcK72WEWI+8u9jL6ZZnTTNWqZXRA7uZ/tQfNJP/1blTmlnz+rm8qYztH9L FtkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5352-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q12-20020a056a00088c00b006cddc343ceesi20055933pfj.181.2023.12.19.06.27.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 06:27:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5352-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5352-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 15DF428307F for ; Tue, 19 Dec 2023 14:25:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18F151C284; Tue, 19 Dec 2023 14:25:17 +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 9017C1B27A; Tue, 19 Dec 2023 14:25:13 +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=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Vyr7WbG_1702995910; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vyr7WbG_1702995910) by smtp.aliyun-inc.com; Tue, 19 Dec 2023 22:25:10 +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, willy@infradead.org Subject: [PATCH v3 1/2] mm: fix arithmetic for bdi min_ratio Date: Tue, 19 Dec 2023 22:25:07 +0800 Message-Id: <20231219142508.86265-2-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20231219142508.86265-1-jefflexu@linux.alibaba.com> References: <20231219142508.86265-1-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-Transfer-Encoding: 8bit Since now bdi->min_ratio is part per million, fix the wrong arithmetic. Otherwise it will fail with -EINVAL when setting a reasonable min_ratio, as it tries to set min_ratio to (min_ratio * BDI_RATIO_SCALE) in percentage unit, which exceeds 100% anyway. # cat /sys/class/bdi/253\:0/min_ratio 0 # cat /sys/class/bdi/253\:0/max_ratio 100 # echo 1 > /sys/class/bdi/253\:0/min_ratio -bash: echo: write error: Invalid argument Fixes: 8021fb3232f2 ("mm: split off __bdi_set_min_ratio() function") Reported-by: Joseph Qi Signed-off-by: Jingbo Xu --- mm/page-writeback.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index ee2fd6a6af40..2140382dd768 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) { -- 2.19.1.6.gb485710b