From patchwork Tue Oct 11 01:00: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: 13003479 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 CD1B4C433F5 for ; Tue, 11 Oct 2022 01:01:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 580006B0075; Mon, 10 Oct 2022 21:01:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FEC28E0001; Mon, 10 Oct 2022 21:01:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D6678E0003; Mon, 10 Oct 2022 21:01:20 -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 19BCC8E0002 for ; Mon, 10 Oct 2022 21:01:20 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D8D0940F8C for ; Tue, 11 Oct 2022 01:01:19 +0000 (UTC) X-FDA: 80006865078.16.E34567C 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 75EEF140025 for ; Tue, 11 Oct 2022 01:01:19 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id EC6BD34BDDD2; Mon, 10 Oct 2022 18:01:05 -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 02/14] mm: Add new knob /sys/class/bdi//strict_limit Date: Mon, 10 Oct 2022 18:00:32 -0700 Message-Id: <20221011010044.851537-3-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665450079; a=rsa-sha256; cv=none; b=SOEf88wM4ym8v+8vYusmOxqnjFRTZX1TBVZMcf7AhUdo0BhXQk4vgxOe67WykCbc9JF42+ qXwkKAV/Ey8E5dIgR/TSMxK5+ER5psW+3rTX9EVfMA8Gw3+JZr9tFB6XcZ3Zye3ApkC0Kp opoq7CZJGa9vNlK8vLwWTfZhn2ToEPs= 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=1665450079; 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=IGZdKbeEWglLon1ji1xCOGLZx125v38HfU6neXGyf7U=; b=p1kGn8LR7d5crqm4ULI43Grba2ApUgpU1F1xsHM1lrJBq06ug9mxwTSDKd4T51FaBMLdkK 60Vm8/WY9EevBEZVi0tVlvyhxVF4z1ELG6+U80USGr+cbfGdv1Dy6j+Y2MosnJeoP/ftVc ZaShwFMngetZAlGGRxUxXW6EUDwHluA= 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-Stat-Signature: 89echemur3qhbukbwjimjbkd9kwjftaq X-Rspamd-Queue-Id: 75EEF140025 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1665450079-497579 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 de65cb1e5f76..f9aaa14ad98f 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);