From patchwork Sat Nov 19 00:51:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DF60C43217 for ; Sat, 19 Nov 2022 00:52:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EDAC6B0074; Fri, 18 Nov 2022 19:52:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 976AB6B0078; Fri, 18 Nov 2022 19:52:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 690796B0075; Fri, 18 Nov 2022 19:52:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5246D6B0074 for ; Fri, 18 Nov 2022 19:52:36 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 332DD1A023B for ; Sat, 19 Nov 2022 00:52:36 +0000 (UTC) X-FDA: 80148366312.24.04C5C50 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf07.hostedemail.com (Postfix) with ESMTP id 9C2164000D for ; Sat, 19 Nov 2022 00:52:35 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 5064719380CA; Fri, 18 Nov 2022 16:52:18 -0800 (PST) From: Stefan Roesch To: kernel-team@fb.com, linux-block@vger.kernel.org, linux-mm@kvack.org Cc: shr@devkernel.io, axboe@kernel.dk, clm@meta.com, akpm@linux-foundation.org Subject: [RFC PATCH v4 02/20] mm: add knob /sys/class/bdi//strict_limit Date: Fri, 18 Nov 2022 16:51:57 -0800 Message-Id: <20221119005215.3052436-3-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668819155; a=rsa-sha256; cv=none; b=xsyJ/3c0xaSsbemOQPrEGvduv3q2/K4ylnOIQEvy9Cm1hxk7kfzmzZPGgviqCjZNkEA1Q8 s8IYpLmh25GSkc6U61e/IKLXOqpK40b4QjRH+GUkBfSIgTrPkYHLTTw3cqnBwDMAC8qRm6 KBtRT2Xc1f0S27/s2u+z3B0gWfaVwdU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf07.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668819155; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GTiUzoAmXnetMWfur67p/57Eq7Hkwtg7/8F/+h9Zbnw=; b=V+03lm3mycNJ7gYk0u3EBVqdnAOmBAShrZKK9vAWRBPQZ4hTXP3XsQ3l6dzMUlOe4mFgSY 1FzY6gT3juVE7qg2DlrrWdOT8/IAmhqKuTRYB0cqxZhEIN1R8808+C0LR6ckO3UgOWe0q/ B6pXqYbPhDfoqScjiN7DXPlPEzM0EBY= Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf07.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io X-Rspam-User: X-Stat-Signature: 7df1kdnmjhhpanccbmkbxemia66ek9px X-Rspamd-Queue-Id: 9C2164000D X-Rspamd-Server: rspam11 X-HE-Tag: 1668819155-352899 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add a new knob to /sys/class/bdi//strict_limit. This new knob allows to set/unset the flag BDI_CAP_STRICTLIMIT in the bdi capabilities. Signed-off-by: Stefan Roesch --- mm/backing-dev.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index c30419a5e119..a0899cce72ef 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -209,11 +209,40 @@ static ssize_t stable_pages_required_show(struct device *dev, } static DEVICE_ATTR_RO(stable_pages_required); +static ssize_t strict_limit_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + unsigned int strict_limit; + ssize_t ret; + + ret = kstrtouint(buf, 10, &strict_limit); + if (ret < 0) + return ret; + + ret = bdi_set_strict_limit(bdi, strict_limit); + if (!ret) + ret = count; + + return ret; +} + +static ssize_t strict_limit_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct backing_dev_info *bdi = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", + !!(bdi->capabilities & BDI_CAP_STRICTLIMIT)); +} +static DEVICE_ATTR_RW(strict_limit); + static struct attribute *bdi_dev_attrs[] = { &dev_attr_read_ahead_kb.attr, &dev_attr_min_ratio.attr, &dev_attr_max_ratio.attr, &dev_attr_stable_pages_required.attr, + &dev_attr_strict_limit.attr, NULL, }; ATTRIBUTE_GROUPS(bdi_dev);