From patchwork Tue Dec 19 02:42:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 180721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1676050dyi; Mon, 18 Dec 2023 18:44:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/1MA0WqH+BmeuBcGyCcMQrxTZU1JW7KPh9kMF1nO2xk760bhgrZCwx6Q7PKOy12y7rhfL X-Received: by 2002:a17:902:c601:b0:1d3:dc64:413e with SMTP id r1-20020a170902c60100b001d3dc64413emr381711plr.81.1702953842057; Mon, 18 Dec 2023 18:44:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702953842; cv=none; d=google.com; s=arc-20160816; b=C2eMXceVyR/A65reb5bx6ng/AeIyHnbok7/e53JsFl+Gu6XJ3IKcTzi8S14TALmtsV PAlNlh6taKuPI1d9O41WueI3Zeyuan1derH/98DYVrAiZuBWYAIDsucSUMfLzke2XxJC n/QXccdar7bsgKIjKzMzMeJvRhQlTE3iKSSBwfYKqQeYzjMv7TEh1n8jvcNeIHwxLxbR b78bOV7M3RP7Xc/7HWkGQMIZTzlq6+dOZg5KdWdmJkl6caqQAvMMa2kFBGbspg/jEMkQ iXsFRcBx3BmCfsRYA3tJ+YPdlw+2rbcPmIrj6U3LkljSXeOwR7b3g4z/OFn/7/75qgsl +0Aw== 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4611-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t1-20020a170902b20100b001d055c255a8si18374948plr.221.2023.12.18.18.44.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 18:44:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4611-ouuuleilei=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; spf=pass (google.com: domain of linux-kernel+bounces-4611-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4611-ouuuleilei=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 E0F93B21841 for ; Tue, 19 Dec 2023 02:44:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6172B1170D; Tue, 19 Dec 2023 02:43:00 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785676527534094904 X-GMAIL-MSGID: 1785676527534094904 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) {