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);