From patchwork Mon Oct 17 18:13:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009229 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 3EE15C433FE for ; Mon, 17 Oct 2022 18:16:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4F396B0074; Mon, 17 Oct 2022 14:16:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFD7F6B0075; Mon, 17 Oct 2022 14:16:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEDF66B0078; Mon, 17 Oct 2022 14:16:35 -0400 (EDT) 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 9F0786B0074 for ; Mon, 17 Oct 2022 14:16:35 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 595F740E87 for ; Mon, 17 Oct 2022 18:16:35 +0000 (UTC) X-FDA: 80031246750.09.144E550 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 02D871C0046 for ; Mon, 17 Oct 2022 18:16:34 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 1177939C99B4; 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 01/14] mm: add bdi_set_strict_limit() function Date: Mon, 17 Oct 2022 11:13:24 -0700 Message-Id: <20221017181337.3884657-2-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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666030595; 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=xIKEIEDTAQXbyvm/+8+8JIi77zszX7sDA+U6ieptj/0F4FAtCAoil4oOcrDSupxxRqzWRO 9A6kzBR8fieFIVJ0knZH6T8DPrJBd9/Lpzz6l7IC6Em/jKa5TzwyP5TGkXOwUBTIhf0hEh vPnrqvHvy1mPMJmmgth4I+rgfFzCE60= 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=1666030595; a=rsa-sha256; cv=none; b=dUAa3s/XNHR5c2apB1u0IUP7bUDKk4C/w24lvS4z6XuD4GBTEMFNef+uMrggTpWXHiP4rr O/aMFvXJnyU+g4t3JtckvKfNl9snh5d9Rwf+vn4ojFvJYO7BknFaKRXfCSC2F1vpeTPqkM FmRVXCREPSa6W0WU6HN8T/y7a97VU/I= X-Rspamd-Server: rspam12 X-Rspam-User: 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-Stat-Signature: 5o43yfmhywezsdh4ezqde88m8xachbu6 X-Rspamd-Queue-Id: 02D871C0046 X-HE-Tag: 1666030594-470954 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) {