From patchwork Sat Nov 19 00:51:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13049435 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 328ECC4332F for ; Sat, 19 Nov 2022 00:52:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2740B6B0073; Fri, 18 Nov 2022 19:52:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 24D586B0075; Fri, 18 Nov 2022 19:52:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7FF16B0074; Fri, 18 Nov 2022 19:52:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D37D26B0073 for ; Fri, 18 Nov 2022 19:52:32 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9ECF2AAC9A for ; Sat, 19 Nov 2022 00:52:32 +0000 (UTC) X-FDA: 80148366144.20.06583E6 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf20.hostedemail.com (Postfix) with ESMTP id 3CA421C0006 for ; Sat, 19 Nov 2022 00:52:31 +0000 (UTC) Received: by dev0134.prn3.facebook.com (Postfix, from userid 425415) id 4D58F19380C8; Fri, 18 Nov 2022 16:52:18 -0800 (PST) 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, akpm@linux-foundation.org Subject: [RFC PATCH v4 01/20] mm: add bdi_set_strict_limit() function Date: Fri, 18 Nov 2022 16:51:56 -0800 Message-Id: <20221119005215.3052436-2-shr@devkernel.io> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221119005215.3052436-1-shr@devkernel.io> References: <20221119005215.3052436-1-shr@devkernel.io> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=neutral (imf20.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668819152; a=rsa-sha256; cv=none; b=BHRjmQdvLk0ng+i+excgTDgawswARlqG+BnuIKH3gLy1XyzZ0+HPsmyw7YYJ0wZxjQXn/v e6laWPYkehD1vTILCpm1FqL60IALgO2W0NKC4+2pRoMn2x8prfOMtHCi+dal6ffyynI80n HiC0bwCZptFRx2Id06SxMiFphygRfPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668819152; 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=szlCkMoMk7dtgwA5rvE99aSMnKQPHVKt3470Uv1F3gQ=; b=QtNFBq8nMoHmH7QMrW+asOEjXj61WPRPrRtRJFu9fyuqRwgPR0dWy+II6112AcZuoKx29C 7AnhAICWjJpD8zK2ygPQSiFVdWsh4l1G/aPJga8QcSRlOzb/6OuC/0XsaBLhpxMOG1jkNE K2PYYtNMOpUnYyXklNdv0CuDKrR6DWs= Authentication-Results: imf20.hostedemail.com; dkim=none; spf=neutral (imf20.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-Rspamd-Server: rspam02 X-Rspam-User: X-Stat-Signature: o46dbzfa9nwyeawk76iwieekuw3x83oc X-Rspamd-Queue-Id: 3CA421C0006 X-HE-Tag: 1668819151-194684 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 | 15 +++++++++++++++ 2 files changed, 16 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..3745b886722f 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -698,6 +698,21 @@ 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; +} + static unsigned long dirty_freerun_ceiling(unsigned long thresh, unsigned long bg_thresh) {