From patchwork Mon Oct 17 18:13:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009229 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 3EE15C433FE for ; Mon, 17 Oct 2022 18:16:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4F396B0074; Mon, 17 Oct 2022 14:16:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFD7F6B0075; Mon, 17 Oct 2022 14:16:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEDF66B0078; Mon, 17 Oct 2022 14:16:35 -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 9F0786B0074 for ; Mon, 17 Oct 2022 14:16:35 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 595F740E87 for ; Mon, 17 Oct 2022 18:16:35 +0000 (UTC) X-FDA: 80031246750.09.144E550 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 02D871C0046 for ; Mon, 17 Oct 2022 18:16:34 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 1177939C99B4; Mon, 17 Oct 2022 11:13:56 -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 v2 01/14] mm: add bdi_set_strict_limit() function Date: Mon, 17 Oct 2022 11:13:24 -0700 Message-Id: <20221017181337.3884657-2-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-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=1666030595; 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=xIKEIEDTAQXbyvm/+8+8JIi77zszX7sDA+U6ieptj/0F4FAtCAoil4oOcrDSupxxRqzWRO 9A6kzBR8fieFIVJ0knZH6T8DPrJBd9/Lpzz6l7IC6Em/jKa5TzwyP5TGkXOwUBTIhf0hEh vPnrqvHvy1mPMJmmgth4I+rgfFzCE60= 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=1666030595; a=rsa-sha256; cv=none; b=dUAa3s/XNHR5c2apB1u0IUP7bUDKk4C/w24lvS4z6XuD4GBTEMFNef+uMrggTpWXHiP4rr O/aMFvXJnyU+g4t3JtckvKfNl9snh5d9Rwf+vn4ojFvJYO7BknFaKRXfCSC2F1vpeTPqkM FmRVXCREPSa6W0WU6HN8T/y7a97VU/I= X-Rspamd-Server: rspam12 X-Rspam-User: 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-Stat-Signature: 5o43yfmhywezsdh4ezqde88m8xachbu6 X-Rspamd-Queue-Id: 02D871C0046 X-HE-Tag: 1666030594-470954 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 17 18:13:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009231 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 71980C4321E for ; Mon, 17 Oct 2022 18:16:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C75978E0001; Mon, 17 Oct 2022 14:16:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFDF46B007B; Mon, 17 Oct 2022 14:16:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEF9C8E0001; Mon, 17 Oct 2022 14:16:37 -0400 (EDT) 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 9E36A6B0078 for ; Mon, 17 Oct 2022 14:16:37 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5D384C01AE for ; Mon, 17 Oct 2022 18:16:37 +0000 (UTC) X-FDA: 80031246834.23.3BEF86A 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 EA3E914002B for ; Mon, 17 Oct 2022 18:16:36 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 1802C39C99B6; Mon, 17 Oct 2022 11:13:56 -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 v2 02/14] mm: add knob /sys/class/bdi//strict_limit Date: Mon, 17 Oct 2022 11:13:25 -0700 Message-Id: <20221017181337.3884657-3-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666030597; a=rsa-sha256; cv=none; b=7GU1s3/avWiVSa3UnGC74Yk2yMyWO/oDgr4Hdh+cUr+U0VpezMCs5RSLLM6dOB33r+oCZH yxK2aRL8U0Oun8xr6CSOU0SPlsrFXyz3KhIeK4omynlKOuypwJMJtjP/8FKFwxF6mYOsbz jTGNCPnmkBeiDPvty17O3FfuuknpkU0= 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=1666030597; 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=TVrt80ZvdjlwwmbyGkSLBnD3OH8iqmGr/pdskfe+HR67LV2kBcceTjhbAhkyr6cgFBVLd6 qEcxgM48VtSZFfu5MwuRVKRSIvJ727fiM9XhKWi7mdx3t0Jhg/cUyRgCkk5GSlUAGe97hq d07g73qVV/pdnmw0W+gz0m/OrwlI2HE= X-Rspamd-Queue-Id: EA3E914002B 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: rspam08 X-Stat-Signature: qw78z7q5wq7qsq1o98ge8tkwzer5n88y X-HE-Tag: 1666030596-699394 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 17 18:13:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009230 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 3C7F5C43217 for ; Mon, 17 Oct 2022 18:16:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C28996B0075; Mon, 17 Oct 2022 14:16:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3CD16B0078; Mon, 17 Oct 2022 14:16:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A02906B007B; Mon, 17 Oct 2022 14:16:36 -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 90F546B0075 for ; Mon, 17 Oct 2022 14:16:36 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 66B70A5B3F for ; Mon, 17 Oct 2022 18:16:36 +0000 (UTC) X-FDA: 80031246792.30.478BAD3 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 EFF931A0032 for ; Mon, 17 Oct 2022 18:16:34 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 1D71F39C99B8; Mon, 17 Oct 2022 11:13:56 -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 v2 03/14] mm: document /sys/class/bdi//strict_limit knob Date: Mon, 17 Oct 2022 11:13:26 -0700 Message-Id: <20221017181337.3884657-4-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666030595; a=rsa-sha256; cv=none; b=IRys7+mt62rk1/2TqIRU103/mlYj3Qvo1WcDGRn+Qqul4ZVbBi+mSG033UCCA1/XuQlNeC 5tke2U3oKO3AmHeFLUbcHDx7v3S3u+Ht+hd3RFIDPdR9M/O2LahY57wsWZuuVOTSePpcYm ZAwXBCRCvEtBUIrSt9NOY6U+ABxddeU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=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; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666030595; 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=NmX1Xsmgphe32AyyyxQM2RDzf7ixXeavSZceK8TYmJwLRhQLw/LNzOYY+InCEH+YJyHYU8 Qcseb+kExDoe8iQUz3DWmEN34KIaS9vnnfzRqwLwKytIhDrwfY9qVaKcImd+6drwpvvw2f LMAQr9gW8tfU2/GAsEPwuvXzSUqlpLo= X-Stat-Signature: 5m9bzsskidsauwszwtyandawwdcgpz9n X-Rspamd-Queue-Id: EFF931A0032 X-Rspam-User: X-Rspamd-Server: rspam03 Authentication-Results: imf19.hostedemail.com; dkim=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; dmarc=none X-HE-Tag: 1666030594-316049 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 17 18:13:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009232 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 E33B0C4332F for ; Mon, 17 Oct 2022 18:16:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 460688E0002; Mon, 17 Oct 2022 14:16:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 437486B007B; Mon, 17 Oct 2022 14:16:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 102038E0002; Mon, 17 Oct 2022 14:16:38 -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 ECC896B0078 for ; Mon, 17 Oct 2022 14:16:37 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BAB2E160E11 for ; Mon, 17 Oct 2022 18:16:37 +0000 (UTC) X-FDA: 80031246834.15.1F8983C 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 EA7A140038 for ; Mon, 17 Oct 2022 18:16:36 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 232EB39C99BA; Mon, 17 Oct 2022 11:13:56 -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 v2 04/14] mm: use part per 1000 for bdi ratios. Date: Mon, 17 Oct 2022 11:13:27 -0700 Message-Id: <20221017181337.3884657-5-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-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=1666030597; 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=NgwubAHd9kjocE8uvVP4wygFQtvG0DFY4qWA86HkDXBjA/YMp8q5WFC9KomtJHwJ9mI//T qDK4ZxDSjqFc78vu1tqpe7DjqsyfAOAfVMjL/hgQdJMpNukEOEKq4H4d6U8mcjTfD6Sz0b G4NhcHOyvDxOQzi19y0Rx856zSOPL0U= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=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; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666030597; a=rsa-sha256; cv=none; b=sg43+Lit9FuWY9WPgdWYYhrWUnI41/D/cdf1KP9XIRhQNt2fTGZ4xIoZRojQE8rnjr8i6E IZyQEwE2yqfuzvBLaHMRYKe/XMrRYOrP9hUBYyC+gsfGRD6wQKGMKzAsC1BHKccU0Q4/JX MNJKOjXeWmnqn53EH2Ib+rFovuhkH0Y= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: EA7A140038 X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=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; dmarc=none X-Stat-Signature: d7rk8n6ej9pnady83ow7y3xyi3y31n9w X-HE-Tag: 1666030596-419782 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 17 18:13:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009234 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 739D8C4167E for ; Mon, 17 Oct 2022 18:16:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D3FA8E0003; Mon, 17 Oct 2022 14:16:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 85CF66B007D; Mon, 17 Oct 2022 14:16:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34F988E0007; Mon, 17 Oct 2022 14:16:39 -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 0B0128E0003 for ; Mon, 17 Oct 2022 14:16:39 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D39691A0F0E for ; Mon, 17 Oct 2022 18:16:38 +0000 (UTC) X-FDA: 80031246876.30.D8AEC21 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 717B8100014 for ; Mon, 17 Oct 2022 18:16:37 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 28DA239C99BC; Mon, 17 Oct 2022 11:13:56 -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 v2 05/14] mm: add bdi_get_max_bytes() function Date: Mon, 17 Oct 2022 11:13:28 -0700 Message-Id: <20221017181337.3884657-6-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666030598; a=rsa-sha256; cv=none; b=2omwpY+0rplreqiqQhBq2Db6nJmKnmFXbBBBWsmMVXJ7ObrO0Yol+o331FX7o1joN97dLB /MXXW0425BUB+TS95df1ybiViDK9Gn77Q6ux83ZWpty3AFu8lSEaU+5lvgus9hJsRJvsMc RKmGix3kIsEtUCVot4uJpDXB3VptZYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666030598; 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=QHdI3esOF6CuzpJl5fpnGlUi3GnEPmuyRqhzNT23j5rTZzwFK3ExfGnUW2Tgn1c1dXqqXq sW5ThaAkMfd0MFKee2TRxg8KrkJ7JjKq8Zrqqi+GwWiQrBqUHdyzbR3PozYxOO17GLJklZ Zhz7mRanZjNfkxjO50HTqd+7xvKXQGA= Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=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 X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: 7ochhm7abi7y38csbndsfq1kcwsuiafr X-Rspamd-Queue-Id: 717B8100014 X-HE-Tag: 1666030597-435782 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 17 18:13:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009235 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 F3A4EC433FE for ; Mon, 17 Oct 2022 18:16:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F2178E0006; Mon, 17 Oct 2022 14:16:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A2096B007D; Mon, 17 Oct 2022 14:16:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 792818E0006; Mon, 17 Oct 2022 14:16:45 -0400 (EDT) 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 68D176B007B for ; Mon, 17 Oct 2022 14:16:45 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3B253120626 for ; Mon, 17 Oct 2022 18:16:45 +0000 (UTC) X-FDA: 80031247170.29.5E402A1 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf29.hostedemail.com (Postfix) with ESMTP id C356712003E for ; Mon, 17 Oct 2022 18:16:44 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 2E69439C99BE; Mon, 17 Oct 2022 11:13:56 -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 v2 06/14] mm: split off __bdi_set_max_ratio() function Date: Mon, 17 Oct 2022 11:13:29 -0700 Message-Id: <20221017181337.3884657-7-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-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=1666030604; 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=Qsyg6IDT7XBMvFXO6F3KZ7t0OddJqOX/TzER75bUOs0xD1YvD+FIFB+2zL2bcmKI7u7Mew dy1eq/4FPGEBAq27s0R40P9pfIl6pDDqx6nncLXC3NO5O3ne9El3zRCZ0atRVvUSlqBcwF ol3G5rLyxrS61n7wbflU/8j007OyQPc= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=neutral (imf29.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=1666030604; a=rsa-sha256; cv=none; b=36gMnysM+Hrf7d0hQIjYcBW3WZozUwBkAyUz2QoRFWqI70iHEWcGYBAxyry8nkcFwybulI CJVhftL/8MYWSDJ+dXSnUYGW2jAiQiWUZLI/VZlbtxjrH6/jDir+cfkOmsYfAI7hCtGVpW DoqmGrbBFy80n8qq2keHHZ4LkBonbLs= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C356712003E X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=none; spf=neutral (imf29.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-Stat-Signature: 9mjjppsiyjcn5h11cco5i5jdm1c3jzhm X-HE-Tag: 1666030604-78182 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 17 18:13:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009238 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 E6D6FC4332F for ; Mon, 17 Oct 2022 18:16:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC35C8E0009; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C73088E0007; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC5BA8E0009; Mon, 17 Oct 2022 14:16:46 -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 9BE928E0007 for ; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4ECE3C0E4D for ; Mon, 17 Oct 2022 18:16:46 +0000 (UTC) X-FDA: 80031247212.15.F5675A0 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 D6A17160039 for ; Mon, 17 Oct 2022 18:16:45 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 3407B39C99C0; Mon, 17 Oct 2022 11:13:56 -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 v2 07/14] mm: add bdi_set_max_bytes() function. Date: Mon, 17 Oct 2022 11:13:30 -0700 Message-Id: <20221017181337.3884657-8-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666030606; a=rsa-sha256; cv=none; b=q/Ps0Ci7YtJ0zJZrzOYNWjXIobaeV/TT7ZgqNwUZJDKyER0vvPQZrU18q7U9ZhaC6vvFeI BOuAGspM0M4HH4ZnFrgS7NOgsJEJa91zXSrbsAOMt6xDKGe8JNShxFYVuEYvEI6s6llvVL 32x15XjJAg4+mRBVnQuBHOyVU1jZRwQ= 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=1666030606; 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=it+iQRaOHmELQWEQlvHFdT3OewIRYM8FjrEDUznl5E0=; b=x5bDpyxueEAyPEW+NIX2PFyIUAuEcMzqQZDlhDAOjRdCWyaS+sgxPnx/6MWgEexmd8K0UL mH2h38FutIUQbfhh96P5BJzE1orpRexjfflslhRyXWeeNA3QKu9z8S43YbYEqNcC/y7Nh+ wg690z73Lr9RK2g7KyNkqPQmty2PCUs= 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: 941riaffkfgoi8fk53en7zbz3cjw4us7 X-Rspamd-Queue-Id: D6A17160039 X-Rspamd-Server: rspam10 X-HE-Tag: 1666030605-959956 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 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..a6594ebdcbd8 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -650,6 +650,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 long pages) +{ + unsigned long background_thresh; + unsigned long dirty_thresh; + unsigned long ratio; + + global_dirty_limits(&background_thresh, &dirty_thresh); + ratio = (pages * 100 * BDI_RATIO_SCALE) / dirty_thresh; + + return ratio; +} + static unsigned long long bdi_get_bytes(unsigned int ratio) { unsigned long background_thresh; @@ -723,6 +745,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 17 18:13:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009233 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 47411C4332F for ; Mon, 17 Oct 2022 18:16:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 612266B0078; Mon, 17 Oct 2022 14:16:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 219128E0006; Mon, 17 Oct 2022 14:16:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03E3E8E0005; Mon, 17 Oct 2022 14:16:38 -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 E1C3C6B007B for ; Mon, 17 Oct 2022 14:16:38 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C476712016F for ; Mon, 17 Oct 2022 18:16:38 +0000 (UTC) X-FDA: 80031246876.07.4BD1B0D 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 09C4AA0031 for ; Mon, 17 Oct 2022 18:16:37 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 39A9139C99C2; Mon, 17 Oct 2022 11:13:56 -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 v2 08/14] mm: add knob /sys/class/bdi//max_bytes Date: Mon, 17 Oct 2022 11:13:31 -0700 Message-Id: <20221017181337.3884657-9-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-1-shr@devkernel.io> MIME-Version: 1.0 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=1666030598; a=rsa-sha256; cv=none; b=0MYmcCZxfYwIDprDTDglEkk8byxgIYhNhdnCLAP0yMei2/WT0pODsJVLBkGIxqJ/zdFWOd lqcnFxkd4wnKlXOA4NJLaNA2GFlBxYO0Ojhc12PW2hNhRXtt6Tl6/vsxxGOEiIHAD7dQdo K+6eBcTt/Kmy7xedpEe5HkMU8Ww2AF8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666030598; 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=B9+niVayIAx8iTMcHfNoLxvXuMo49b7IPJVOomFLJ37KOfnCANgl2KsiO01Th8rPYnWVgG gUyHzBPs1hL/TAbWUuzddWY8GHtu6jEhnbme+DsY21YLBXbJQIppcjDCwnWmROkqsL/wfT +/UE9dQXyiWmlDDGODbkSRBYtn/Jyd8= 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-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: bxiazkj4uefcnogrgyiodyo41ajinm5x X-Rspamd-Queue-Id: 09C4AA0031 X-HE-Tag: 1666030597-565720 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 17 18:13:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009236 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 2CA49C4332F for ; Mon, 17 Oct 2022 18:16:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17C2B8E0008; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 129868E0007; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6E568E0008; Mon, 17 Oct 2022 14:16:45 -0400 (EDT) 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 D2D016B007B for ; Mon, 17 Oct 2022 14:16:45 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id AB1AB1A0DED for ; Mon, 17 Oct 2022 18:16:45 +0000 (UTC) X-FDA: 80031247170.28.2A9E695 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 4215A40033 for ; Mon, 17 Oct 2022 18:16:45 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 3F2D039C99C4; Mon, 17 Oct 2022 11:13:56 -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 v2 09/14] mm: document /sys/class/bdi//max_bytes knob Date: Mon, 17 Oct 2022 11:13:32 -0700 Message-Id: <20221017181337.3884657-10-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-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=1666030605; 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=2ryPz0io6pLGWtxWXqrA+OxeWtn9zn8Yyhsbs7jFNSysFy4UqQ0BwexClGSuvN1570NEPX 3Opf+QRXLnzi8nYtiU0zkQK6hjqJ9uJ+eByxvaeFOIIJ+sxGqPptQ3rwL+rY66KGd3z1j9 DtHqI/47N0bTBOHUr5mVeGtdwFRGUgs= 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666030605; a=rsa-sha256; cv=none; b=rcmuZ8bbJ3vcqROiW9uFeR9O0kLbjzowAahlAI+kqjvuZvKsV1SAiNqO9UQRoG3i1X+iDi jn2JjGZWzWMixw4PFaPivVeBzbUF1scohtAABII6nqNQ4pWtMngX42akFD9Wum5qr80Bbe +zFD8SJ1hXcXz7w3cL+o+Pn8GY/FC0U= 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-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4215A40033 X-Rspam-User: X-Stat-Signature: tu74p3jms7nck9qzxncojwy1gnft89ig X-HE-Tag: 1666030605-36052 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 17 18:13:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009239 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 3FFDFC43219 for ; Mon, 17 Oct 2022 18:16:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B70E8E000A; Mon, 17 Oct 2022 14:16:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE3368E0007; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFEB78E000A; Mon, 17 Oct 2022 14:16:46 -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 AE5FB8E0007 for ; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 73659160D0F for ; Mon, 17 Oct 2022 18:16:46 +0000 (UTC) X-FDA: 80031247212.18.2F2A517 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 E833C100030 for ; Mon, 17 Oct 2022 18:16:45 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 44E9F39C99C6; Mon, 17 Oct 2022 11:13:56 -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 v2 10/14] mm: add bdi_get_min_bytes() function. Date: Mon, 17 Oct 2022 11:13:33 -0700 Message-Id: <20221017181337.3884657-11-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-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=1666030606; 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=5HNtT2D4okHKWExVxt+QjyvzzXQe2cjqnwjG+4w8RjE=; b=bzr1WynfPa8TRJJd3+699Y6cBhvwiGfoOQ+Wl7SCXUxBV9mt9rVBmCmbU5nWfYCd0c6ove qFRr1A4ohZECFFVCHuAqbS0vJrhvWJ5gly0B+HU6Eydco4OhiiX9mSxWYFztZXR/GCXSHJ 5tNY2KQzudx1U11IWYaBLawY8sWYMrQ= 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666030606; a=rsa-sha256; cv=none; b=Ft925oazODJ2erOKjsQvCV8ciFwJBf1F7NXKop86kzb+WtGSbKJiqxJVA0KdZrxHJ9aruF hGkLh2qI4zDYLCiUvPTh3cXGSqozQtJGRlrmLjYXocMTqsog0jDAfsm0sePGReuecZRUT0 7onujugwg3bTEgrCk5MvF/G0qfGr/xg= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E833C100030 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-Stat-Signature: bnjucnur1i4mkmjbuez9x5j6tokzqkni X-HE-Tag: 1666030605-357918 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 a6594ebdcbd8..a37a25994ad8 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -739,6 +739,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 17 18:13:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009240 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 C6279C433FE for ; Mon, 17 Oct 2022 18:16:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6334A8E000B; Mon, 17 Oct 2022 14:16:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 596218E0007; Mon, 17 Oct 2022 14:16:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39AEB8E000B; Mon, 17 Oct 2022 14:16:52 -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 1E7D78E0007 for ; Mon, 17 Oct 2022 14:16:52 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E604D8034C for ; Mon, 17 Oct 2022 18:16:51 +0000 (UTC) X-FDA: 80031247422.13.8F58A86 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 88CD480033 for ; Mon, 17 Oct 2022 18:16:51 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 4A81139C99C8; Mon, 17 Oct 2022 11:13:56 -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 v2 11/14] mm: split off __bdi_set_min_ratio() function Date: Mon, 17 Oct 2022 11:13:34 -0700 Message-Id: <20221017181337.3884657-12-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=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; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666030611; a=rsa-sha256; cv=none; b=74pYL9ER6JgW9qDEjjF7jIEI/prso9BS2q03tfSXBsYYJHWZF2dUa9ptslmQg32YpNM2bQ no9dsxcZluu/sh/jaBDSCWRm6aCZShwO+ZxZPoXMqTssjnpfredfDWO6C9zZXlZg6jWk1+ +MkTMxxV9jmpu6CQGR+uQT6V/ne2UUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666030611; 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=teDNe1Ua7LbxZMqlEBzF6LNgDM/LSr7KGIqwPnX0YBc=; b=qA2sGZAUrL5QcVJP8dGva/x8lsWyQlXdSXfP5X3WaNDJjG6+okBF6S+d3LXw/uiOErPyg4 bP8z6tWnR++qUkmL2WdcLb3IkySi0ofklUNe7vOjRIb4CebBMNVx4AvgM/GrQLwmNv+T21 kLwCtFrfLLJssWZm9hzdbEgJYeZJXR8= X-Stat-Signature: tn866gspru7jtn58ob7z1b4i8ze51cw4 X-Rspamd-Queue-Id: 88CD480033 Authentication-Results: imf30.hostedemail.com; dkim=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; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1666030611-147509 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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 a37a25994ad8..7733dcf96d7e 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -684,7 +684,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; @@ -730,6 +730,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 17 18:13:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009237 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 7CD21C433FE for ; Mon, 17 Oct 2022 18:16:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 460B86B007B; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 348B78E0009; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B7C26B007E; Mon, 17 Oct 2022 14:16:46 -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 E3ECC8E0007 for ; Mon, 17 Oct 2022 14:16:45 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BAD3640F0A for ; Mon, 17 Oct 2022 18:16:45 +0000 (UTC) X-FDA: 80031247170.23.F990743 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf29.hostedemail.com (Postfix) with ESMTP id 54F3012003F for ; Mon, 17 Oct 2022 18:16:45 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 5018B39C99CA; Mon, 17 Oct 2022 11:13:56 -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 v2 12/14] mm: add bdi_set_min_bytes() function Date: Mon, 17 Oct 2022 11:13:35 -0700 Message-Id: <20221017181337.3884657-13-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-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=1666030605; 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=Fn53sXB0tYzghzXcq7eiufnYR5imF4AEMK7yuCoLRzk=; b=VTq3KblHsrotnH+2I47HufOb7TCIrk7yj0TOKQH28xmM/X/wepyMBJ4wCkxZFFc4peU77u mpkTyKDE8sm8JQML+f5nkjxXLYTYG0K4A1TSZ+ChaUCRhHfXSAiL9ucKk9pKvBkCpz34fb fpB8E4030S3h3U0sUR+XG/oQ1fYckx4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=neutral (imf29.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=1666030605; a=rsa-sha256; cv=none; b=pSXzY4LLUUf+mWLNSmxmajnj9lRATLLXlBspk1GPBLqgF16NLoiQ/eT1O2sfOjXV/mjpdm Zjgpi5j0eq4kaU10cDDFv400ejTL2JC71hW6AjvoB6Mil89dwn6+P2YzJ2Iz/hYcT37OS9 Cvaik7UsBvXL2/zxipHp65mRYmwL40M= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 54F3012003F X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=none; spf=neutral (imf29.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-Stat-Signature: 5pxwpkwu9xhfajfkmqdwe7khpg64w9ic X-HE-Tag: 1666030605-101869 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 7733dcf96d7e..04c4a142098b 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -750,6 +750,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 17 18:13:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009241 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 0C883C4167B for ; Mon, 17 Oct 2022 18:16:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DCA18E000C; Mon, 17 Oct 2022 14:16:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98D148E0007; Mon, 17 Oct 2022 14:16:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87CC18E000C; Mon, 17 Oct 2022 14:16:56 -0400 (EDT) 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 781E98E0007 for ; Mon, 17 Oct 2022 14:16:56 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 405C0140F66 for ; Mon, 17 Oct 2022 18:16:56 +0000 (UTC) X-FDA: 80031247632.25.CB92271 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 D62A540046 for ; Mon, 17 Oct 2022 18:16:55 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 55CBA39C99CC; Mon, 17 Oct 2022 11:13:56 -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 v2 13/14] mm: add /sys/class/bdi//min_bytes knob Date: Mon, 17 Oct 2022 11:13:36 -0700 Message-Id: <20221017181337.3884657-14-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666030616; a=rsa-sha256; cv=none; b=MS21vFLm83nUqr4ChnF8261HjISvA6R5cwahywfU66jVKJTXwyKKDMSGJfrcC/uvMGWyNh bQDuw0TqmHa61sgs5yPsNk6T1bS4FeJynK9zog43lXrrIuvETfY7XUWCB6wJGzAoieXYO8 ufkz48q3WVjYH9IuXRU11DvfA2hDE3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666030616; 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=WQEMF6FY13qlAOjQsnMFqiEVKaBSRGLwtUZog8fsrfHvKJ9VNvQVyIyDRwKpknUN9oIAbG DlBdOAxAQQmSNSv1tUj8RSMrZM6yGMExY0mY43ydIN4SOVa66nMI4Yh9N3YgKsj6ikMc3Y O027KZJVMrZGUV5c+Vd4gsk/yTWsdS8= Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=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 X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: ahhn45e3yb8ek4rzz895wy1799bkjpx1 X-Rspamd-Queue-Id: D62A540046 X-HE-Tag: 1666030615-488859 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 17 18:13:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009242 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 75E30C4332F for ; Mon, 17 Oct 2022 18:16:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 102868E000D; Mon, 17 Oct 2022 14:16:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B4168E0007; Mon, 17 Oct 2022 14:16:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE5668E000D; Mon, 17 Oct 2022 14:16:58 -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 D86588E0007 for ; Mon, 17 Oct 2022 14:16:58 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8736D1A016E for ; Mon, 17 Oct 2022 18:16:58 +0000 (UTC) X-FDA: 80031247716.28.BBAAEE9 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 2D4B0180033 for ; Mon, 17 Oct 2022 18:16:57 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 5B60139C99CE; Mon, 17 Oct 2022 11:13:56 -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 v2 14/14] mm: document /sys/class/bdi//min_bytes knob Date: Mon, 17 Oct 2022 11:13:37 -0700 Message-Id: <20221017181337.3884657-15-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221017181337.3884657-1-shr@devkernel.io> References: <20221017181337.3884657-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=1666030618; 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=n0wNTIU3YfYNvjS9zN/vza7uw3pT23I6ZNGrTzZDzS1I0uBamaVKfkFCW03wVQ7ILl0JHg PxufVOrY0RAWpZTd7AqBvCJduvblc08SOuB6OKIlq/NJ4M2bph8UDaKV8yzXUajQC4GXkX 6J/zF+MGXie2/tYq5O36zeAShs/WXx8= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=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; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666030618; a=rsa-sha256; cv=none; b=bJ8VVEwj7x4nf42YKzJae+tN9vmoHDwfLueTIxMq9Oche0NtP/3Y/b4H+DcUKTbY5Cr5Nc 9oitFrjDKKKyDmS3ZJn7ahAapruURbR95fCBiCz7Z3HUQwqh8JF2fLHTXlLg9HnhzkrJrI k7KKACh0XvpMuS676IPZcf/Xs2F5Zr8= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2D4B0180033 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=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; dmarc=none X-Stat-Signature: tf1dt7cufsaj9bbwyt4stxgghfno1dq9 X-HE-Tag: 1666030617-95589 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