From patchwork Mon Oct 24 19:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13017984 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 CA8D9ECAAA1 for ; Mon, 24 Oct 2022 19:06:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2530F94000B; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CF3F940007; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E5FF94000B; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) 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 EEB0D940007 for ; Mon, 24 Oct 2022 15:06:30 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D4DC7140D92 for ; Mon, 24 Oct 2022 19:06:30 +0000 (UTC) X-FDA: 80056774140.04.0E67A9D Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf27.hostedemail.com (Postfix) with ESMTP id 5CAC640028 for ; Mon, 24 Oct 2022 19:06:30 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 4C3843ED5908; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 01/14] mm: add bdi_set_strict_limit() function Date: Mon, 24 Oct 2022 12:05:50 -0700 Message-Id: <20221024190603.3987969-2-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-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=1666638390; 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=d/iFoe1bt1NpYx+Au3tv9hTFtJHOJTfblPbH7ptRjB8=; b=vef3mlIuf/nutgm10LKj3BqBa6hShF/VwJ02ram5p7iRYDldpgdxrHPSU5UmLqvU7nAmyS dIMRF0K6TsL1JOn3s6VWuLOycVheFH+JvaWCzwFYED5i15HJzaryC8rJBcSISsjwpl7jg9 7j2IYFVwJ7tA6nhi/C2eGE19eo8vMkA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf27.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=1666638390; a=rsa-sha256; cv=none; b=rafIBF/f5PTBYjikjmKfW71LuEeHNLbhBNyX4+Nrg640milBpZUprLcnMb8dm+91kVuWYO cCYpGsKBhQDGLuCdcI2IZ4TtuKLCMjriW5FL7Iez0nC0jh9msu1KrUeIU4cB4E/Q2KvhGk jOYCWAyRR0IefVdXy8Nwl+knI7CshQ0= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5CAC640028 X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf27.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: 6efhtswc1w6d6pmyripocmjfy7ba6txw X-HE-Tag: 1666638390-367661 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 | 16 ++++++++++++++++ 2 files changed, 17 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..e22aae0ecacd 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -698,6 +698,22 @@ 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; +} +EXPORT_SYMBOL_GPL(bdi_set_strict_limit); + static unsigned long dirty_freerun_ceiling(unsigned long thresh, unsigned long bg_thresh) { From patchwork Mon Oct 24 19:05:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13017985 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 A27FFC38A2D for ; Mon, 24 Oct 2022 19:06:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F28894000D; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 551E494000C; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2518F94000A; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 025CE94000A for ; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C2602140D82 for ; Mon, 24 Oct 2022 19:06:30 +0000 (UTC) X-FDA: 80056774140.06.0D75D2B Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf30.hostedemail.com (Postfix) with ESMTP id 5DB4380038 for ; Mon, 24 Oct 2022 19:06:30 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 504903ED590A; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 02/14] mm: add knob /sys/class/bdi//strict_limit Date: Mon, 24 Oct 2022 12:05:51 -0700 Message-Id: <20221024190603.3987969-3-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-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=1666638390; 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=nxx7YiD43JOFunLoIOlOfrwcGN1u/CIOvDPEHs3mjirlc2CnM8bQsEv/d8SL+n3hJUBGUu oN507RiOx4VZIRipvX+tpS5j6dm+CKPvuEmsAHNjLpRASG4DgRK7nlrY0T35DSc437nJyt HofhVOXoHMfNOX4SOjgFeMhMiC1udeo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf30.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=1666638390; a=rsa-sha256; cv=none; b=J7npyO3r/4J9FC2RbUiszI+QYytIw6r5TfqCXpZHlyJJvweUEXzmnXjMyqD4RIrEWSWej+ zVE9DoByqIUbJKDcGLD6pftNy7bpmJFl5aCsAxK3saksG9K8j6XMJUZJBtgaAAJN7ebA9p w6Ar+DMRD3Qj8++ERxNYEXrujTrJag4= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5DB4380038 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf30.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: 4o6qsgbx34kd9j89zyrcsen3f3yt6z96 X-HE-Tag: 1666638390-818684 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 Mon Oct 24 19:05:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13017988 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 F331BC38A2D for ; Mon, 24 Oct 2022 19:06:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5901D940007; Mon, 24 Oct 2022 15:06:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AE6A94000F; Mon, 24 Oct 2022 15:06:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 133E394000C; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) 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 E2DFF940007 for ; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9A2101A0B75 for ; Mon, 24 Oct 2022 19:06:31 +0000 (UTC) X-FDA: 80056774182.25.5F26903 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 3C8CA160004 for ; Mon, 24 Oct 2022 19:06:31 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 5639D3ED590C; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 03/14] mm: document /sys/class/bdi//strict_limit knob Date: Mon, 24 Oct 2022 12:05:52 -0700 Message-Id: <20221024190603.3987969-4-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-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=1666638391; 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=w6YpVQQSxlDA3w+M4b8tdsespQH1IXd6hGycfdHgGcdnKJmrGnp0t2xOgNUva4B/hHry17 cOAMBBC0NHOGyj8+ro7Gsyg/djaO2S5p+TxHqL/HqOWdAgCYe6wkgDO9ANke/tfzVxQpfU lRWohNa+3ro6bSENEjtfVHGBgh9JJj8= 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666638391; a=rsa-sha256; cv=none; b=fgtixDWdaBfwA8ePTSdMtTYC6S7TLT8617tQd0vW9MFmcmEdQ7K1QXvgMSdqUBfpdnVrxi lruTpE/M223NU4F50OfE5T5PeBDAlzjc9AghnMgq5kkYrNgG6xwUkuq7gVfWLL61obJ/Os KHT92fdxMlnZhaXs8Wbii/7wBI193J0= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3C8CA160004 X-Rspam-User: 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: k4i9qwwqehfif5nqkc7xpu7xxoiyhh15 X-HE-Tag: 1666638391-143850 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//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 Mon Oct 24 19:05:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13017983 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 5BFF7FA373F for ; Mon, 24 Oct 2022 19:06:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29402940009; Mon, 24 Oct 2022 15:06:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2454E940007; Mon, 24 Oct 2022 15:06:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10C7C940009; Mon, 24 Oct 2022 15:06:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 02D9E940007 for ; Mon, 24 Oct 2022 15:06:27 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6AA1A1A0D1F for ; Mon, 24 Oct 2022 19:06:26 +0000 (UTC) X-FDA: 80056773972.05.DC6F190 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf28.hostedemail.com (Postfix) with ESMTP id CC774C000D for ; Mon, 24 Oct 2022 19:06:24 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 5C2CA3ED590E; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 04/14] mm: use part per 1000 for bdi ratios. Date: Mon, 24 Oct 2022 12:05:53 -0700 Message-Id: <20221024190603.3987969-5-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-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=1666638385; 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=jSx8Kdgi7SYsVhni8CUTfVHDRrAR63Tx5LgDXY11GcE=; b=uyZu3VfoUBYUrMvN2s8T2niqYaJA29uHcDvYVTlhjQmD/gmPY2F7iZ3pHpM/D5E1WYcvE4 KdaSu2paZDJt8PP3lkp9BrHfsFH3ZGqWgLw0YuHifEN1NpKwUGptTWitLeAWwQCtG0SC8N 9lMUU8mX6DM94oqY7gnWdQhuHitBS5s= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=neutral (imf28.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=1666638385; a=rsa-sha256; cv=none; b=pUE6GVIA5mqxITXxQURsrzsssWcn4oqngmmvzMp0F6eRttrH2i7bAZ2AZNGJvQ44mWQipQ ZaNYOJ6u2L6oc0Qy8Sh4wIrb4EWwxypQRHtvM81NPeRaydzwRIb34zBEn6FUS47pMgCAtS Kj/iLYod9a7N4B8iOvyKsx9VPySPkRg= X-Rspamd-Queue-Id: CC774C000D Authentication-Results: imf28.hostedemail.com; dkim=none; spf=neutral (imf28.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-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: bazgcd8chznqm48wj4hrnwyzr3ymr9fi X-HE-Tag: 1666638384-758133 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 1000 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..19fe0e605ed8 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 1000 for finer granularity. */ +#define BDI_RATIO_SCALE 10 + 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 e22aae0ecacd..4d5383d4da45 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) { @@ -776,15 +779,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 Mon Oct 24 19:05:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13017990 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 9D5D9C38A2D for ; Mon, 24 Oct 2022 19:06:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26F70940010; Mon, 24 Oct 2022 15:06:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FA6594000C; Mon, 24 Oct 2022 15:06:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F4137940010; Mon, 24 Oct 2022 15:06:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D5D0994000C for ; Mon, 24 Oct 2022 15:06:34 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8900E16028D for ; Mon, 24 Oct 2022 19:06:34 +0000 (UTC) X-FDA: 80056774308.22.79D9E29 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 043C2100004 for ; Mon, 24 Oct 2022 19:06:33 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 6247B3ED5910; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 05/14] mm: add bdi_get_max_bytes() function Date: Mon, 24 Oct 2022 12:05:54 -0700 Message-Id: <20221024190603.3987969-6-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666638394; a=rsa-sha256; cv=none; b=mFheQE6W/hWgXGMPLFdtBX9WKp6urk/416VnfogiTO2uQw1M6g1v7dYbP08i865TosVLTJ 714chX50YRGDrrolQCZNFxq3peBeQYXz35NI6l8MDyWN4VA9EcPHgbnY5vtmlDU8Y5WkjG 7JxHIMp4Du8OUz/974g5ErWT5fCVxGY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666638394; 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=t1aPZkjeB5Y6h6IJtUv4U9JkXNmAOOb0yMfCmHKUz0I=; b=8qbZCiN/zHSpXfiLC9Mxllnb8+BsPlMeUYYAnTT68ytIIZn2pOuWxnHFgZUKk59C2NIxVS WEgNZwdfh89C+s6TbOsyLOodUq7Y3nyGd/oMrxBpgLHcs04KWttjcKMx8/+KCU9IfUm/Y0 R2gCCPXRiIEik08glQGSJC4auWv8AG8= X-Stat-Signature: permguz93cbxwdge7cmt35ijkjqgzwow X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 043C2100004 Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=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 X-HE-Tag: 1666638393-418062 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 | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 19fe0e605ed8..cb0e66564d4d 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 1000 for finer granularity. */ #define BDI_RATIO_SCALE 10 +unsigned long long 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 4d5383d4da45..0b9dcf5afda2 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 unsigned long long bdi_get_bytes(unsigned int ratio) +{ + unsigned long background_thresh; + unsigned long dirty_thresh; + unsigned long long 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,12 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio) } EXPORT_SYMBOL(bdi_set_max_ratio); +unsigned long long bdi_get_max_bytes(struct backing_dev_info *bdi) +{ + return bdi_get_bytes(bdi->max_ratio); +} +EXPORT_SYMBOL_GPL(bdi_get_max_bytes); + int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit) { if (strict_limit > 1) From patchwork Mon Oct 24 19:05:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13017986 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 5EF30ECAAA1 for ; Mon, 24 Oct 2022 19:06:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FEFC94000A; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8ADBB940007; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EF1294000A; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4C46C940007 for ; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 23F5BA237B for ; Mon, 24 Oct 2022 19:06:31 +0000 (UTC) X-FDA: 80056774182.04.5A6E3EB Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf15.hostedemail.com (Postfix) with ESMTP id AA33AA003F for ; Mon, 24 Oct 2022 19:06:30 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 684C43ED5914; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 06/14] mm: split off __bdi_set_max_ratio() function Date: Mon, 24 Oct 2022 12:05:55 -0700 Message-Id: <20221024190603.3987969-7-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-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=1666638390; 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=LqUVGiHmiJ6DXSLgcbrND54x5kK2lO6fc/yi//3REBY=; b=nVRXdr7UMd1VqSKjHerZ3UI41afIyyW6C3uye/hj9pJGtqAQY+iiIEu4we+nRsNVx2ycwn dFQXmNiw1AnKnoUraMkIRC8YsmFww3MRqPjhnnn+LKByZPR0Bfem2aAZPk3maBHnf7R5NI BfH9xpbzJqpYQbAOjBIw89+E4BTwiZM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf15.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=1666638390; a=rsa-sha256; cv=none; b=f7k1xxLB0/KzYxKVAeGAebAKR/9WT8A8O6251t8L01WVjoz2irwr+3moNOxVOglbz2pITY gVRn7WBVtTwhA4k6q8SAQELPdAXWQ7ZvPXRJN2sRSfsW1LH8NpiJ723tT+Yy3I0hCLefMa +76NJErDKvEWb7Y1Fowa/3Ga0WOF5j0= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: AA33AA003F X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf15.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: baortxmncgzajnr9mbqnx9asuqejz6ke X-HE-Tag: 1666638390-408908 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 the __bdi_set_max_ratio() function from the bdi_set_max_ratio() function. The __bdi_set_max_ratio() function will also be called from the bdi_set_max_bytes() function, 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 0b9dcf5afda2..8b8936603783 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); unsigned long long bdi_get_max_bytes(struct backing_dev_info *bdi) From patchwork Mon Oct 24 19:05: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: 13017987 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 B91ABFA373F for ; Mon, 24 Oct 2022 19:06:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 30BC094000E; Mon, 24 Oct 2022 15:06:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29336940007; Mon, 24 Oct 2022 15:06:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC8F594000E; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) 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 B23B194000C for ; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 58321A2280 for ; Mon, 24 Oct 2022 19:06:31 +0000 (UTC) X-FDA: 80056774182.29.4592AC0 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf30.hostedemail.com (Postfix) with ESMTP id E3FC180015 for ; Mon, 24 Oct 2022 19:06:30 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 6E88D3ED5916; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 07/14] mm: add bdi_set_max_bytes() function. Date: Mon, 24 Oct 2022 12:05:56 -0700 Message-Id: <20221024190603.3987969-8-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-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=1666638391; 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=EYVVEmRWLGblBv/HvcJB/YSmGkYRrfg5tbv7NtvGoG4=; b=EPG5H8cBs9vxPe0QWOEU55N6is4jf/ZVUqNVoGCOfbTjTAtQLqz0d7iC7Fno0NYKSKR+9p xwkSCU0mpJySNI7cQPKCzbPQAsbn83LFIAmB1cM5WLafEaque3Nas7nEvYB2aQJ3j9klv2 0HHHs9u+Gt0isLWbsRefVOdCdutSE28= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf30.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=1666638391; a=rsa-sha256; cv=none; b=PIf3/IyC0ZnM/m6/e4nYDmPP1G0/jsPJNJ9FTTXcs7LNACTFnkXZQdnTWOz/p+SCMZo+mS KNfMAU62aJB9LjdSDqzti7Je/23OYeP6KmyCr/uEcyOA/tvPvxY9TyTOOS0lg1yykASxY9 wkQR4rSugw8UHmPHP93nopNz8ltUd38= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E3FC180015 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf30.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: aoezhatdze71irerzs78qtjnxmtht1y7 X-HE-Tag: 1666638390-529740 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 | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index cb0e66564d4d..5eb1ae3410b2 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) unsigned long long 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, unsigned long long 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 8b8936603783..21d7c1880ea8 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 / 2) + 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 unsigned long long bdi_get_bytes(unsigned int ratio) { unsigned long background_thresh; @@ -723,6 +746,21 @@ unsigned long long bdi_get_max_bytes(struct backing_dev_info *bdi) } EXPORT_SYMBOL_GPL(bdi_get_max_bytes); +int bdi_set_max_bytes(struct backing_dev_info *bdi, unsigned long long 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); +} +EXPORT_SYMBOL_GPL(bdi_set_max_bytes); + int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit) { if (strict_limit > 1) From patchwork Mon Oct 24 19:05: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: 13017992 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 8F52AFA373F for ; Mon, 24 Oct 2022 19:06:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04B46940012; Mon, 24 Oct 2022 15:06:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC95094000C; Mon, 24 Oct 2022 15:06:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6C1A940012; Mon, 24 Oct 2022 15:06:41 -0400 (EDT) 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 BC55994000C for ; Mon, 24 Oct 2022 15:06:41 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 940A6160B65 for ; Mon, 24 Oct 2022 19:06:41 +0000 (UTC) X-FDA: 80056774602.25.6F94996 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf14.hostedemail.com (Postfix) with ESMTP id 1AF5710001F for ; Mon, 24 Oct 2022 19:06:40 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 746163ED5918; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 08/14] mm: add knob /sys/class/bdi//max_bytes Date: Mon, 24 Oct 2022 12:05:57 -0700 Message-Id: <20221024190603.3987969-9-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=neutral (imf14.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=1666638401; a=rsa-sha256; cv=none; b=mcJ/pS6EXqwXtjEKNs7U770QwXtzxF00TjKVHN/lwGdqYoyXhMW7iME8LT0aRuuc4DiQU9 9iNp7IeYxAOjd/jAa3gQf7obGqYKwGcRWGFBgwCefTXPgyXTmCgOA3bF0I57nxD+6qwunM TrcVxMayYxd6GWMNCpaGvUguAOL9W5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666638401; 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=HRjojvwutNAzIwilLfehls3OIoJ0WB8TYhETQyv8qH4=; b=rH55lp49HOUWRfVTZcrKyz1f7g/Ofp301o/KHjyQNL5ury624YnAZZMDOIvPdgjje1oL79 HLgFupQg0EkoG3PE8rH6qMLhJTVDUqPXrb0pPUnrEnz9z8vEIwv8ldilL06SA/sRKVBDhr 9UztYIcdP171diJSXbRZV6axVrnwS5k= X-Rspamd-Queue-Id: 1AF5710001F Authentication-Results: imf14.hostedemail.com; dkim=none; spf=neutral (imf14.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: tqiug8m3qsb47nidua5bbr6ca3nqz1uy X-HE-Tag: 1666638400-995409 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..d5f9a8a45550 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); + unsigned long long 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 Mon Oct 24 19:05: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: 13017989 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 59DCAECAAA1 for ; Mon, 24 Oct 2022 19:06:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB9B294000F; Mon, 24 Oct 2022 15:06:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D19FD94000C; Mon, 24 Oct 2022 15:06:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBBBF94000F; Mon, 24 Oct 2022 15:06:32 -0400 (EDT) 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 A10BC94000C for ; Mon, 24 Oct 2022 15:06:32 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 59CC180654 for ; Mon, 24 Oct 2022 19:06:32 +0000 (UTC) X-FDA: 80056774224.16.CCE17BB 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 CAF6416000E for ; Mon, 24 Oct 2022 19:06:31 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 7A4B63ED591A; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 09/14] mm: document /sys/class/bdi//max_bytes knob Date: Mon, 24 Oct 2022 12:05:58 -0700 Message-Id: <20221024190603.3987969-10-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-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=1666638391; 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=Yzs4g7j2Z0orKidRG1uNVE61lL1v3vwfAxvXopvwqqcVfHr1xVPUUoX5ntno4NUdRrut4W CwRnpymSpBCYR4FEjJB8bSTRgw5diKdEvAkHaivfg7+ItXWbzi5T5iK1UU/ZJrABKgLOsm 2l8gIjZ7NEiKa0BCthYFjAxuzUzArO8= 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666638391; a=rsa-sha256; cv=none; b=thzr/Utxhd5ABukjq2BXulmS9mNAZeuo1i8WV+1RR5Vfb963jiBCWLQ1XzHPLmsrqxeDCQ TAW800KSP8Ni9LnuwHa6duJKrcuIqJtEyAdSE5UAwo5wpDv+BrcFAwZ0TnpktqKeCrh85R 4pLRG0qBafnaiFq6znKRtX4b0s/mDiU= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CAF6416000E X-Rspam-User: 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: 96mgficq55pfnorspg4a5zwm1rdir5xa X-HE-Tag: 1666638391-758978 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 Mon Oct 24 19:05: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: 13017991 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 EB7F0ECAAA1 for ; Mon, 24 Oct 2022 19:06:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6CD6940011; Mon, 24 Oct 2022 15:06:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D1D5594000C; Mon, 24 Oct 2022 15:06:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9447940011; Mon, 24 Oct 2022 15:06:37 -0400 (EDT) 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 A7A3B94000C for ; Mon, 24 Oct 2022 15:06:37 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2B6E21C398A for ; Mon, 24 Oct 2022 19:06:37 +0000 (UTC) X-FDA: 80056774434.21.2BF0942 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf06.hostedemail.com (Postfix) with ESMTP id 95E0018000A for ; Mon, 24 Oct 2022 19:06:36 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 81FC93ED591C; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 10/14] mm: add bdi_get_min_bytes() function. Date: Mon, 24 Oct 2022 12:05:59 -0700 Message-Id: <20221024190603.3987969-11-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666638396; a=rsa-sha256; cv=none; b=TNz6g1jOXhOIWZgQyPqhiFnJYCh0xs6i00cqxaepuQ/G7WGfktPWBp6VhForjegpRFzaPD Iusnb+OU+mMxnBQI9xZuhoE3jXgF/vEPj5QIxJCo2PD28GWb/AMjk0kFv1P2Xeg2/wntXZ NUGf4wu/rj0xov3JGd3bnyCUEvL08qs= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=neutral (imf06.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=1666638396; 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=zUGrJmpr+WL12/APdEMCSVUI9VYkfwrAflxorHJthMg=; b=iMPosptOnIW3LSAS7chvfgCNYq0IFqenyFdarJME1Na/uW9IwMAFrCeNLx9Dwam9m/YrB6 0Lf6h9dvAY6kIDPnnW3t9SRBl9VU1iuw2HEiylDNeCl1ZMndZwb0IFhv0hcSgBQuTo32JO MUHBwifDhmBTv6WCmLFHnJARvc8JPI8= X-Rspamd-Queue-Id: 95E0018000A X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=none; spf=neutral (imf06.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: rspam04 X-Stat-Signature: zzr3ddbjsf954e3wzbhmx7o85up555ox X-HE-Tag: 1666638396-156737 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 | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 5eb1ae3410b2..621329f25bbe 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 1000 for finer granularity. */ #define BDI_RATIO_SCALE 10 +unsigned long long bdi_get_min_bytes(struct backing_dev_info *bdi); unsigned long long 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 21d7c1880ea8..69fc2866e625 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -740,6 +740,12 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio) } EXPORT_SYMBOL(bdi_set_max_ratio); +unsigned long long bdi_get_min_bytes(struct backing_dev_info *bdi) +{ + return bdi_get_bytes(bdi->min_ratio); +} +EXPORT_SYMBOL_GPL(bdi_get_min_bytes); + unsigned long long bdi_get_max_bytes(struct backing_dev_info *bdi) { return bdi_get_bytes(bdi->max_ratio); From patchwork Mon Oct 24 19:06: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: 13017993 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 66A99ECAAA1 for ; Mon, 24 Oct 2022 19:06:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C465940013; Mon, 24 Oct 2022 15:06:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7754294000C; Mon, 24 Oct 2022 15:06:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A106940013; Mon, 24 Oct 2022 15:06:43 -0400 (EDT) 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 4634694000C for ; Mon, 24 Oct 2022 15:06:43 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1929E1A0CE7 for ; Mon, 24 Oct 2022 19:06:43 +0000 (UTC) X-FDA: 80056774686.06.B04BD06 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 7D8BF140039 for ; Mon, 24 Oct 2022 19:06:42 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 879E23ED591E; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 11/14] mm: split off __bdi_set_min_ratio() function Date: Mon, 24 Oct 2022 12:06:00 -0700 Message-Id: <20221024190603.3987969-12-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666638402; a=rsa-sha256; cv=none; b=vJpL6oKlr/AE+zdk4DhI9kQNaB0D26WulgNevRQC0b5SkHQXy02hCnaLG7m2z1do2ySD8p IuBC63IP/zgAQYbKkwbqgxPRLd6L0iz6Tnb0FRdw0pXgRd7d7u2RsVr0q6lBfE1q76T47g ypO3uKkkidFq5sBTJ/CGl0Ih4b8Ww+E= 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666638402; 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=IZ7bEncvwhyJc9EF6wrS1C/KziMYTcD+EWx1LHFw9XY=; b=y8J8w7GgrzWb3pElbW1duGEA2fzr8Dp49pB2yVbJuBZB3RfRjPKsh2cROWltRJT5zpewdP f8c3u3UG40wuP7L2qXAIifXolHEWmS41HeoCQm3UcFzpN3C0kL9n2X84smk8G2BDwSZJaK dzQKN5s+XnLi9YU49VyY879aVX/5irY= X-Rspamd-Queue-Id: 7D8BF140039 X-Rspam-User: 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: rspam04 X-Stat-Signature: cx8ha911qw7pg4n6fpq71mztd4bh7uh8 X-HE-Tag: 1666638402-455767 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 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 69fc2866e625..07f59ed60d4a 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -685,7 +685,7 @@ static unsigned long long 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 Mon Oct 24 19:06: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: 13017994 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 0F278C38A2D for ; Mon, 24 Oct 2022 19:06:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EB98940016; Mon, 24 Oct 2022 15:06:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B062940015; Mon, 24 Oct 2022 15:06:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA09D940014; Mon, 24 Oct 2022 15:06:43 -0400 (EDT) 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 D2E9594000C for ; Mon, 24 Oct 2022 15:06:43 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B5857804E1 for ; Mon, 24 Oct 2022 19:06:43 +0000 (UTC) X-FDA: 80056774686.29.CFDE443 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf21.hostedemail.com (Postfix) with ESMTP id 5045C1C0006 for ; Mon, 24 Oct 2022 19:06:43 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 8D48A3ED5920; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 12/14] mm: add bdi_set_min_bytes() function Date: Mon, 24 Oct 2022 12:06:01 -0700 Message-Id: <20221024190603.3987969-13-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=neutral (imf21.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=1666638403; a=rsa-sha256; cv=none; b=bKo5fUMFUoDRnttX6HW3sEGq69J0MsP/cYmzBW0mnFcZca7e1PDNqSVL4F3SKcamTKRYox HwfgzhX1sOMRbX+Y0xYCywH0+GMVyIiRCODvTzb2Jtye3LqMpoqs3kOulBiOO2488YLfmZ VHvpYpqkhhC8tcRKa3EFEQJWgpmHA24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666638403; 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=6OUODX1nNAq8swH8yL3uScYOJodGqULvOeQGrmp/VBM=; b=EktAg6/4OKs9rDMR4AvuS5/eFL7vDGMHcnS9lu6JjcqcRtHa4iW+s4ipyZH2PmUShN9s/v gA+jyN0qRrTYG+pd5H8W0BFqYeSMe4+n6ZDIvmKOgaoTOu1ewb8c87yXP82uhBwwLn4J8B iIuaFqfMNgZa+zOaEmvcXfEpuu3EnLk= X-Rspamd-Queue-Id: 5045C1C0006 Authentication-Results: imf21.hostedemail.com; dkim=none; spf=neutral (imf21.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: tc1kjcopdazfzea1baqraswrx194qpdh X-HE-Tag: 1666638403-371907 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_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 | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 621329f25bbe..659e9cb8c643 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -109,6 +109,7 @@ unsigned long long bdi_get_min_bytes(struct backing_dev_info *bdi); unsigned long long 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, unsigned long long min_bytes); int bdi_set_max_bytes(struct backing_dev_info *bdi, unsigned long long 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 07f59ed60d4a..ca6cbf8e63bb 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -751,6 +751,21 @@ unsigned long long bdi_get_min_bytes(struct backing_dev_info *bdi) } EXPORT_SYMBOL_GPL(bdi_get_min_bytes); +int bdi_set_min_bytes(struct backing_dev_info *bdi, unsigned long long 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); +} +EXPORT_SYMBOL_GPL(bdi_set_min_bytes); + unsigned long long bdi_get_max_bytes(struct backing_dev_info *bdi) { return bdi_get_bytes(bdi->max_ratio); From patchwork Mon Oct 24 19:06: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: 13017995 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 2603EECAAA1 for ; Mon, 24 Oct 2022 19:06:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 70294940014; Mon, 24 Oct 2022 15:06:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B28094000C; Mon, 24 Oct 2022 15:06:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E716940014; Mon, 24 Oct 2022 15:06:44 -0400 (EDT) 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 0C4BA94000C for ; Mon, 24 Oct 2022 15:06:44 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D2169A524C for ; Mon, 24 Oct 2022 19:06:43 +0000 (UTC) X-FDA: 80056774686.25.EFAC31A Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf19.hostedemail.com (Postfix) with ESMTP id 6E7851A003C for ; Mon, 24 Oct 2022 19:06:43 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 932FB3ED5922; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 13/14] mm: add /sys/class/bdi//min_bytes knob Date: Mon, 24 Oct 2022 12:06:02 -0700 Message-Id: <20221024190603.3987969-14-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666638403; a=rsa-sha256; cv=none; b=LnuluUG1VNOhT6JObrH8E0jeVL5x8QuryuWUWce6Q3p53/7V6e57uVMpTYS4BPxfy+3aWC 9vXVKVfscVLHwMOXpjI/zY1wJJFt2+pfHmgBpyDGpbs91rKiCEmshwJj8IbSG4EPkRMIcf mHpr+mnO5z+Rk7sNKXyuml0dMbKhso0= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf19.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=1666638403; 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=PQd6Jq4ND+jJMcRVkdVY6rBoLeMfYLdxqIFjJRet+M4=; b=1OGi2Ci7ImP6aOJLW6nxnpux+LLZFgwriVUzNKmTGbtWNsgJvPLLlvmjl2GqWcWjeBadVp GFjpyBmVLTHceQScej2AjvEP0fpa6SqES6vwR31QpnuFgiGBkock5/3FlMYhBbPKa8GNb/ hlxRjEM4+Uf8osbS8QPMbRt1stI2aH0= X-Rspamd-Queue-Id: 6E7851A003C Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf19.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: rspam12 X-Rspam-User: X-Stat-Signature: t85x4qjqs9b5des59uaxinwzum4kqu38 X-HE-Tag: 1666638403-376555 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 d5f9a8a45550..53dc46ffdb9b 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); + unsigned long long 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 Mon Oct 24 19:06: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: 13017996 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 7B488ECAAA1 for ; Mon, 24 Oct 2022 19:06:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 183CC940015; Mon, 24 Oct 2022 15:06:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1337694000C; Mon, 24 Oct 2022 15:06:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 021EA940015; Mon, 24 Oct 2022 15:06:50 -0400 (EDT) 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 E36D094000C for ; Mon, 24 Oct 2022 15:06:50 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AF31B40279 for ; Mon, 24 Oct 2022 19:06:50 +0000 (UTC) X-FDA: 80056774980.10.DD15576 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf03.hostedemail.com (Postfix) with ESMTP id 4CC3C20032 for ; Mon, 24 Oct 2022 19:06:50 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 9919B3ED5924; Mon, 24 Oct 2022 12:06:12 -0700 (PDT) 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, willy@infradead.org, hch@infradead.org Subject: [RFC PATCH v3 14/14] mm: document /sys/class/bdi//min_bytes knob Date: Mon, 24 Oct 2022 12:06:03 -0700 Message-Id: <20221024190603.3987969-15-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666638410; a=rsa-sha256; cv=none; b=jKE2z2mXUJIzkbFen8+mjR+kEIlgQkGVqRWRQJ1MSNdtOGDBa3ncjmeDADd3Uygkt5TyM7 1P+B0nzrmqd/OeVM4DuH3Ty9h59ThqHhLSfkCjGD/fEjKkARZpWFvMHvI19oFXzNYaVgiH gQe1YSWBa3qHrws6w0gWrWTWmfKDurc= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf03.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=1666638410; 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=aOfuDL/2N4WylY6TNjDd1lBhRdzTTmmky+flmNYJ9h+nt0f+7fcWDclIQ3UjMFoDP/fAG7 zjUtR0ZxrWB68NaKQ4ldR6PNXFVetiTI2vOmg1WKrLCSbR+N/eel/EXIoIa0AOX1k3UA3V nxr9ap0K8vNYZOsAMzNWndylw5+5KSQ= X-Stat-Signature: ebg3c6k1rs1pamos7zm5ybbkoey9wefy X-Rspamd-Queue-Id: 4CC3C20032 Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf03.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: rspam05 X-HE-Tag: 1666638410-897895 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//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