From nobody Mon Apr 6 00:12:15 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56BC7ECAAD8 for ; Tue, 13 Sep 2022 18:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231742AbiIMS2y (ORCPT ); Tue, 13 Sep 2022 14:28:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231546AbiIMS1U (ORCPT ); Tue, 13 Sep 2022 14:27:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 884056D54A for ; Tue, 13 Sep 2022 10:45:11 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 67D73B81095 for ; Tue, 13 Sep 2022 17:45:09 +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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D 120000000; module_param(cold_min_age, ulong, 0600); =20 -/* - * 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 us= ed - * 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 =3D 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 milliseco= nds. - * - * 1 second by default. - */ -static unsigned long quota_reset_interval_ms __read_mostly =3D 1000; -module_param(quota_reset_interval_ms, ulong, 0600); +static struct damos_quota damon_lru_sort_quota =3D { + /* Use up to 10 ms per 1 sec, by default */ + .ms =3D 10, + .sz =3D 0, + .reset_interval =3D 1000, + /* Within the quota, mark hotter regions accessed first. */ + .weight_sz =3D 0, + .weight_nr_accesses =3D 1, + .weight_age =3D 0, +}; +DEFINE_DAMON_MODULES_DAMOS_TIME_QUOTA(damon_lru_sort_quota); =20 struct damos_watermarks damon_lru_sort_wmarks =3D { .metric =3D DAMOS_WMARK_FREE_MEM_RATE, @@ -162,19 +149,10 @@ static struct damos *damon_lru_sort_new_hot_scheme(un= signed int hot_thres) .min_age_region =3D 0, .max_age_region =3D UINT_MAX, }; - struct damos_quota quota =3D { - /* - * Do not try LRU-lists sorting of hot pages for more than half - * of quota_ms milliseconds within quota_reset_interval_ms. - */ - .ms =3D quota_ms / 2, - .sz =3D 0, - .reset_interval =3D quota_reset_interval_ms, - /* Within the quota, mark hotter regions accessed first. */ - .weight_sz =3D 0, - .weight_nr_accesses =3D 1, - .weight_age =3D 0, - }; + struct damos_quota quota =3D damon_lru_sort_quota; + + /* Use half of total quota for hot pages sorting */ + quota.ms =3D quota.ms / 2; =20 return damon_new_scheme( &pattern, @@ -200,20 +178,10 @@ static struct damos *damon_lru_sort_new_cold_scheme(u= nsigned int cold_thres) .min_age_region =3D cold_thres, .max_age_region =3D UINT_MAX, }; - struct damos_quota quota =3D { - /* - * Do not try LRU-lists sorting of cold pages for more than - * half of quota_ms milliseconds within - * quota_reset_interval_ms. - */ - .ms =3D quota_ms / 2, - .sz =3D 0, - .reset_interval =3D quota_reset_interval_ms, - /* Within the quota, mark colder regions not accessed first. */ - .weight_sz =3D 0, - .weight_nr_accesses =3D 0, - .weight_age =3D 1, - }; + struct damos_quota quota =3D damon_lru_sort_quota; + + /* Use half of total quota for cold pages sorting */ + quota.ms =3D quota.ms / 2; =20 return damon_new_scheme( &pattern, --=20 2.25.1