From patchwork Tue Oct 11 01:00:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13003477 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 00B15C433F5 for ; Tue, 11 Oct 2022 01:01:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 793E76B0073; Mon, 10 Oct 2022 21:01:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 743B86B0074; Mon, 10 Oct 2022 21:01:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6334D6B0075; Mon, 10 Oct 2022 21:01:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4FC6D6B0073 for ; Mon, 10 Oct 2022 21:01:18 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2EE0FC0FFC for ; Tue, 11 Oct 2022 01:01:18 +0000 (UTC) X-FDA: 80006865036.30.26487B9 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf10.hostedemail.com (Postfix) with ESMTP id CBB06C0019 for ; Tue, 11 Oct 2022 01:01:17 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id E675C34BDDCF; 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 01/14] mm: add bdi_set_strict_limit() function Date: Mon, 10 Oct 2022 18:00:31 -0700 Message-Id: <20221011010044.851537-2-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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665450077; 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=d/iFoe1bt1NpYx+Au3tv9hTFtJHOJTfblPbH7ptRjB8=; b=sdxo8YSOhiUM/JAIi7t4YPEAIxdbzym3wlq2R4xRdIqISpp7wRneXX56lp8DrbPpDc+dXg 8WBOI94WV/3qgCakLOxPz5Fuc8hWnueZdTDR3xiSgFBt5cSNiUhxBzlKvjHaL9DFFkSEi+ SXK95wvEssLz1BOqli8YDoKrBK4cLyk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf10.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=1665450077; a=rsa-sha256; cv=none; b=b2mNYWmLZs+KmRRmWwp+3lvH8UZEKcvEppK3cQdOC94qLQjdxSwEdFNlUJPckSRWbYbfA/ PMpptZ6B5QA/EkTxHWtcOTqu8pUjKS4zLPAa1hV1ppF4CvYbL3XMfOS5RyckSrpaqmafmN 1RPxa8zIjgIlFkxEupF7ea/zzvdFbOU= Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf10.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: pshzgx78twigqnpa4wn7mxh4m71p4wem X-Rspamd-Queue-Id: CBB06C0019 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1665450077-499746 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 bdi_set_strict_limit function to be able to set/unset the BDI_CAP_STRICTLIMIT flag. Signed-off-by: Stefan Roesch --- include/linux/backing-dev.h | 1 + mm/page-writeback.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h index 439815cc1ab9..9c984ffc8a0a 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -104,6 +104,7 @@ static inline unsigned long wb_stat_error(void) int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio); int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio); +int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit); /* * Flags in backing_dev_info::capability diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7e9d8d857ecc..e22aae0ecacd 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -698,6 +698,22 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio) } EXPORT_SYMBOL(bdi_set_max_ratio); +int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit) +{ + if (strict_limit > 1) + return -EINVAL; + + spin_lock_bh(&bdi_lock); + if (strict_limit) + bdi->capabilities |= BDI_CAP_STRICTLIMIT; + else + bdi->capabilities &= ~BDI_CAP_STRICTLIMIT; + spin_unlock_bh(&bdi_lock); + + return 0; +} +EXPORT_SYMBOL_GPL(bdi_set_strict_limit); + static unsigned long dirty_freerun_ceiling(unsigned long thresh, unsigned long bg_thresh) {