From patchwork Sat Nov 19 00:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31A09C4332F for ; Sat, 19 Nov 2022 01:45:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5F156B0073; Fri, 18 Nov 2022 20:45:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE6548E0001; Fri, 18 Nov 2022 20:45:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5FC46B0075; Fri, 18 Nov 2022 20:45:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 964A66B0073 for ; Fri, 18 Nov 2022 20:45:42 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6E72880883 for ; Sat, 19 Nov 2022 01:45:42 +0000 (UTC) X-FDA: 80148500124.21.EB17A23 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf08.hostedemail.com (Postfix) with ESMTP id 1306916000B for ; Sat, 19 Nov 2022 01:45:41 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 6B4AF19380D6; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 08/20] mm: add knob /sys/class/bdi//max_bytes Date: Fri, 18 Nov 2022 16:52:03 -0800 Message-Id: <20221119005215.3052436-9-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668822342; a=rsa-sha256; cv=none; b=tGxCjA5pYjtczy7k8EKOQTOs/TgFWgEJ2Peeuc32fLHJnV3Tu+hw3zJZDjCz4Af+jJUMJF ZSuyz8U/4JzOTGawEw0mfUXmMcUTX2GCNf1qBg/xUQZ6F1hVpWdK32LTl8SzbiHMsGfh1A +P39aURp/d23XVZ7odiuB1upJt21Gw0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf08.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668822342; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a2bCCV9zuA3dixLxlt9sozvXlK1yM8DnEdAqmWWvlLY=; b=8lv8GqQlCvmlv6Izf+o7Mx06X5HQLl8kW2PsnkH5C25s33pyLS74/mIcpyTcc57y+n9KcX AJcpUuMuDZln/82WoMu74cKPMAB6cr72OQAxpT8R9AK+hgY/naK3jzdB5cd6+bOCMP6jt3 xe4tIplemyQoFJ1YxAbbE0jQn4qPObs= X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1306916000B Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf08.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Stat-Signature: zoadsiteqks3xef45rxkxdqi91krnf9g X-HE-Tag: 1668822341-706246 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This adds the new knob max_bytes to specify a dirty memory limit for the corresponding bdi. The specified bytes value is converted to a ratio. Signed-off-by: Stefan Roesch --- mm/backing-dev.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 90fa517123dc..95d3229fc81f 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -199,6 +199,34 @@ static ssize_t max_ratio_store(struct device *dev, } BDI_SHOW(max_ratio, bdi->max_ratio / BDI_RATIO_SCALE) +static ssize_t max_bytes_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%llu\n", bdi_get_max_bytes(bdi)); +} + +static ssize_t max_bytes_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + u64 bytes; + ssize_t ret; + + ret = kstrtoull(buf, 10, &bytes); + if (ret < 0) + return ret; + + ret = bdi_set_max_bytes(bdi, bytes); + if (!ret) + ret = count; + + return ret; +} +DEVICE_ATTR_RW(max_bytes); + static ssize_t stable_pages_required_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -241,6 +269,7 @@ static struct attribute *bdi_dev_attrs[] = { &dev_attr_read_ahead_kb.attr, &dev_attr_min_ratio.attr, &dev_attr_max_ratio.attr, + &dev_attr_max_bytes.attr, &dev_attr_stable_pages_required.attr, &dev_attr_strict_limit.attr, NULL,