From patchwork Sat Nov 19 00:51:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 328ECC4332F for ; Sat, 19 Nov 2022 00:52:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2740B6B0073; Fri, 18 Nov 2022 19:52:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 24D586B0075; Fri, 18 Nov 2022 19:52:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7FF16B0074; Fri, 18 Nov 2022 19:52:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D37D26B0073 for ; Fri, 18 Nov 2022 19:52:32 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9ECF2AAC9A for ; Sat, 19 Nov 2022 00:52:32 +0000 (UTC) X-FDA: 80148366144.20.06583E6 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf20.hostedemail.com (Postfix) with ESMTP id 3CA421C0006 for ; Sat, 19 Nov 2022 00:52:31 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 4D58F19380C8; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 01/20] mm: add bdi_set_strict_limit() function Date: Fri, 18 Nov 2022 16:51:56 -0800 Message-Id: <20221119005215.3052436-2-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=neutral (imf20.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668819152; a=rsa-sha256; cv=none; b=BHRjmQdvLk0ng+i+excgTDgawswARlqG+BnuIKH3gLy1XyzZ0+HPsmyw7YYJ0wZxjQXn/v e6laWPYkehD1vTILCpm1FqL60IALgO2W0NKC4+2pRoMn2x8prfOMtHCi+dal6ffyynI80n HiC0bwCZptFRx2Id06SxMiFphygRfPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668819152; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=szlCkMoMk7dtgwA5rvE99aSMnKQPHVKt3470Uv1F3gQ=; b=QtNFBq8nMoHmH7QMrW+asOEjXj61WPRPrRtRJFu9fyuqRwgPR0dWy+II6112AcZuoKx29C 7AnhAICWjJpD8zK2ygPQSiFVdWsh4l1G/aPJga8QcSRlOzb/6OuC/0XsaBLhpxMOG1jkNE K2PYYtNMOpUnYyXklNdv0CuDKrR6DWs= Authentication-Results: imf20.hostedemail.com; dkim=none; spf=neutral (imf20.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none X-Rspamd-Server: rspam02 X-Rspam-User: X-Stat-Signature: o46dbzfa9nwyeawk76iwieekuw3x83oc X-Rspamd-Queue-Id: 3CA421C0006 X-HE-Tag: 1668819151-194684 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds the bdi_set_strict_limit function to be able to set/unset the BDI_CAP_STRICTLIMIT flag. Signed-off-by: Stefan Roesch --- include/linux/backing-dev.h | 1 + mm/page-writeback.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 439815cc1ab9..9c984ffc8a0a 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -104,6 +104,7 @@ static inline unsigned long wb_stat_error(void) int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio); int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); +int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit); /* * Flags in backing_dev_info::capability diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7e9d8d857ecc..3745b886722f 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -698,6 +698,21 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio) } EXPORT_SYMBOL(bdi_set_max_ratio); +int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit) +{ + if (strict_limit > 1) + return -EINVAL; + + spin_lock_bh(&bdi_lock); + if (strict_limit) + bdi->capabilities |= BDI_CAP_STRICTLIMIT; + else + bdi->capabilities &= ~BDI_CAP_STRICTLIMIT; + spin_unlock_bh(&bdi_lock); + + return 0; +} + static unsigned long dirty_freerun_ceiling(unsigned long thresh, unsigned long bg_thresh) { From patchwork Sat Nov 19 00:51:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DF60C43217 for ; Sat, 19 Nov 2022 00:52:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EDAC6B0074; Fri, 18 Nov 2022 19:52:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 976AB6B0078; Fri, 18 Nov 2022 19:52:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 690796B0075; Fri, 18 Nov 2022 19:52:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5246D6B0074 for ; Fri, 18 Nov 2022 19:52:36 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 332DD1A023B for ; Sat, 19 Nov 2022 00:52:36 +0000 (UTC) X-FDA: 80148366312.24.04C5C50 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf07.hostedemail.com (Postfix) with ESMTP id 9C2164000D for ; Sat, 19 Nov 2022 00:52:35 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 5064719380CA; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 02/20] mm: add knob /sys/class/bdi//strict_limit Date: Fri, 18 Nov 2022 16:51:57 -0800 Message-Id: <20221119005215.3052436-3-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668819155; a=rsa-sha256; cv=none; b=xsyJ/3c0xaSsbemOQPrEGvduv3q2/K4ylnOIQEvy9Cm1hxk7kfzmzZPGgviqCjZNkEA1Q8 s8IYpLmh25GSkc6U61e/IKLXOqpK40b4QjRH+GUkBfSIgTrPkYHLTTw3cqnBwDMAC8qRm6 KBtRT2Xc1f0S27/s2u+z3B0gWfaVwdU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf07.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668819155; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GTiUzoAmXnetMWfur67p/57Eq7Hkwtg7/8F/+h9Zbnw=; b=V+03lm3mycNJ7gYk0u3EBVqdnAOmBAShrZKK9vAWRBPQZ4hTXP3XsQ3l6dzMUlOe4mFgSY 1FzY6gT3juVE7qg2DlrrWdOT8/IAmhqKuTRYB0cqxZhEIN1R8808+C0LR6ckO3UgOWe0q/ B6pXqYbPhDfoqScjiN7DXPlPEzM0EBY= Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf07.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspam-User: X-Stat-Signature: 7df1kdnmjhhpanccbmkbxemia66ek9px X-Rspamd-Queue-Id: 9C2164000D X-Rspamd-Server: rspam11 X-HE-Tag: 1668819155-352899 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add a new knob to /sys/class/bdi//strict_limit. This new knob allows to set/unset the flag BDI_CAP_STRICTLIMIT in the bdi capabilities. Signed-off-by: Stefan Roesch --- mm/backing-dev.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index c30419a5e119..a0899cce72ef 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -209,11 +209,40 @@ static ssize_t stable_pages_required_show(struct device *dev, } static DEVICE_ATTR_RO(stable_pages_required); +static ssize_t strict_limit_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + unsigned int strict_limit; + ssize_t ret; + + ret = kstrtouint(buf, 10, &strict_limit); + if (ret < 0) + return ret; + + ret = bdi_set_strict_limit(bdi, strict_limit); + if (!ret) + ret = count; + + return ret; +} + +static ssize_t strict_limit_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", + !!(bdi->capabilities & BDI_CAP_STRICTLIMIT)); +} +static DEVICE_ATTR_RW(strict_limit); + static struct attribute *bdi_dev_attrs[] = { &dev_attr_read_ahead_kb.attr, &dev_attr_min_ratio.attr, &dev_attr_max_ratio.attr, &dev_attr_stable_pages_required.attr, + &dev_attr_strict_limit.attr, NULL, }; ATTRIBUTE_GROUPS(bdi_dev); From patchwork Sat Nov 19 00:51:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAE38C4332F for ; Sat, 19 Nov 2022 00:52:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 692B26B007D; Fri, 18 Nov 2022 19:52:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CEAF6B007B; Fri, 18 Nov 2022 19:52:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BD5C6B0078; Fri, 18 Nov 2022 19:52:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 39C206B0074 for ; Fri, 18 Nov 2022 19:52:36 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0270916088D for ; Sat, 19 Nov 2022 00:52:36 +0000 (UTC) X-FDA: 80148366312.25.E690398 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf09.hostedemail.com (Postfix) with ESMTP id 9BF88140008 for ; Sat, 19 Nov 2022 00:52:35 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 550E119380CC; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 03/20] mm: document /sys/class/bdi//strict_limit knob Date: Fri, 18 Nov 2022 16:51:58 -0800 Message-Id: <20221119005215.3052436-4-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668819155; a=rsa-sha256; cv=none; b=GmI/vw0RcBMX8BFQ8EC1kT+rEb/ocHWlFLKcKs7VMlh7K3LowiJesnj2gv8nu/yZ1HLly9 cuPeubXUjLDPUrLlOxvMfAnWNBXNHRJt+/Chmkr+lKd0TmS5cYGVNBszeA7v235z82MqL6 f/ZeZbIG9zLFwDARlA/IsKIdCAqss+M= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf09.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668819155; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2U+im8+B4wNoFjJqOFLX/rTYATi3Lg6oskSy2dhLr2A=; b=jusS/QDOUSbELS/8Kqlk8L+62hAnMBWfWsNXVatu2kOY8OnIVAezlIjVPxgvOIQFTUgJFm x7Xdm1OqmksKPDnlWhGqX8uzhp3j5MpUdN8ywjJShzQr/me7Yh+4WhDUi3aMpGb+uZbMTQ zww3YDxYtpdAvN4sAzO88WPUIx/cZiE= X-Stat-Signature: 9761ued9n98tju3qnb9wukjwj8by4on6 X-Rspamd-Queue-Id: 9BF88140008 Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf09.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1668819155-171341 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This documents the new /sys/class/bdi//strict_limit knob. Signed-off-by: Stefan Roesch --- Documentation/ABI/testing/sysfs-class-bdi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-bdi b/Documentation/ABI/testing/sysfs-class-bdi index 6d2a2fc189dd..68b5d4018c2f 100644 --- a/Documentation/ABI/testing/sysfs-class-bdi +++ b/Documentation/ABI/testing/sysfs-class-bdi @@ -55,6 +55,17 @@ Description: mount that is prone to get stuck, or a FUSE mount which cannot be trusted to play fair. + (read-write) +What: /sys/class/bdi//strict_limit +Date: October 2022 +Contact: Stefan Roesch +Description: + Forces per-BDI checks for the share of given device in the write-back + cache even before the global background dirty limit is reached. This + is useful in situations where the global limit is much higher than + affordable for given relatively slow (or untrusted) device. Turning + strictlimit on has no visible effect if max_ratio is equal to 100%. + (read-write) What: /sys/class/bdi//stable_pages_required Date: January 2008 From patchwork Sat Nov 19 00:51:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049438 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D7F0C4332F for ; Sat, 19 Nov 2022 00:52:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA81A6B0075; Fri, 18 Nov 2022 19:52:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E57CA6B0078; Fri, 18 Nov 2022 19:52:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D216A6B007B; Fri, 18 Nov 2022 19:52:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C26336B0075 for ; Fri, 18 Nov 2022 19:52:39 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A5E88AAD80 for ; Sat, 19 Nov 2022 00:52:39 +0000 (UTC) X-FDA: 80148366438.06.8B62DF8 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf01.hostedemail.com (Postfix) with ESMTP id DBDDF4000D for ; Sat, 19 Nov 2022 00:52:37 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 599CC19380CE; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 04/20] mm: use part per 1000000 for bdi ratios. Date: Fri, 18 Nov 2022 16:51:59 -0800 Message-Id: <20221119005215.3052436-5-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668819158; a=rsa-sha256; cv=none; b=v+uPVByZ4OjwTawxZmekk7AzFv6bojjykt6vjhzMdgWu5L0/Zy9xUG0eg1HK/UIcP/HFuo oL2rFK29EmEv41R5h35yL+jKTeOMEWM5FRIccxoGxMP69kTfW+dLMh688MUA4Ll0hAF2VQ q05BnzCQarK8cpcczDAhyOn1Bx8hom0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=neutral (imf01.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668819158; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BWR9QqcrwqugEOVfhhT9R3FPz/n02TnviTqTEJStq9k=; b=IwcudSnT6tWFol3qOANjo+5zuF+c1dXaeI25H4skcF5t0ZrUZuYb7XRtWUfpI/KyabStr6 qwLqXB12FrYT4voHRWDKboSK4iaej31aBIlKM5YK9rgyMkUfmGFbkSt4yMa4Gto1G5dcEE 28KfgH1J4XhSjeI1eQXTlC6Qivd8SXw= Authentication-Results: imf01.hostedemail.com; dkim=none; spf=neutral (imf01.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: DBDDF4000D X-Rspam-User: X-Stat-Signature: 6q3fesh56w573gogwq5ybfdk9kstbs47 X-HE-Tag: 1668819157-688846 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To get finer granularity for ratio calculations use part per million instead of percentiles. This is especially important if we want to automatically convert byte values to ratios. Otherwise the values that are actually used can be quite different. This is also important for machines with more main memory (1% of 256GB is already 2.5GB). Signed-off-by: Stefan Roesch --- include/linux/backing-dev.h | 3 +++ mm/backing-dev.c | 6 +++--- mm/page-writeback.c | 15 +++++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 9c984ffc8a0a..1b50c028e5ad 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -102,6 +102,9 @@ static inline unsigned long wb_stat_error(void) #endif } +/* BDI ratio is expressed as part per 1000000 for finer granularity. */ +#define BDI_RATIO_SCALE 10000 + int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio); int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit); diff --git a/mm/backing-dev.c b/mm/backing-dev.c index a0899cce72ef..90fa517123dc 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -178,7 +178,7 @@ static ssize_t min_ratio_store(struct device *dev, return ret; } -BDI_SHOW(min_ratio, bdi->min_ratio) +BDI_SHOW(min_ratio, bdi->min_ratio / BDI_RATIO_SCALE) static ssize_t max_ratio_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -197,7 +197,7 @@ static ssize_t max_ratio_store(struct device *dev, return ret; } -BDI_SHOW(max_ratio, bdi->max_ratio) +BDI_SHOW(max_ratio, bdi->max_ratio / BDI_RATIO_SCALE) static ssize_t stable_pages_required_show(struct device *dev, struct device_attribute *attr, @@ -809,7 +809,7 @@ int bdi_init(struct backing_dev_info *bdi) kref_init(&bdi->refcnt); bdi->min_ratio = 0; - bdi->max_ratio = 100; + bdi->max_ratio = 100 * BDI_RATIO_SCALE; bdi->max_prop_frac = FPROP_FRAC_BASE; INIT_LIST_HEAD(&bdi->bdi_list); INIT_LIST_HEAD(&bdi->wb_list); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 3745b886722f..dd98b2654302 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -197,7 +197,7 @@ static void wb_min_max_ratio(struct bdi_writeback *wb, min *= this_bw; min = div64_ul(min, tot_bw); } - if (max < 100) { + if (max < 100 * BDI_RATIO_SCALE) { max *= this_bw; max = div64_ul(max, tot_bw); } @@ -655,6 +655,8 @@ int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio) unsigned int delta; int ret = 0; + min_ratio *= BDI_RATIO_SCALE; + spin_lock_bh(&bdi_lock); if (min_ratio > bdi->max_ratio) { ret = -EINVAL; @@ -665,7 +667,7 @@ int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio) bdi->min_ratio = min_ratio; } else { delta = min_ratio - bdi->min_ratio; - if (bdi_min_ratio + delta < 100) { + if (bdi_min_ratio + delta < 100 * BDI_RATIO_SCALE) { bdi_min_ratio += delta; bdi->min_ratio = min_ratio; } else { @@ -684,6 +686,7 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio) if (max_ratio > 100) return -EINVAL; + max_ratio *= BDI_RATIO_SCALE; spin_lock_bh(&bdi_lock); if (bdi->min_ratio > max_ratio) { @@ -775,15 +778,15 @@ static unsigned long __wb_calc_thresh(struct dirty_throttle_control *dtc) fprop_fraction_percpu(&dom->completions, dtc->wb_completions, &numerator, &denominator); - wb_thresh = (thresh * (100 - bdi_min_ratio)) / 100; + wb_thresh = (thresh * (100 * BDI_RATIO_SCALE - bdi_min_ratio)) / (100 * BDI_RATIO_SCALE); wb_thresh *= numerator; wb_thresh = div64_ul(wb_thresh, denominator); wb_min_max_ratio(dtc->wb, &wb_min_ratio, &wb_max_ratio); - wb_thresh += (thresh * wb_min_ratio) / 100; - if (wb_thresh > (thresh * wb_max_ratio) / 100) - wb_thresh = thresh * wb_max_ratio / 100; + wb_thresh += (thresh * wb_min_ratio) / (100 * BDI_RATIO_SCALE); + if (wb_thresh > (thresh * wb_max_ratio) / (100 * BDI_RATIO_SCALE)) + wb_thresh = thresh * wb_max_ratio / (100 * BDI_RATIO_SCALE); return wb_thresh; } From patchwork Sat Nov 19 00:52:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BA7EC433FE for ; Sat, 19 Nov 2022 00:57:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7ED3D6B0072; Fri, 18 Nov 2022 19:57:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 79D7C6B0073; Fri, 18 Nov 2022 19:57:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 665F68E0001; Fri, 18 Nov 2022 19:57:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 534276B0072 for ; Fri, 18 Nov 2022 19:57:38 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2CE30A075C for ; Sat, 19 Nov 2022 00:57:38 +0000 (UTC) X-FDA: 80148378996.03.C27A4EC Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf18.hostedemail.com (Postfix) with ESMTP id C31BB1C000B for ; Sat, 19 Nov 2022 00:57:37 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 5DF8C19380D0; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 05/20] mm: add bdi_get_max_bytes() function Date: Fri, 18 Nov 2022 16:52:00 -0800 Message-Id: <20221119005215.3052436-6-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668819457; a=rsa-sha256; cv=none; b=NBrU2BGudLbB7JmRpZguxZSdHnAOUD5RPPaq+8ZEs4Thz+wTx6ULfL3usA1ZaBAAkuA7Y+ 6e/66OArbmq9YSGs3ns/FXATyYpMRo/aVQ9e/s0L1C1KfH+q8V0Ciaq68DwYnQWRGRRH8k jq8z8kXVYvgMpK0SfyVsEpGK1SvIHBE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf18.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668819457; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aXsnCLS53W8cxzDoMdNwuSaFrrJ0VnEpsYBQ38HuW6o=; b=Fr16hMgMfnlrlxEa9N2V9APx/ZSfLzWn7WUfZTAItI/Kvrgk11iGuVDYokKTIH1e2tgBM7 p6d7h+cfmpgOHgwJEF/ZnFwEsJu+xcmaI9B57MBO0TRr9AEeRm6kaf0LX+5hF/RZcng8Zw gX1deTu8vI9cs14CydpsBIh/0GiK/Ks= X-Stat-Signature: 79nrmobh54dgi3enntgbrfhx5sjoqm6a X-Rspamd-Queue-Id: C31BB1C000B Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf18.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1668819457-761878 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds a function to return the specified value for max_bytes. It converts the stored max_ratio of the bdi to the corresponding bytes value. It introduces the bdi_get_bytes helper function to do the conversion. This is an approximation as it is based on the value that is returned by global_dirty_limits(), which can change. The helper function will also be used by the min_bytes bdi knob. Signed-off-by: Stefan Roesch --- include/linux/backing-dev.h | 1 + mm/page-writeback.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 1b50c028e5ad..473686c32775 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -105,6 +105,7 @@ static inline unsigned long wb_stat_error(void) /* BDI ratio is expressed as part per 1000000 for finer granularity. */ #define BDI_RATIO_SCALE 10000 +u64 bdi_get_max_bytes(struct backing_dev_info *bdi); int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio); int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index dd98b2654302..719404e0d03d 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -650,6 +650,18 @@ void wb_domain_exit(struct wb_domain *dom) */ static unsigned int bdi_min_ratio; +static u64 bdi_get_bytes(unsigned int ratio) +{ + unsigned long background_thresh; + unsigned long dirty_thresh; + u64 bytes; + + global_dirty_limits(&background_thresh, &dirty_thresh); + bytes = (dirty_thresh * PAGE_SIZE * ratio) / BDI_RATIO_SCALE / 100; + + return bytes; +} + int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio) { unsigned int delta; @@ -701,6 +713,11 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio) } EXPORT_SYMBOL(bdi_set_max_ratio); +u64 bdi_get_max_bytes(struct backing_dev_info *bdi) +{ + return bdi_get_bytes(bdi->max_ratio); +} + int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit) { if (strict_limit > 1) From patchwork Sat Nov 19 00:52:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4F95C4332F for ; Sat, 19 Nov 2022 01:21:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C44B56B0073; Fri, 18 Nov 2022 20:21:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA8296B0075; Fri, 18 Nov 2022 20:21:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C45F6B0074; Fri, 18 Nov 2022 20:21:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 73DE26B0072 for ; Fri, 18 Nov 2022 20:21:38 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4A304A081F for ; Sat, 19 Nov 2022 01:21:38 +0000 (UTC) X-FDA: 80148439476.01.774FBE8 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf05.hostedemail.com (Postfix) with ESMTP id E15D8100002 for ; Sat, 19 Nov 2022 01:21:37 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 6272019380D2; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 06/20] mm: split off __bdi_set_max_ratio() function Date: Fri, 18 Nov 2022 16:52:01 -0800 Message-Id: <20221119005215.3052436-7-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668820898; a=rsa-sha256; cv=none; b=Yi4JycFawOsxnMO4RgxgFqQBr9FaOzP7bUlxxa4XmR9EsYtb/PEu4wFmDEtJwkKTx5KaSQ 8K9FtW/GTfDMdH5ccR0QZrAoyDCgvD2HuZNUxxHpeE7QGDPxy3b98ZNAgeeAxB2/o9xcZT fqXRV8nsVvAovpJBkU0Q6Utyj7AwHNE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=neutral (imf05.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668820898; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VT73Scl9XxTxD5AA2/Eu27dKxenA/AlC3Wpwkh1bmqY=; b=OnsFMtOrA9ay4yPWn2pNxDL6CFflcV66Jf1JF35DrQ1fnZKMss4ZdLHthrj+OlxwP586fU GeRzGfItEpQ+7B7lZxGBMdmWwRwX6FBHtgGnoKtW80b6R8DUszNiNQrCGnwa00DnMMvP1O szn1cgpu08yHwsVNiXFOpFLPay1ZMAM= X-Stat-Signature: 8pja7ftnwas4qq8pinq9jqw7ke836sy8 X-Rspamd-Queue-Id: E15D8100002 X-Rspamd-Server: rspam01 X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=none; spf=neutral (imf05.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none X-HE-Tag: 1668820897-146032 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This splits off __bdi_set_max_ratio() from bdi_set_max_ratio(). __bdi_set_max_ratio() will also be called from bdi_set_max_bytes(), which will be introduced in the next patch. Signed-off-by: Stefan Roesch --- mm/page-writeback.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 719404e0d03d..e74ef596dc27 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -692,14 +692,10 @@ int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio) return ret; } -int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio) +static int __bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio) { int ret = 0; - if (max_ratio > 100) - return -EINVAL; - max_ratio *= BDI_RATIO_SCALE; - spin_lock_bh(&bdi_lock); if (bdi->min_ratio > max_ratio) { ret = -EINVAL; @@ -711,6 +707,14 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio) return ret; } + +int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio) +{ + if (max_ratio > 100) + return -EINVAL; + + return __bdi_set_max_ratio(bdi, max_ratio * BDI_RATIO_SCALE); +} EXPORT_SYMBOL(bdi_set_max_ratio); u64 bdi_get_max_bytes(struct backing_dev_info *bdi) From patchwork Sat Nov 19 00:52:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 825EFC433FE for ; Sat, 19 Nov 2022 01:33:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B08DC8E0001; Fri, 18 Nov 2022 20:33:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AB7CF6B0074; Fri, 18 Nov 2022 20:33:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 957BF8E0001; Fri, 18 Nov 2022 20:33:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 87A346B0073 for ; Fri, 18 Nov 2022 20:33:41 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5513E1608C6 for ; Sat, 19 Nov 2022 01:33:41 +0000 (UTC) X-FDA: 80148469842.12.EDE7A7C Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf25.hostedemail.com (Postfix) with ESMTP id ECB2FA000B for ; Sat, 19 Nov 2022 01:33:40 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 670C619380D4; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 07/20] mm: add bdi_set_max_bytes() function. Date: Fri, 18 Nov 2022 16:52:02 -0800 Message-Id: <20221119005215.3052436-8-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668821621; a=rsa-sha256; cv=none; b=Dqqm5nk86TV6FQmcL5CC/NYdT3ORWE404htFsoXweDKVDlaZA+YvrNgn3oqgGj+6ebdIZ/ MwA2EN1+qrjNJQhQUq9VVss2/SuP2ZJlBCEJDLPL+SsLZuoccA0Okq1aIRds/9f9HVFYE6 wH1NuvJ7A1UEjIsKX9KcYhlryrl4cKU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf25.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668821621; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3J0pKE76usexPf+a1rJ40q4uSSdXqcfpbvcXPrHAR+A=; b=WFAJaGH3n1q/KoX1xTBAveZpgseutDOg00oWy2ufeQlsaM+qBw2pQSKyosif+/tJIDsL0i B5q4Noz3iViMaA3HAjLhsp6ZFI8P/XYjUUNk1g5aN77MAEcA3KXtLh46+GBn+Y8EbVfntU SHnj0Q3D+iyfsLWsBKV1ajiUP6k+0zc= X-Stat-Signature: nqfe5whu6n7oodonank8yoosu7t8fwac X-Rspamd-Queue-Id: ECB2FA000B Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf25.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1668821620-936644 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This introduces the bdi_set_max_bytes() function. The max_bytes function does not store the max_bytes value. Instead it converts the max_bytes value into the corresponding ratio value. Signed-off-by: Stefan Roesch --- include/linux/backing-dev.h | 1 + mm/page-writeback.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 473686c32775..ea6c993433d5 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -108,6 +108,7 @@ static inline unsigned long wb_stat_error(void) u64 bdi_get_max_bytes(struct backing_dev_info *bdi); int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio); int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); +int bdi_set_max_bytes(struct backing_dev_info *bdi, u64 max_bytes); int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit); /* diff --git a/mm/page-writeback.c b/mm/page-writeback.c index e74ef596dc27..20ae9adeb22f 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -650,6 +651,28 @@ void wb_domain_exit(struct wb_domain *dom) */ static unsigned int bdi_min_ratio; +static int bdi_check_pages_limit(unsigned long pages) +{ + unsigned long max_dirty_pages = global_dirtyable_memory(); + + if (pages > max_dirty_pages) + return -EINVAL; + + return 0; +} + +static unsigned long bdi_ratio_from_pages(unsigned long pages) +{ + unsigned long background_thresh; + unsigned long dirty_thresh; + unsigned long ratio; + + global_dirty_limits(&background_thresh, &dirty_thresh); + ratio = div64_u64(pages * 100ULL * BDI_RATIO_SCALE, dirty_thresh); + + return ratio; +} + static u64 bdi_get_bytes(unsigned int ratio) { unsigned long background_thresh; @@ -722,6 +745,20 @@ u64 bdi_get_max_bytes(struct backing_dev_info *bdi) return bdi_get_bytes(bdi->max_ratio); } +int bdi_set_max_bytes(struct backing_dev_info *bdi, u64 max_bytes) +{ + int ret; + unsigned long pages = max_bytes >> PAGE_SHIFT; + unsigned long max_ratio; + + ret = bdi_check_pages_limit(pages); + if (ret) + return ret; + + max_ratio = bdi_ratio_from_pages(pages); + return __bdi_set_max_ratio(bdi, max_ratio); +} + int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit) { if (strict_limit > 1) From patchwork Sat Nov 19 00:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31A09C4332F for ; Sat, 19 Nov 2022 01:45:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5F156B0073; Fri, 18 Nov 2022 20:45:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE6548E0001; Fri, 18 Nov 2022 20:45:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5FC46B0075; Fri, 18 Nov 2022 20:45:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 964A66B0073 for ; Fri, 18 Nov 2022 20:45:42 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6E72880883 for ; Sat, 19 Nov 2022 01:45:42 +0000 (UTC) X-FDA: 80148500124.21.EB17A23 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf08.hostedemail.com (Postfix) with ESMTP id 1306916000B for ; Sat, 19 Nov 2022 01:45:41 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 6B4AF19380D6; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 08/20] mm: add knob /sys/class/bdi//max_bytes Date: Fri, 18 Nov 2022 16:52:03 -0800 Message-Id: <20221119005215.3052436-9-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668822342; a=rsa-sha256; cv=none; b=tGxCjA5pYjtczy7k8EKOQTOs/TgFWgEJ2Peeuc32fLHJnV3Tu+hw3zJZDjCz4Af+jJUMJF ZSuyz8U/4JzOTGawEw0mfUXmMcUTX2GCNf1qBg/xUQZ6F1hVpWdK32LTl8SzbiHMsGfh1A +P39aURp/d23XVZ7odiuB1upJt21Gw0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf08.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668822342; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a2bCCV9zuA3dixLxlt9sozvXlK1yM8DnEdAqmWWvlLY=; b=8lv8GqQlCvmlv6Izf+o7Mx06X5HQLl8kW2PsnkH5C25s33pyLS74/mIcpyTcc57y+n9KcX AJcpUuMuDZln/82WoMu74cKPMAB6cr72OQAxpT8R9AK+hgY/naK3jzdB5cd6+bOCMP6jt3 xe4tIplemyQoFJ1YxAbbE0jQn4qPObs= X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1306916000B Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf08.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Stat-Signature: zoadsiteqks3xef45rxkxdqi91krnf9g X-HE-Tag: 1668822341-706246 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds the new knob max_bytes to specify a dirty memory limit for the corresponding bdi. The specified bytes value is converted to a ratio. Signed-off-by: Stefan Roesch --- mm/backing-dev.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 90fa517123dc..95d3229fc81f 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -199,6 +199,34 @@ static ssize_t max_ratio_store(struct device *dev, } BDI_SHOW(max_ratio, bdi->max_ratio / BDI_RATIO_SCALE) +static ssize_t max_bytes_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%llu\n", bdi_get_max_bytes(bdi)); +} + +static ssize_t max_bytes_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + u64 bytes; + ssize_t ret; + + ret = kstrtoull(buf, 10, &bytes); + if (ret < 0) + return ret; + + ret = bdi_set_max_bytes(bdi, bytes); + if (!ret) + ret = count; + + return ret; +} +DEVICE_ATTR_RW(max_bytes); + static ssize_t stable_pages_required_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -241,6 +269,7 @@ static struct attribute *bdi_dev_attrs[] = { &dev_attr_read_ahead_kb.attr, &dev_attr_min_ratio.attr, &dev_attr_max_ratio.attr, + &dev_attr_max_bytes.attr, &dev_attr_stable_pages_required.attr, &dev_attr_strict_limit.attr, NULL, From patchwork Sat Nov 19 00:52:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E956AC433FE for ; Sat, 19 Nov 2022 01:27:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 650176B0072; Fri, 18 Nov 2022 20:27:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 600576B0073; Fri, 18 Nov 2022 20:27:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EED36B0074; Fri, 18 Nov 2022 20:27:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3EEB66B0072 for ; Fri, 18 Nov 2022 20:27:41 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0F2FF401D4 for ; Sat, 19 Nov 2022 01:27:41 +0000 (UTC) X-FDA: 80148454722.19.D4929C2 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf20.hostedemail.com (Postfix) with ESMTP id 910921C0006 for ; Sat, 19 Nov 2022 01:27:40 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 6FA0819380D8; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 09/20] mm: document /sys/class/bdi//max_bytes knob Date: Fri, 18 Nov 2022 16:52:04 -0800 Message-Id: <20221119005215.3052436-10-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668821260; a=rsa-sha256; cv=none; b=I6GeCZrkoM2ce/Ou+sGB1zZVFah3SNgTKjvgIcugu02lrkIV34w+pH0uGwBbgb1eU5GIu6 v3Waze6+NcicbJYnX3eWMrBYEick7OahMASfVXDfieU4zxOG4E/NpTaj8nRdCAQxSSQdFZ 6Jvve8eUttcrbPiHVYzSEivmkJOIjMY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf20.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668821260; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FG2YZJniK6WQyGMVTRehiSJED6hFD5pcUkGd65cLNIA=; b=uLmiE5NNJ2ilkx+rjA5WC0xtVKJC4z7SPHb6EFXY0ZJwwujZ+f8LcBwbKKZ+12z0TA6JU6 BgHijoWME4lhQ4GfJXnk6uZpCL0uo4OznFifTAS6ouBDN1yAxLhuZ4UsEHdmQY6DNu/gBA EjE/BOMfmKCHPYAoFfwOuMoimjeUIFU= Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf20.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspam-User: X-Stat-Signature: 4steptaaqpuffsnzt1hq7rbb9idxszz3 X-Rspamd-Queue-Id: 910921C0006 X-Rspamd-Server: rspam11 X-HE-Tag: 1668821260-66061 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This documents the new /sys/class/bdi//max_bytes knob. Signed-off-by: Stefan Roesch --- Documentation/ABI/testing/sysfs-class-bdi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-bdi b/Documentation/ABI/testing/sysfs-class-bdi index 68b5d4018c2f..580f723de049 100644 --- a/Documentation/ABI/testing/sysfs-class-bdi +++ b/Documentation/ABI/testing/sysfs-class-bdi @@ -56,6 +56,20 @@ Description: be trusted to play fair. (read-write) + +What: /sys/class/bdi//max_bytes +Date: October 2022 +Contact: Stefan Roesch +Description: + Allows limiting a particular device to use not more than the + given 'max_bytes' of the write-back cache. This is useful in + situations where we want to avoid one device taking all or + most of the write-back cache. For example in case of an NFS + mount that is prone to get stuck, a FUSE mount which cannot be + trusted to play fair, or a nbd device. + + (read-write) + What: /sys/class/bdi//strict_limit Date: October 2022 Contact: Stefan Roesch From patchwork Sat Nov 19 00:52:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049511 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E6FDC4332F for ; Sat, 19 Nov 2022 01:57:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 048C76B0074; Fri, 18 Nov 2022 20:57:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F120A8E0002; Fri, 18 Nov 2022 20:57:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB2B06B0078; Fri, 18 Nov 2022 20:57:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CA4D26B0074 for ; Fri, 18 Nov 2022 20:57:43 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9F129AAB2A for ; Sat, 19 Nov 2022 01:57:43 +0000 (UTC) X-FDA: 80148530406.07.A8FDC55 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf02.hostedemail.com (Postfix) with ESMTP id 348FB80006 for ; Sat, 19 Nov 2022 01:57:42 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 742F119380DA; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 10/20] mm: add bdi_get_min_bytes() function. Date: Fri, 18 Nov 2022 16:52:05 -0800 Message-Id: <20221119005215.3052436-11-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668823063; a=rsa-sha256; cv=none; b=YAmMnBLDUI/uKCCVN55UAxfq0ievNPI/18FBzcQUTDRI5UqCFBFYyMyThjzisfxl72hL/o GzXyw1/Ik+hKdNkC0YNyN1qLWZ96B2EQ2HqMDfWTosC+H1T9Dy2KzR2z6Iatn0IIgPMaHJ 5Ls3uA4qeVozoxx4bOzKRsqDamxxJ7o= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf02.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668823063; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nxtD0N2K1jYnFvRCEbMSRC9TXcgcDivRP5MqisE+u/Q=; b=x8mabs6LpYeMh9bPYRU3CW8Fm6rLV7jFFWH7ofhpuXHCRcYe4nvrI3vM2HbxU98N0/y5Ip 2N0uwUr8lyqww0NP+COM1apxqG04hCxpE0BylQw1dmWa5+kNZCXUgI+lGgk5AfJFgI50xg 03D2G5HekwfXiElEadRtsN4fRxJjXu8= X-Stat-Signature: 9bcz9drpmb63ufq197ruyeih7d4zqhhi X-Rspamd-Queue-Id: 348FB80006 Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf02.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1668823062-243822 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds a function to return the specified value for min_bytes. It converts the stored min_ratio of the bdi to the corresponding bytes value. This is an approximation as it is based on the value that is returned by global_dirty_limits(), which can change. The returned value can be different than the value when the min_bytes value was set. Signed-off-by: Stefan Roesch --- include/linux/backing-dev.h | 1 + mm/page-writeback.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index ea6c993433d5..8e04567727e6 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -105,6 +105,7 @@ static inline unsigned long wb_stat_error(void) /* BDI ratio is expressed as part per 1000000 for finer granularity. */ #define BDI_RATIO_SCALE 10000 +u64 bdi_get_min_bytes(struct backing_dev_info *bdi); u64 bdi_get_max_bytes(struct backing_dev_info *bdi); int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio); int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 20ae9adeb22f..c47824464f4c 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -740,6 +740,11 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio) } EXPORT_SYMBOL(bdi_set_max_ratio); +u64 bdi_get_min_bytes(struct backing_dev_info *bdi) +{ + return bdi_get_bytes(bdi->min_ratio); +} + u64 bdi_get_max_bytes(struct backing_dev_info *bdi) { return bdi_get_bytes(bdi->max_ratio); From patchwork Sat Nov 19 00:52:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15F0AC4332F for ; Sat, 19 Nov 2022 01:45:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A87F28E0002; Fri, 18 Nov 2022 20:45:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A38518E0001; Fri, 18 Nov 2022 20:45:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9272A8E0002; Fri, 18 Nov 2022 20:45:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 81A928E0001 for ; Fri, 18 Nov 2022 20:45:45 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 55910C051A for ; Sat, 19 Nov 2022 01:45:45 +0000 (UTC) X-FDA: 80148500250.23.122BE8B Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf25.hostedemail.com (Postfix) with ESMTP id DB1DCA0011 for ; Sat, 19 Nov 2022 01:45:44 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 788A819380DD; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 11/20] mm: split off __bdi_set_min_ratio() function Date: Fri, 18 Nov 2022 16:52:06 -0800 Message-Id: <20221119005215.3052436-12-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668822345; a=rsa-sha256; cv=none; b=lM/uUsV1uxsrWTS5p4zrrp1WffZMRuEitWyGVC5YwkdEOVsbrHizvKcFYEoxI0P5LfOjSu Fnu3wLi95/UNACx1ip/2fl6Edi7j/BGILAs/UiJ+CG5Bjo6FpP3jPSNRkYkMdS79i7TemL 9eB8LrjKGBaFg9TsjZxj0Ilh/xt0PHE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=neutral (imf25.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668822345; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XdhPpcj8l6uajS15RCTLwqW9pJiDkrcFzzYl5EPgqtw=; b=pNGcb4DNd3w/MtMy+g71/P8BF9DQt54+SjqocQ82SgyRrp5Hg0aG5jn0FJJmjIf1yGrAA5 C0ezwNHokYs1Fgms5IIr4zWfzPpFWa3co2zIwCBDGwYYWOL2kg5Jgd0XMbHqzP2oWgFDeX qiwH1BugqCEMpND0EUsqA8Hh7eHQbJE= Authentication-Results: imf25.hostedemail.com; dkim=none; spf=neutral (imf25.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: DB1DCA0011 X-Rspam-User: X-Stat-Signature: 371mfwkz51jnuwessr6e8iftoetof4b9 X-HE-Tag: 1668822344-328494 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This splits off the __bdi_set_min_ratio() function from the bdi_set_min_ratio() function. The __bdi_set_min_ratio() function will also be called from the bdi_set_min_bytes() function, which will be introduced in the next patch. Signed-off-by: Stefan Roesch --- mm/page-writeback.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index c47824464f4c..cefee7210d83 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -685,7 +685,7 @@ static u64 bdi_get_bytes(unsigned int ratio) return bytes; } -int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio) +static int __bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio) { unsigned int delta; int ret = 0; @@ -731,6 +731,11 @@ static int __bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ra return ret; } +int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio) +{ + return __bdi_set_min_ratio(bdi, min_ratio * BDI_RATIO_SCALE); +} + int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio) { if (max_ratio > 100) From patchwork Sat Nov 19 00:52:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 106C0C433FE for ; Sat, 19 Nov 2022 01:51:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69F9A8E0001; Fri, 18 Nov 2022 20:51:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 695C98E0002; Fri, 18 Nov 2022 20:51:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52B3B8E0001; Fri, 18 Nov 2022 20:51:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 403B86B0074 for ; Fri, 18 Nov 2022 20:51:42 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E1F351A0739 for ; Sat, 19 Nov 2022 01:51:41 +0000 (UTC) X-FDA: 80148515202.22.87E1561 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf09.hostedemail.com (Postfix) with ESMTP id 7CED6140009 for ; Sat, 19 Nov 2022 01:51:41 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 7CD5419380DF; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 12/20] mm: add bdi_set_min_bytes() function Date: Fri, 18 Nov 2022 16:52:07 -0800 Message-Id: <20221119005215.3052436-13-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=neutral (imf09.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668822701; a=rsa-sha256; cv=none; b=2CMEiRTMLyHJJezQJUWJbluMBZHCYNKwasv6Gr18p8Vmk95fK9cCT/2zilv5Itmfl79Bvm qKTNr9+HtLCLIpZZ4wJQXPebkMpupI3mizOD8J+pbiczaO9jCABNwD1/xVUh9fpsZ1+CjJ RUg0Lrt6c9F/wcnaS+6m9WvooYh1wFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668822701; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U4a7x6fgCVUukJ/yo1HXq8TNmI5fDz9k0O0+dktr8hU=; b=dh5G4AXEjwzHXBgQ/dX3mxKu6vsByRWJcdeklG0+jowtkFnNXgtuIW0HOhzA8vDR9zNmwz kLtumzdxlx26lObakxnOzA5ExX6TaaoROVhK8nXXj+piGtlcuo7WxOowBOtph28/TGG2y6 a7tdZmdEI2BmpTZUCdfLmWRIPIZ2A18= Authentication-Results: imf09.hostedemail.com; dkim=none; spf=neutral (imf09.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none X-Rspamd-Server: rspam02 X-Rspam-User: X-Stat-Signature: 4of7rd8eddqi1yk9hweycnbmkc4ma6jn X-Rspamd-Queue-Id: 7CED6140009 X-HE-Tag: 1668822701-644589 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000137, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This introduces the bdi_set_min_bytes() function. The min_bytes function does not store the min_bytes value. Instead it converts the min_bytes value into the corresponding ratio value. Signed-off-by: Stefan Roesch --- include/linux/backing-dev.h | 1 + mm/page-writeback.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 8e04567727e6..572669758c7f 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -109,6 +109,7 @@ u64 bdi_get_min_bytes(struct backing_dev_info *bdi); u64 bdi_get_max_bytes(struct backing_dev_info *bdi); int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio); int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); +int bdi_set_min_bytes(struct backing_dev_info *bdi, u64 min_bytes); int bdi_set_max_bytes(struct backing_dev_info *bdi, u64 max_bytes); int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index cefee7210d83..3d151e7a9b6c 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -750,6 +750,20 @@ u64 bdi_get_min_bytes(struct backing_dev_info *bdi) return bdi_get_bytes(bdi->min_ratio); } +int bdi_set_min_bytes(struct backing_dev_info *bdi, u64 min_bytes) +{ + int ret; + unsigned long pages = min_bytes >> PAGE_SHIFT; + unsigned long min_ratio; + + ret = bdi_check_pages_limit(pages); + if (ret) + return ret; + + min_ratio = bdi_ratio_from_pages(pages); + return __bdi_set_min_ratio(bdi, min_ratio); +} + u64 bdi_get_max_bytes(struct backing_dev_info *bdi) { return bdi_get_bytes(bdi->max_ratio); From patchwork Sat Nov 19 00:52:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 224B0C433FE for ; Sat, 19 Nov 2022 02:03:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 944346B0075; Fri, 18 Nov 2022 21:03:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 808B36B0078; Fri, 18 Nov 2022 21:03:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60D888E0001; Fri, 18 Nov 2022 21:03:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4E9F16B0075 for ; Fri, 18 Nov 2022 21:03:44 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 218EC1A088B for ; Sat, 19 Nov 2022 02:03:44 +0000 (UTC) X-FDA: 80148545568.13.75D329F Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf24.hostedemail.com (Postfix) with ESMTP id AF89E18000B for ; Sat, 19 Nov 2022 02:03:43 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 80F9919380E2; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 13/20] mm: add /sys/class/bdi//min_bytes knob Date: Fri, 18 Nov 2022 16:52:08 -0800 Message-Id: <20221119005215.3052436-14-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668823423; a=rsa-sha256; cv=none; b=yYx15ytOvGcVxxUKwj3Eqy2ndnM+cXaoY/uosdJ4l8Ss2P510gQmkfaAnZ6jtcKrqE/Zqu mHu+22Fb94FstujHxsr1YKukCpuQRPhno7fC6fp70n482M+K1oU+Ke6h5KEdUt00ejlaCQ bG1dnTnL3AYBFNCeRoRRxVLTuDiMyks= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf24.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668823423; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CpvPe/bxwEXdSY1z0mHR7c8X13zjnjPiwVJF99HBaCQ=; b=e1cVdbmTGdWAo0U410HxcNFf1rEP8PtHaLM0PuoCT+Af5h592tNyo32IOG3MXq3IIrv1i+ BhFw0KCgm8dky/FsaaQA5VjJOTrNxZa3NkXs8cptxbjgl5q1vguxjASu/oxpPjwCLeTl7v V15WnWWeXEfm4PPkoS5o2MjULGQvfbc= X-Stat-Signature: myk4bimutka3a9pdkzuxax6hbsrwj4du X-Rspamd-Queue-Id: AF89E18000B Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf24.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1668823423-426015 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: bdi has two existing knobs to limit the amount of dirty memory: min_ratio and max_ratio. However the granularity of the knobs is limited and often it is more convenient to specify limits in terms of bytes. This change adds the min_bytes knob. It does not store the min_bytes value, instead it converts the max_bytes value to a ratio. The value is therefore more an approximation than an absolute value. It also maintains the sum over all the bdi min_ratio values stored in the variable bdi_min_ratio. Signed-off-by: Stefan Roesch --- mm/backing-dev.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 95d3229fc81f..3fab79061ade 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -199,6 +199,34 @@ static ssize_t max_ratio_store(struct device *dev, } BDI_SHOW(max_ratio, bdi->max_ratio / BDI_RATIO_SCALE) +static ssize_t min_bytes_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%llu\n", bdi_get_min_bytes(bdi)); +} + +static ssize_t min_bytes_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + u64 bytes; + ssize_t ret; + + ret = kstrtoull(buf, 10, &bytes); + if (ret < 0) + return ret; + + ret = bdi_set_min_bytes(bdi, bytes); + if (!ret) + ret = count; + + return ret; +} +DEVICE_ATTR_RW(min_bytes); + static ssize_t max_bytes_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -269,6 +297,7 @@ static struct attribute *bdi_dev_attrs[] = { &dev_attr_read_ahead_kb.attr, &dev_attr_min_ratio.attr, &dev_attr_max_ratio.attr, + &dev_attr_min_bytes.attr, &dev_attr_max_bytes.attr, &dev_attr_stable_pages_required.attr, &dev_attr_strict_limit.attr, From patchwork Sat Nov 19 00:52:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BDDBC4332F for ; Sat, 19 Nov 2022 02:15:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AEA76B0073; Fri, 18 Nov 2022 21:15:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 037416B0072; Fri, 18 Nov 2022 21:15:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8A486B0072; Fri, 18 Nov 2022 21:15:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C383C6B0072 for ; Fri, 18 Nov 2022 21:15:42 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9666A40B40 for ; Sat, 19 Nov 2022 02:15:42 +0000 (UTC) X-FDA: 80148575724.23.F835D4F Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf13.hostedemail.com (Postfix) with ESMTP id 282492000A for ; Sat, 19 Nov 2022 02:15:41 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 8506219380E4; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 14/20] mm: document /sys/class/bdi//min_bytes knob Date: Fri, 18 Nov 2022 16:52:09 -0800 Message-Id: <20221119005215.3052436-15-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=neutral (imf13.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668824142; a=rsa-sha256; cv=none; b=d+6XAQ/rLBeHVB0TrCTboRkVXIiL5ozXunF2hHKJsrlLrAZE40DwcUTEsvBPklJx7caMXI o/voc0t6GIkLfui68s+3RQSxOG92A+SuxR3nXXXQTIjuvQlwnz8DSxTUF5zZKKBS2j74u7 wQFGwSIx83WUVjT3QxvA5ystW4I7qoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668824142; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3EUi6jPj2vZbV6ealsadFNrxvkct4936SBuSwS/JJic=; b=JtcdjI004QN8DBnBdTkcOvhcfE8j84JLEBHGDArT/zBwQh0x1Egx71PpOQlkznApR8oy// 4LPcykcY2H3pGCi81HkGC6K+hZhcYlAjPTFcU78nXzS5w1jrAKVgopnbLmZEe6xfbyBV+n KH5LHEXE86NyiDOqO2xk1xGQZx8NsQM= Authentication-Results: imf13.hostedemail.com; dkim=none; spf=neutral (imf13.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none X-Rspamd-Server: rspam02 X-Rspam-User: X-Stat-Signature: biofh3c9f5xa8wcpjiyyhzigqdp5rk6d X-Rspamd-Queue-Id: 282492000A X-HE-Tag: 1668824141-871737 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000342, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This documents the new /sys/class/bdi//min_bytes knob. Signed-off-by: Stefan Roesch --- Documentation/ABI/testing/sysfs-class-bdi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-bdi b/Documentation/ABI/testing/sysfs-class-bdi index 580f723de049..bec996e29565 100644 --- a/Documentation/ABI/testing/sysfs-class-bdi +++ b/Documentation/ABI/testing/sysfs-class-bdi @@ -57,6 +57,21 @@ Description: (read-write) +What: /sys/class/bdi//min_bytes +Date: October 2022 +Contact: Stefan Roesch +Description: + Under normal circumstances each device is given a part of the + total write-back cache that relates to its current average + writeout speed in relation to the other devices. + + The 'min_bytes' parameter allows assigning a minimum + percentage of the write-back cache to a particular device + expressed in bytes. + For example, this is useful for providing a minimum QoS. + + (read-write) + What: /sys/class/bdi//max_bytes Date: October 2022 Contact: Stefan Roesch From patchwork Sat Nov 19 00:52:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BB01C43219 for ; Sat, 19 Nov 2022 02:15:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 321B56B0072; Fri, 18 Nov 2022 21:15:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A67A8E0001; Fri, 18 Nov 2022 21:15:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F041B6B0078; Fri, 18 Nov 2022 21:15:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D49D16B0074 for ; Fri, 18 Nov 2022 21:15:42 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8DEC116063B for ; Sat, 19 Nov 2022 02:15:42 +0000 (UTC) X-FDA: 80148575724.27.A585EFF Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf17.hostedemail.com (Postfix) with ESMTP id 336AC40009 for ; Sat, 19 Nov 2022 02:15:41 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 891E619380E6; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 15/20] mm: add bdi_set_max_ratio_no_scale() function Date: Fri, 18 Nov 2022 16:52:10 -0800 Message-Id: <20221119005215.3052436-16-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668824142; a=rsa-sha256; cv=none; b=fH9s5IEJcit4krapMcygUdLS8EayECHSVSMSAsAaPso0LkOjYifbnk0VkfopZG9/dumkUU BkfJQvVrBpTSgZOmedgf5bNpnx/TAQY6T5R+mUo7Lmz14sUcY7ggBmjWLKsMgFtTRLpz6i +rYf9alSQRT/8pXnQoZU974VXb1lrlY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf17.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668824142; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VdNh1ryy1a+hPFoJ1Vexe0jpqeNa6kfTL1Cd4xqYU4M=; b=GLFIb1rjYk4wv/iQK+ExSnQ8cUZZuj/DbHLGrjh/S+zCelZR363PmP4tWZbeZqmwBw4nWb 0hkIqHQBI6KtUHnGnXda6mJ3teHt827vOL2P1TFxI+uSqCioNKS8bvNQ0X1dvRMgrMlYxT lZMVR4o0vdC+bV651sAe5TK417QEae0= X-Stat-Signature: of9judeqrsjtrbirunp6e8q6w5nmpfsn X-Rspamd-Queue-Id: 336AC40009 Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf17.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1668824141-453293 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This introduces bdi_set_max_ratio_no_scale(). It uses the max granularity for the ratio. This function by the new sysfs knob max_ratio_fine. Signed-off-by: Stefan Roesch --- include/linux/backing-dev.h | 1 + mm/page-writeback.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 572669758c7f..d9acbb22ff25 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -109,6 +109,7 @@ u64 bdi_get_min_bytes(struct backing_dev_info *bdi); u64 bdi_get_max_bytes(struct backing_dev_info *bdi); int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio); int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); +int bdi_set_max_ratio_no_scale(struct backing_dev_info *bdi, unsigned int max_ratio); int bdi_set_min_bytes(struct backing_dev_info *bdi, u64 min_bytes); int bdi_set_max_bytes(struct backing_dev_info *bdi, u64 max_bytes); int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 3d151e7a9b6c..f44ade72966c 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -719,6 +719,9 @@ static int __bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ra { int ret = 0; + if (max_ratio > 100 * BDI_RATIO_SCALE) + return -EINVAL; + spin_lock_bh(&bdi_lock); if (bdi->min_ratio > max_ratio) { ret = -EINVAL; @@ -731,6 +734,11 @@ static int __bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ra return ret; } +int bdi_set_max_ratio_no_scale(struct backing_dev_info *bdi, unsigned int max_ratio) +{ + return __bdi_set_max_ratio(bdi, max_ratio); +} + int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio) { return __bdi_set_min_ratio(bdi, min_ratio * BDI_RATIO_SCALE); @@ -738,9 +746,6 @@ int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio) int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio) { - if (max_ratio > 100) - return -EINVAL; - return __bdi_set_max_ratio(bdi, max_ratio * BDI_RATIO_SCALE); } EXPORT_SYMBOL(bdi_set_max_ratio); From patchwork Sat Nov 19 00:52:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049516 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE5FCC4332F for ; Sat, 19 Nov 2022 02:09:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F0386B0074; Fri, 18 Nov 2022 21:09:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DD916B0078; Fri, 18 Nov 2022 21:09:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3219A8E0001; Fri, 18 Nov 2022 21:09:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1F0EF6B0074 for ; Fri, 18 Nov 2022 21:09:45 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D150A40AF1 for ; Sat, 19 Nov 2022 02:09:44 +0000 (UTC) X-FDA: 80148560688.16.158A332 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf12.hostedemail.com (Postfix) with ESMTP id 70EB040008 for ; Sat, 19 Nov 2022 02:09:44 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 8D4A619380E8; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 16/20] mm: add /sys/class/bdi//max_ratio_fine knob Date: Fri, 18 Nov 2022 16:52:11 -0800 Message-Id: <20221119005215.3052436-17-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668823784; a=rsa-sha256; cv=none; b=pTAMzWSCLkvS6c8Tc6SYiCMnvBvasU6625MR7K1lezgEJ8vpey+SiVhOWaJd9RbFmw4aTp yvh0jCMtkrO0LIJSieQZ5HUNRZ2jhoKtAXGBFDglLQBpVC76qScD217GvUanLeX7kymU8T PWj0eKyF94VMfNHHjGjMc0jM55sdjQA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf12.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668823784; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WzJI9fdAKySthuAC8ejnhXYwfTG0H+erXO63GWB12m0=; b=OjTHaL0PrcygYOVPI5bs8Fibq+Ys+KglKxLSRvtDuPfBRlkpJifa6KQV8lhdbI6VGiLbsT cYc+O/+VxKX3kRCng59cXE25HXZKScoJsxdd6h2jhDk8/XLzs5qlGg/Utbuhc9PyfmW+QZ vNnMoyYvPMLj0/GPxZyz5Cyz6sZjy8w= X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 70EB040008 Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf12.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Stat-Signature: fhdyy3twux9zoq9z6p1jkkrz6u7fhjwr X-HE-Tag: 1668823784-182367 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds the max_ratio_fine knob. The knob specifies the values not based on 1 of 100, but instead 1 per million. Signed-off-by: Stefan Roesch --- mm/backing-dev.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 3fab79061ade..94c2382367cf 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -199,6 +199,25 @@ static ssize_t max_ratio_store(struct device *dev, } BDI_SHOW(max_ratio, bdi->max_ratio / BDI_RATIO_SCALE) +static ssize_t max_ratio_fine_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + unsigned int ratio; + ssize_t ret; + + ret = kstrtouint(buf, 10, &ratio); + if (ret < 0) + return ret; + + ret = bdi_set_max_ratio_no_scale(bdi, ratio); + if (!ret) + ret = count; + + return ret; +} +BDI_SHOW(max_ratio_fine, bdi->max_ratio) + static ssize_t min_bytes_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -297,6 +316,7 @@ static struct attribute *bdi_dev_attrs[] = { &dev_attr_read_ahead_kb.attr, &dev_attr_min_ratio.attr, &dev_attr_max_ratio.attr, + &dev_attr_max_ratio_fine.attr, &dev_attr_min_bytes.attr, &dev_attr_max_bytes.attr, &dev_attr_stable_pages_required.attr, From patchwork Sat Nov 19 00:52:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5025C433FE for ; Sat, 19 Nov 2022 02:27:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 257998E0002; Fri, 18 Nov 2022 21:27:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 205578E0001; Fri, 18 Nov 2022 21:27:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0169C6B0078; Fri, 18 Nov 2022 21:27:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E66C36B0073 for ; Fri, 18 Nov 2022 21:27:46 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BE671140334 for ; Sat, 19 Nov 2022 02:27:46 +0000 (UTC) X-FDA: 80148606132.19.6D427C2 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf18.hostedemail.com (Postfix) with ESMTP id 7187C1C000A for ; Sat, 19 Nov 2022 02:27:46 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 918AE19380EB; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 17/20] mm: document /sys/class/bdi//max_ratio_fine knob Date: Fri, 18 Nov 2022 16:52:12 -0800 Message-Id: <20221119005215.3052436-18-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668824866; a=rsa-sha256; cv=none; b=CjsKhj5BWKJ8WGvPfvSpl+Fr5xQ7H6efFU8/W8WbFQOeJgVFDcFTIwPPXjP47BTdmUy0w4 tcRxXROePrEaOrTXfYXQRitkGTTGcIBvzI4/MdozKPVZOkrSjjccCTS3WSKJnV0idI1PNF cGq5k+FoNuDcYMmHtzmykB2IxImV3fI= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf18.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668824866; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XD49U+Fc5iz9FZUWKu+vfryFQkTDrxVvEeOUEAAsIuU=; b=kGlniDJsMzovqnUc+flMMMmega1+SvEqqgMU4MdY02fThTUylLu04eWSKcedQNXy38OKVu LdM+hapWj1qC2Thvtb272XcaIQG+XM1GB76j/D0kU9u/CxBjkQKITmxNaDvvt/+5tPPmaN QASS8Hrcal4KvTErVE/4GZhDUc7XNjc= Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf18.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspam-User: X-Stat-Signature: dumewen98fghkbimy6ddzzfwxdjdh7mr X-Rspamd-Queue-Id: 7187C1C000A X-Rspamd-Server: rspam11 X-HE-Tag: 1668824866-828526 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This documents the new /sys/class/bdi//max_ratio_fine knob. Signed-off-by: Stefan Roesch --- Documentation/ABI/testing/sysfs-class-bdi | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-bdi b/Documentation/ABI/testing/sysfs-class-bdi index bec996e29565..34d2e5489c74 100644 --- a/Documentation/ABI/testing/sysfs-class-bdi +++ b/Documentation/ABI/testing/sysfs-class-bdi @@ -57,6 +57,19 @@ Description: (read-write) +What: /sys/class/bdi//max_ratio_fine +Date: November 2022 +Contact: Stefan Roesch +Description: + Allows limiting a particular device to use not more than the + given value of the write-back cache. The value is given as part + of 1 million. This is useful in situations where we want to avoid + one device taking all or most of the write-back cache. For example + in case of an NFS mount that is prone to get stuck, or a FUSE mount + which cannot be trusted to play fair. + + (read-write) + What: /sys/class/bdi//min_bytes Date: October 2022 Contact: Stefan Roesch From patchwork Sat Nov 19 00:52:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9CFEC4321E for ; Sat, 19 Nov 2022 02:09:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1778F6B0078; Fri, 18 Nov 2022 21:09:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 089376B007B; Fri, 18 Nov 2022 21:09:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E45838E0001; Fri, 18 Nov 2022 21:09:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D59EC6B0078 for ; Fri, 18 Nov 2022 21:09:45 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B0EBDAAE2E for ; Sat, 19 Nov 2022 02:09:45 +0000 (UTC) X-FDA: 80148560730.08.08A177D Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf20.hostedemail.com (Postfix) with ESMTP id 3464F1C0006 for ; Sat, 19 Nov 2022 02:09:44 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 95A1E19380ED; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 18/20] mm: add bdi_set_min_ratio_no_scale() function Date: Fri, 18 Nov 2022 16:52:13 -0800 Message-Id: <20221119005215.3052436-19-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668823785; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kWwF9efk52Saq5MY+cBPHsGvoMLbDiQx8CkAmxnBcS0=; b=0dVzr+ERNrx3SQKFecasEijBNIlyxLwqRO7gRva0Gd/fp1okSe9WYPek79RpkjCi/1ljeY GxgOuGwuTB6mu21z9QTVhHeMw47M/qD7Vq0gQ2m/a92+6ra4zK6cx/ksmnHMVE0UKBpGHr z6uImKEIPOIFe3rw5wH4V490jXNFS2k= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf20.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668823785; a=rsa-sha256; cv=none; b=x837heBOPxJPvsk0krFtWVK/XY2T9Fmrz1U3t2DtSY5s48qleM7wcFUIzw3pMKuurduDXE Giaeald/q6Kzt7KhLBtbdQq6RAQOpGAcXG923aTZZfCfHyzpDcAGzydv5FGoT1NqdUIyqM IhCu5eUpHz8POl0p6YkYPxpMgUrK2Xk= X-Rspam-User: X-Stat-Signature: 8aaboewe7y6gk1xs3iff7tqf447q1pao X-Rspamd-Queue-Id: 3464F1C0006 Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf20.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspamd-Server: rspam07 X-HE-Tag: 1668823784-475249 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This introduces bdi_set_min_ratio_no_scale(). It uses the max granularity for the ratio. This function by the new sysfs knob min_ratio_fine. Signed-off-by: Stefan Roesch --- include/linux/backing-dev.h | 1 + mm/page-writeback.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index d9acbb22ff25..fbad4fcd408e 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -109,6 +109,7 @@ u64 bdi_get_min_bytes(struct backing_dev_info *bdi); u64 bdi_get_max_bytes(struct backing_dev_info *bdi); int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio); int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); +int bdi_set_min_ratio_no_scale(struct backing_dev_info *bdi, unsigned int min_ratio); int bdi_set_max_ratio_no_scale(struct backing_dev_info *bdi, unsigned int max_ratio); int bdi_set_min_bytes(struct backing_dev_info *bdi, u64 min_bytes); int bdi_set_max_bytes(struct backing_dev_info *bdi, u64 max_bytes); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index f44ade72966c..ad608ef2a243 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -690,6 +690,8 @@ static int __bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ra unsigned int delta; int ret = 0; + if (min_ratio > 100 * BDI_RATIO_SCALE) + return -EINVAL; min_ratio *= BDI_RATIO_SCALE; spin_lock_bh(&bdi_lock); @@ -734,6 +736,11 @@ static int __bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ra return ret; } +int bdi_set_min_ratio_no_scale(struct backing_dev_info *bdi, unsigned int min_ratio) +{ + return __bdi_set_min_ratio(bdi, min_ratio); +} + int bdi_set_max_ratio_no_scale(struct backing_dev_info *bdi, unsigned int max_ratio) { return __bdi_set_max_ratio(bdi, max_ratio); From patchwork Sat Nov 19 00:52:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BB02C4332F for ; Sat, 19 Nov 2022 02:21:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 982C96B0072; Fri, 18 Nov 2022 21:21:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9333C6B0073; Fri, 18 Nov 2022 21:21:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 821BD6B0074; Fri, 18 Nov 2022 21:21:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 72A196B0072 for ; Fri, 18 Nov 2022 21:21:47 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 45BEA1A0808 for ; Sat, 19 Nov 2022 02:21:47 +0000 (UTC) X-FDA: 80148591054.20.47FEBC8 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf11.hostedemail.com (Postfix) with ESMTP id CE00540004 for ; Sat, 19 Nov 2022 02:21:46 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 99BAD19380EF; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 19/20] mm: add /sys/class/bdi//min_ratio_fine knob Date: Fri, 18 Nov 2022 16:52:14 -0800 Message-Id: <20221119005215.3052436-20-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668824507; a=rsa-sha256; cv=none; b=Q8L7mnTsDGKGzMJEdTCDXQx+/dCTBlqbTUbSz96yPBGI++zXcFWAh+praoCY+xHZNyYIb1 Sv5hPyZ1GQVpy2XFDyuAFL/rdZQ3n7/Lsj6Jk7SAVfLRchX6XVbit/NT2tQE/ZjLZPLANz CAT2r7K8uUCAWDCp+9mY7m+vUrs02DY= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf11.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668824507; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nD5ACcCeKXwK39Bja+H6lmd1c0kYUAc8hPfCYjF6Qgw=; b=wV0P3RMnQE83wjXNfnLCndGulraOl2qR56cl3OhweWXeaSjd9WYHgQnv+YrkdQ57HcZBgs XbnEgwyMonGCb3dCen2iH+47ZaBL1v50elPTDQal6gp+QEKtHadKBpmZso7/GtzDEm7+29 Iu786eysBizwl2iu3LQ5yu7fJFElhLM= X-Stat-Signature: g7c1ytkw8dby6skmhqboji69y6a4t53u X-Rspamd-Queue-Id: CE00540004 Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf11.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1668824506-562723 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds the min_ratio_fine knob. The knob specifies the values not based on 1 of 100, but instead 1 per million. Signed-off-by: Stefan Roesch --- mm/backing-dev.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 94c2382367cf..a53b9360b72e 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -180,6 +180,25 @@ static ssize_t min_ratio_store(struct device *dev, } BDI_SHOW(min_ratio, bdi->min_ratio / BDI_RATIO_SCALE) +static ssize_t min_ratio_fine_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + unsigned int ratio; + ssize_t ret; + + ret = kstrtouint(buf, 10, &ratio); + if (ret < 0) + return ret; + + ret = bdi_set_min_ratio_no_scale(bdi, ratio); + if (!ret) + ret = count; + + return ret; +} +BDI_SHOW(min_ratio_fine, bdi->min_ratio) + static ssize_t max_ratio_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -315,6 +334,7 @@ static DEVICE_ATTR_RW(strict_limit); static struct attribute *bdi_dev_attrs[] = { &dev_attr_read_ahead_kb.attr, &dev_attr_min_ratio.attr, + &dev_attr_min_ratio_fine.attr, &dev_attr_max_ratio.attr, &dev_attr_max_ratio_fine.attr, &dev_attr_min_bytes.attr, From patchwork Sat Nov 19 00:52:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4790FC433FE for ; Sat, 19 Nov 2022 02:33:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 224246B0073; Fri, 18 Nov 2022 21:33:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BA366B0075; Fri, 18 Nov 2022 21:33:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5A6E8E0002; Fri, 18 Nov 2022 21:33:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CC8936B0073 for ; Fri, 18 Nov 2022 21:33:47 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 92441C051A for ; Sat, 19 Nov 2022 02:33:47 +0000 (UTC) X-FDA: 80148621294.01.1F2ED7E Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf17.hostedemail.com (Postfix) with ESMTP id AD66140009 for ; Sat, 19 Nov 2022 02:33:45 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 9E02919380F1; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 20/20] mm: document /sys/class/bdi//min_ratio_fine knob Date: Fri, 18 Nov 2022 16:52:15 -0800 Message-Id: <20221119005215.3052436-21-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668825225; a=rsa-sha256; cv=none; b=6q/CAIjUfntps0VDZE41fplLWDDF7xjojpHxU1gAcXnO9cEPWBPOQeYt9Di/pujIF6pQ1y JNMpCzSFm82isHAtP++mGT1kTxoX041P3xH15M1RtNerODZgc19TV4vNSczFElnKLIyXIy ikrdXqNYmIcI3q3HwIswstFoC0n6eXo= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf17.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668825225; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IAql0XPMvC1TJMJyXmTl7aDi/qXiRQy//kR7ZQ4/jNQ=; b=3fYHhbk1E7ds1afA4M5HAwj4hMleOTd5pD+GQVcz33Zz4fb8VlFG/U+AJAhoGsWY2GTV5X 96GblWd/qLf8mloxpiwMw+n535rYk206r39jPvglzO/dm9n48G4LR+V2UGbCEwqo9meoyh mirMmJ02qrjbIm7YxhtYGXlUujP9A/A= Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf17.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspam-User: X-Stat-Signature: ukmcyzhbh9nh4nega7dnbzxiwnp9rdpb X-Rspamd-Queue-Id: AD66140009 X-Rspamd-Server: rspam11 X-HE-Tag: 1668825225-509420 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This documents the new /sys/class/bdi//max_ratio_fine knob. Signed-off-by: Stefan Roesch --- Documentation/ABI/testing/sysfs-class-bdi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-bdi b/Documentation/ABI/testing/sysfs-class-bdi index 34d2e5489c74..b4ed0db680cf 100644 --- a/Documentation/ABI/testing/sysfs-class-bdi +++ b/Documentation/ABI/testing/sysfs-class-bdi @@ -44,6 +44,21 @@ Description: (read-write) +What: /sys/class/bdi//min_ratio_fine +Date: November 2022 +Contact: Stefan Roesch +Description: + Under normal circumstances each device is given a part of the + total write-back cache that relates to its current average + writeout speed in relation to the other devices. + + The 'min_ratio_fine' parameter allows assigning a minimum reserve + of the write-back cache to a particular device. The value is + expressed as part of 1 million. For example, this is useful for + providing a minimum QoS. + + (read-write) + What: /sys/class/bdi//max_ratio Date: January 2008 Contact: Peter Zijlstra