From patchwork Mon Oct 24 19:05:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13017985 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 A27FFC38A2D for ; Mon, 24 Oct 2022 19:06:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F28894000D; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 551E494000C; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2518F94000A; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 025CE94000A for ; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C2602140D82 for ; Mon, 24 Oct 2022 19:06:30 +0000 (UTC) X-FDA: 80056774140.06.0D75D2B Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf30.hostedemail.com (Postfix) with ESMTP id 5DB4380038 for ; Mon, 24 Oct 2022 19:06:30 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 504903ED590A; Mon, 24 Oct 2022 12:06:12 -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 v3 02/14] mm: add knob /sys/class/bdi//strict_limit Date: Mon, 24 Oct 2022 12:05:51 -0700 Message-Id: <20221024190603.3987969-3-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221024190603.3987969-1-shr@devkernel.io> References: <20221024190603.3987969-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666638390; 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=nxx7YiD43JOFunLoIOlOfrwcGN1u/CIOvDPEHs3mjirlc2CnM8bQsEv/d8SL+n3hJUBGUu oN507RiOx4VZIRipvX+tpS5j6dm+CKPvuEmsAHNjLpRASG4DgRK7nlrY0T35DSc437nJyt HofhVOXoHMfNOX4SOjgFeMhMiC1udeo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf30.hostedemail.com: 66.220.144.178 is neither permitted nor denied by domain of shr@devkernel.io) smtp.mailfrom=shr@devkernel.io ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666638390; a=rsa-sha256; cv=none; b=J7npyO3r/4J9FC2RbUiszI+QYytIw6r5TfqCXpZHlyJJvweUEXzmnXjMyqD4RIrEWSWej+ zVE9DoByqIUbJKDcGLD6pftNy7bpmJFl5aCsAxK3saksG9K8j6XMJUZJBtgaAAJN7ebA9p w6Ar+DMRD3Qj8++ERxNYEXrujTrJag4= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5DB4380038 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf30.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: 4o6qsgbx34kd9j89zyrcsen3f3yt6z96 X-HE-Tag: 1666638390-818684 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);