From patchwork Mon Oct 17 18:13:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13009237 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 7CD21C433FE for ; Mon, 17 Oct 2022 18:16:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 460B86B007B; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 348B78E0009; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B7C26B007E; Mon, 17 Oct 2022 14:16:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E3ECC8E0007 for ; Mon, 17 Oct 2022 14:16:45 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BAD3640F0A for ; Mon, 17 Oct 2022 18:16:45 +0000 (UTC) X-FDA: 80031247170.23.F990743 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf29.hostedemail.com (Postfix) with ESMTP id 54F3012003F for ; Mon, 17 Oct 2022 18:16:45 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 5018B39C99CA; 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 12/14] mm: add bdi_set_min_bytes() function Date: Mon, 17 Oct 2022 11:13:35 -0700 Message-Id: <20221017181337.3884657-13-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=1666030605; 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=Fn53sXB0tYzghzXcq7eiufnYR5imF4AEMK7yuCoLRzk=; b=VTq3KblHsrotnH+2I47HufOb7TCIrk7yj0TOKQH28xmM/X/wepyMBJ4wCkxZFFc4peU77u mpkTyKDE8sm8JQML+f5nkjxXLYTYG0K4A1TSZ+ChaUCRhHfXSAiL9ucKk9pKvBkCpz34fb fpB8E4030S3h3U0sUR+XG/oQ1fYckx4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=neutral (imf29.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=1666030605; a=rsa-sha256; cv=none; b=pSXzY4LLUUf+mWLNSmxmajnj9lRATLLXlBspk1GPBLqgF16NLoiQ/eT1O2sfOjXV/mjpdm Zjgpi5j0eq4kaU10cDDFv400ejTL2JC71hW6AjvoB6Mil89dwn6+P2YzJ2Iz/hYcT37OS9 Cvaik7UsBvXL2/zxipHp65mRYmwL40M= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 54F3012003F X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=none; spf=neutral (imf29.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: 5pxwpkwu9xhfajfkmqdwe7khpg64w9ic X-HE-Tag: 1666030605-101869 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 introduces the bdi_set_min_bytes() function. The min_bytes function does not store the min_bytes value. Instead it converts the min_bytes value into the corresponding ratio value. 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 621329f25bbe..659e9cb8c643 100644 --- a/include/linux/backing-dev.h +++ b/include/linux/backing-dev.h @@ -109,6 +109,7 @@ unsigned long long bdi_get_min_bytes(struct backing_dev_info *bdi); unsigned long long bdi_get_max_bytes(struct backing_dev_info *bdi); 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_min_bytes(struct backing_dev_info *bdi, unsigned long long min_bytes); int bdi_set_max_bytes(struct backing_dev_info *bdi, unsigned long long max_bytes); int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7733dcf96d7e..04c4a142098b 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -750,6 +750,21 @@ unsigned long long bdi_get_min_bytes(struct backing_dev_info *bdi) } EXPORT_SYMBOL_GPL(bdi_get_min_bytes); +int bdi_set_min_bytes(struct backing_dev_info *bdi, unsigned long long min_bytes) +{ + int ret; + unsigned long pages = min_bytes >> PAGE_SHIFT; + unsigned long min_ratio; + + ret = bdi_check_pages_limit(pages); + if (ret) + return ret; + + min_ratio = bdi_ratio_from_pages(pages); + return __bdi_set_min_ratio(bdi, min_ratio); +} +EXPORT_SYMBOL_GPL(bdi_set_min_bytes); + unsigned long long bdi_get_max_bytes(struct backing_dev_info *bdi) { return bdi_get_bytes(bdi->max_ratio);