Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp242771rdh; Mon, 18 Dec 2023 18:43:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IG61EJMu4b/uYFP9BfW5pLVz3qtI3b2L9a1v6qt7PIGHlPPglJpGYNCjO26TOqXbOAyyYCy X-Received: by 2002:a05:6a20:9699:b0:191:5fba:7e9d with SMTP id hp25-20020a056a20969900b001915fba7e9dmr13776306pzc.32.1702953832581; Mon, 18 Dec 2023 18:43:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702953832; cv=none; d=google.com; s=arc-20160816; b=hoze7gOn1gbwdkcXC0VnTsgaX14vDRiGJKR13Vju301UB7bqZ68zcdQQhicNE+A96q z9hH3MZBMPhQqwD4MUvm7w1NHRNt/CdU4mhQaWIuoIlrZZR04xXgeYhMhDx9dT+8SPgQ lqCa6rzMwhFeemKFBZyAnritcrHOdDUx7UtrLHgxvf+MjB2JUaWHUiCdw6QcqvX9k0En g4uulP/6/oauVArrR/yVmEikxBJkeKiEAtZ0QxD4iIxSZxJOxeB3WCxCdSm2D435+lK8 FGtEySWNAo8HvxdoL8/o+VWoJcUF00+opgGAOxeexRUWO9ZLkxSKLgYqeU98esy2j9dF Wuiw== 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=LhRAuR7mnPUf2lm0avoqobx1z6sFYhmPMF/sryImvNg=; b=U48u7NzXnu429m+3pnzdy7VvN7sg+dGEnnBqAMCx/Ktl2axVH9LoX+jRxymyRk1CZ3 7IM4IlENuZlsFOG53C4Voa+F8u/z7UmiHXmzulbGEB5I4VPD9QRO0RWtYtOug2UfXyB7 StZtX++xI8kO8WUgmPf6l143VUVOGsWxoj6KkOdr3YBUh/MrE5PaO1JFV70Ca2KZG8ak RxnZxMeDZCcuJbUcyzsS32DEPyhW17roxth0eZSWGClFp6z+n2S6J8V7di0cYwvjybJ2 Q9ETWGgBl1CJsfZyOLtrpgUB85LJqbeJ4DQR8UdsL7T7pXp0w3ClZ9zO2wcwWwL78Ni7 rIIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4611-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4611-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g18-20020a056a000b9200b006cb6b7aa192si19145236pfj.331.2023.12.18.18.43.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 18:43:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4611-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4611-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4611-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9975BB218AF for ; Tue, 19 Dec 2023 02:43:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4594FDDC8; Tue, 19 Dec 2023 02:42:59 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (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 EBE77BA5D; Tue, 19 Dec 2023 02:42:55 +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=01201311R511e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0Vyp0pKX_1702953767; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vyp0pKX_1702953767) by smtp.aliyun-inc.com; Tue, 19 Dec 2023 10:42:48 +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 1/2] mm: fix arithmetic for bdi min_ratio Date: Tue, 19 Dec 2023 10:42:45 +0800 Message-Id: <20231219024246.65654-2-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> 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