From patchwork Mon Oct 24 19:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13017984 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 CA8D9ECAAA1 for ; Mon, 24 Oct 2022 19:06:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2530F94000B; Mon, 24 Oct 2022 15:06:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CF3F940007; 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 0E5FF94000B; Mon, 24 Oct 2022 15:06:31 -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 EEB0D940007 for ; Mon, 24 Oct 2022 15:06:30 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D4DC7140D92 for ; Mon, 24 Oct 2022 19:06:30 +0000 (UTC) X-FDA: 80056774140.04.0E67A9D Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf27.hostedemail.com (Postfix) with ESMTP id 5CAC640028 for ; Mon, 24 Oct 2022 19:06:30 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 4C3843ED5908; 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 01/14] mm: add bdi_set_strict_limit() function Date: Mon, 24 Oct 2022 12:05:50 -0700 Message-Id: <20221024190603.3987969-2-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=d/iFoe1bt1NpYx+Au3tv9hTFtJHOJTfblPbH7ptRjB8=; b=vef3mlIuf/nutgm10LKj3BqBa6hShF/VwJ02ram5p7iRYDldpgdxrHPSU5UmLqvU7nAmyS dIMRF0K6TsL1JOn3s6VWuLOycVheFH+JvaWCzwFYED5i15HJzaryC8rJBcSISsjwpl7jg9 7j2IYFVwJ7tA6nhi/C2eGE19eo8vMkA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf27.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=rafIBF/f5PTBYjikjmKfW71LuEeHNLbhBNyX4+Nrg640milBpZUprLcnMb8dm+91kVuWYO cCYpGsKBhQDGLuCdcI2IZ4TtuKLCMjriW5FL7Iez0nC0jh9msu1KrUeIU4cB4E/Q2KvhGk jOYCWAyRR0IefVdXy8Nwl+knI7CshQ0= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5CAC640028 X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=neutral (imf27.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: 6efhtswc1w6d6pmyripocmjfy7ba6txw X-HE-Tag: 1666638390-367661 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) {