From patchwork Tue Sep 13 17:44:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975090 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 2E458C6FA8A for ; Tue, 13 Sep 2022 17:45:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED35080017; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E837C80014; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C886A80017; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B4C7A80014 for ; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 93F961202EC for ; Tue, 13 Sep 2022 17:45:09 +0000 (UTC) X-FDA: 79907788338.05.6B36D81 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id 06B36400A1 for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 53D5561548; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF9C5C4347C; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091108; bh=vDKNHhOgxvXdmTbnCpBFmnMIFqpdFy3QEkyiK51v7wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e0yD8AsuLcJY/gdEyZtKUR8q1Ts7XNhquj3lx0IpkCYiMXfHclxM34eS35xvz5mGh fkuMV0nRyR0ro+vFojhppd4ac+A71wrZJNunIKAb5DtvrNoKoDnH6zOCHz6tmFkbmK 3QsXvf5zG2B6yuDePFY3HZ6FDO/KlfqqjANqTebR/1yB+9XeztxD5Hthie3KR0QJNX oR4tOs2/ML/GJ4AKnMgp+nZfnQBn0bDVsunxi2qkG5CHaItsMPVwFvj62tHHPZJhuz y/1ytxtrSdHS19LaXn3XYOkYz6YMzbI6S06WFBSegLR4f6HdEb2eqeVVQE9WXnjsfh 0qImovxL20cRA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/22] mm/damon/lru_sort: use quotas param generator Date: Tue, 13 Sep 2022 17:44:48 +0000 Message-Id: <20220913174449.50645-22-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091109; 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:dkim-signature; bh=lApDtzBL/tG0DmUFUQYBHzJZu+t2IgX4OJEEx1kwFTE=; b=2GPnholQmYkTjnMvfLCRiftcYywk/WX8Zao5HFch9TC06KUVyvRT1T6ATDwlJKnRHu7Vsc +eBSXPHB325DF3vOkWUJcsbRP1iS6Q/SLVLSw8Baa+/hlxI1LfvksWrLXERCGMPdsUui1R eXz7ebadmDbsHR1JcC3ty9yAsQvbOjM= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=e0yD8Asu; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091109; a=rsa-sha256; cv=none; b=SZh9sQ+U37MMiGGeI8CHs9hwKu3hUfIF4u1b3839EPVpH0noKaP04OTr74D+iNI3FXcNjV Ow6DbKLpc/fx38I0Pj7NCUxXdCQV6Tk3YeoiZVkOFg8/NDeFInTArAvzV3z0tw/M4DaT+g R0YZjo+G8RQcYbJUwqziOEOPUcH8yj8= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 06B36400A1 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=e0yD8Asu; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: k7snq8wg7t9u1bs5nzdh1sywjcyaf4qu X-Rspam-User: X-HE-Tag: 1663091108-366170 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 commit makes DAMON_LRU_SORT to generate the module parameters for DAMOS watermarks using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 70 ++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 51 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 13a752aed272..8d9c3d1fd6be 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -65,30 +65,17 @@ module_param(hot_thres_access_freq, ulong, 0600); static unsigned long cold_min_age __read_mostly = 120000000; module_param(cold_min_age, ulong, 0600); -/* - * Limit of time for trying the LRU lists sorting in milliseconds. - * - * DAMON_LRU_SORT tries to use only up to this time within a time window - * (quota_reset_interval_ms) for trying LRU lists sorting. This can be used - * for limiting CPU consumption of DAMON_LRU_SORT. If the value is zero, the - * limit is disabled. - * - * 10 ms by default. - */ -static unsigned long quota_ms __read_mostly = 10; -module_param(quota_ms, ulong, 0600); - -/* - * The time quota charge reset interval in milliseconds. - * - * The charge reset interval for the quota of time (quota_ms). That is, - * DAMON_LRU_SORT does not try LRU-lists sorting for more than quota_ms - * milliseconds or quota_sz bytes within quota_reset_interval_ms milliseconds. - * - * 1 second by default. - */ -static unsigned long quota_reset_interval_ms __read_mostly = 1000; -module_param(quota_reset_interval_ms, ulong, 0600); +static struct damos_quota damon_lru_sort_quota = { + /* Use up to 10 ms per 1 sec, by default */ + .ms = 10, + .sz = 0, + .reset_interval = 1000, + /* Within the quota, mark hotter regions accessed first. */ + .weight_sz = 0, + .weight_nr_accesses = 1, + .weight_age = 0, +}; +DEFINE_DAMON_MODULES_DAMOS_TIME_QUOTA(damon_lru_sort_quota); struct damos_watermarks damon_lru_sort_wmarks = { .metric = DAMOS_WMARK_FREE_MEM_RATE, @@ -162,19 +149,10 @@ static struct damos *damon_lru_sort_new_hot_scheme(unsigned int hot_thres) .min_age_region = 0, .max_age_region = UINT_MAX, }; - struct damos_quota quota = { - /* - * Do not try LRU-lists sorting of hot pages for more than half - * of quota_ms milliseconds within quota_reset_interval_ms. - */ - .ms = quota_ms / 2, - .sz = 0, - .reset_interval = quota_reset_interval_ms, - /* Within the quota, mark hotter regions accessed first. */ - .weight_sz = 0, - .weight_nr_accesses = 1, - .weight_age = 0, - }; + struct damos_quota quota = damon_lru_sort_quota; + + /* Use half of total quota for hot pages sorting */ + quota.ms = quota.ms / 2; return damon_new_scheme( &pattern, @@ -200,20 +178,10 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres) .min_age_region = cold_thres, .max_age_region = UINT_MAX, }; - struct damos_quota quota = { - /* - * Do not try LRU-lists sorting of cold pages for more than - * half of quota_ms milliseconds within - * quota_reset_interval_ms. - */ - .ms = quota_ms / 2, - .sz = 0, - .reset_interval = quota_reset_interval_ms, - /* Within the quota, mark colder regions not accessed first. */ - .weight_sz = 0, - .weight_nr_accesses = 0, - .weight_age = 1, - }; + struct damos_quota quota = damon_lru_sort_quota; + + /* Use half of total quota for cold pages sorting */ + quota.ms = quota.ms / 2; return damon_new_scheme( &pattern,