From patchwork Mon Oct 24 19:06:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 13017994 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 0F278C38A2D for ; Mon, 24 Oct 2022 19:06:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EB98940016; Mon, 24 Oct 2022 15:06:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B062940015; Mon, 24 Oct 2022 15:06:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA09D940014; Mon, 24 Oct 2022 15:06:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D2E9594000C for ; Mon, 24 Oct 2022 15:06:43 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B5857804E1 for ; Mon, 24 Oct 2022 19:06:43 +0000 (UTC) X-FDA: 80056774686.29.CFDE443 Received: from 66-220-144-178.mail-mxout.facebook.com (66-220-144-178.mail-mxout.facebook.com [66.220.144.178]) by imf21.hostedemail.com (Postfix) with ESMTP id 5045C1C0006 for ; Mon, 24 Oct 2022 19:06:43 +0000 (UTC) Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id 8D48A3ED5920; 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 12/14] mm: add bdi_set_min_bytes() function Date: Mon, 24 Oct 2022 12:06:01 -0700 Message-Id: <20221024190603.3987969-13-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-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=neutral (imf21.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=1666638403; a=rsa-sha256; cv=none; b=bKo5fUMFUoDRnttX6HW3sEGq69J0MsP/cYmzBW0mnFcZca7e1PDNqSVL4F3SKcamTKRYox HwfgzhX1sOMRbX+Y0xYCywH0+GMVyIiRCODvTzb2Jtye3LqMpoqs3kOulBiOO2488YLfmZ VHvpYpqkhhC8tcRKa3EFEQJWgpmHA24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666638403; 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=6OUODX1nNAq8swH8yL3uScYOJodGqULvOeQGrmp/VBM=; b=EktAg6/4OKs9rDMR4AvuS5/eFL7vDGMHcnS9lu6JjcqcRtHa4iW+s4ipyZH2PmUShN9s/v gA+jyN0qRrTYG+pd5H8W0BFqYeSMe4+n6ZDIvmKOgaoTOu1ewb8c87yXP82uhBwwLn4J8B iIuaFqfMNgZa+zOaEmvcXfEpuu3EnLk= X-Rspamd-Queue-Id: 5045C1C0006 Authentication-Results: imf21.hostedemail.com; dkim=none; spf=neutral (imf21.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: tc1kjcopdazfzea1baqraswrx194qpdh X-HE-Tag: 1666638403-371907 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 07f59ed60d4a..ca6cbf8e63bb 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -751,6 +751,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);