From patchwork Tue Oct 11 01:00:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13003487 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 743DCC4332F for ; Tue, 11 Oct 2022 01:01:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A5782900007; Mon, 10 Oct 2022 21:01:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DD09900008; Mon, 10 Oct 2022 21:01:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 856FF900007; Mon, 10 Oct 2022 21:01:29 -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 6D347900005 for ; Mon, 10 Oct 2022 21:01:29 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2DFC51A0FEA for ; Tue, 11 Oct 2022 01:01:29 +0000 (UTC) X-FDA: 80006865498.15.92950CF Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf13.hostedemail.com (Postfix) with ESMTP id 6C8002002B for ; Tue, 11 Oct 2022 01:01:28 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 19A1534BDDDE; Mon, 10 Oct 2022 18:01:06 -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 Subject: [RFC PATCH v1 08/14] mm: Add new knob /sys/class/bdi//max_bytes Date: Mon, 10 Oct 2022 18:00:38 -0700 Message-Id: <20221011010044.851537-9-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221011010044.851537-1-shr@devkernel.io> References: <20221011010044.851537-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=neutral (imf13.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665450088; a=rsa-sha256; cv=none; b=eLLW/QNOIOXYkJOzPbxu77vOypon7xx3x6NH1/UaK4o5Au6jU3JEnpGvLAYEWjoIFaDyk/ Ry6llRfeVZYj1Gb5Blso1jxiZ3Y97GCFDC90IHQOQTOg67R3aq4kHyjoZwru0eBqYMPGUJ 7W3vhKiOaeLExQl6/+p2luxrGU1BWMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665450088; 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=F4NPhnB88Tya0oth5y1oYsdLs0otd0rcqLckIwUpYxQ=; b=jNTd/snu7FTcCPCGgTlLO6gYzccTVQsng9IDzy/VwmkiAVoCDrcmCHV/2hYb7hq6k9NDWY YgbJscUqkrpAMI0zpDj+rcEI+w2g/jKfuiiaZaT884yL94ag1aX1NxlpFj7PSHi7ig65s7 Ggwy3xBc9w/UsujlUVCFyMcxrjLO2N8= X-Rspamd-Queue-Id: 6C8002002B X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=none; spf=neutral (imf13.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io; dmarc=none X-Rspamd-Server: rspam10 X-Stat-Signature: xzrwa9c6et4sn8tqzfyuuzt9941cugz9 X-HE-Tag: 1665450088-949307 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 e64bc49561b1..a3cad145b219 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,