Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6976724rwn; Tue, 13 Sep 2022 11:46:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR7CqM5EFu8MZo/PniglYTQLEJQQyrBhsi9WXeITo8PrP3nsaTy0Ky5yxMPrxr1H57Gf2GUt X-Received: by 2002:a05:6402:2711:b0:451:327a:365f with SMTP id y17-20020a056402271100b00451327a365fmr15737464edd.315.1663094782143; Tue, 13 Sep 2022 11:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663094782; cv=none; d=google.com; s=arc-20160816; b=L5YUAoXsebtPd/yUOu4RXCxG21D+i2nFFSaoiHK5X2BrcjuVv0TIeDQGqPmk8itdp3 zONC5I/D6b62tBxuS5ZXQ/roUolOcCzN2HHDpYwqTx+0exzDS4Q84mZz2BAH3VCCescI QOQMMJ82m1T8CiSglpPsJs8Z30QhHM3cvTZoCMfwNDMe8fcHYnAZIyhXLPmJbJ66ULlY fDe/gVvDSC0zZHnUzOA/L5SPEAO/YVK10syROptegsCEa1xa/HZd9F0XvFYWM7DJsKiI +vEsI7DAztCLR5w/mCe9nWpAGChkibzr4tCXp0hCGewR7rc4muLXPqiFolqMFdf8285r YO7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t7JBb+K3jEvIcwHpEdWXJ+44A/poDYeWrDCpAE9FMUo=; b=mB1IBgpNUXLAlftSaMcylVJFV9/vdnCP8Y6h7BSpja26MFCLiYZcoHfrCrlsqQoq06 YOnb7CaLhW2IuWgV7MVcNYwU3FB/4xVCTMQ7RxMrcaKMPMnlFFFijtXcQGIsAywrS4oo E05t+rhZi8DqaJS84IQR9ynv/kIvkmjMB3tvW5pgh3zPKaz2gb4ErVMEP7iFKp/wjXbv DrSxOxbgLoJ1KKXxPelw1pLm0Cani5VJkYRK1t6KNYHOtUZuDaoVTM6CiJgKhyyWXVDR pJShMczhWACUN7FiLJr8+lQxC5d0mHghe+EM0yMNhis1Jl+JDcM5PL7Xt3D1YilMT/fI jwEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TzARBjc+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a056402350800b00451c7db4990si6390439edd.63.2022.09.13.11.45.55; Tue, 13 Sep 2022 11:46:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TzARBjc+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232761AbiIMS1u (ORCPT + 99 others); Tue, 13 Sep 2022 14:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbiIMS0x (ORCPT ); Tue, 13 Sep 2022 14:26:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D3525FF77 for ; Tue, 13 Sep 2022 10:45:01 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9FED161551 for ; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 165DDC433B5; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091100; bh=t9hexQZJ8425+LB2Nnk1GDKOCK+nsv8kErzuC6jdjaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TzARBjc+b2EGph+GmNC6Uuaf+rE6285m8cIpolJIwlcgLD4RYkhT8rjd/UNjWXNyX kL6NPs3+Mvkqla410Y6Wg9HpYE9Wz5TsIrtegel/6wmVc9yhuNSprDlUazn97gUQFQ 5+QNIpfdHLk8vCrrXanRAU9ng/6v36aJhiYXfNdmpWEtg/kwCBZ+5iNvL/mWFDD/9m 7QjA+mT+1iRHREfBbXvWwWxBlYQZ5TCgl62KKns7DjJkK/iGonvXbyEzfnq7EyO5ho Dnvy+93O6xEpLNnEasEnxiX1uuo0tpqchbKEd+5eSN2nOsX+wOsH2SKE+Yg7kgx+t8 9Hu065mtEuOPg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/22] mm/damon/lru_sort: use 'struct damon_attrs' for storing parameters for it Date: Tue, 13 Sep 2022 17:44:35 +0000 Message-Id: <20220913174449.50645-9-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: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DAMON_LRU_SORT receives monitoring attributes by parameters one by one to separate variables, and then combines those into 'struct damon_attrs'. This commit makes the module directly stores the parameter values to a static 'struct damon_attrs' variable and use it to simplify the code. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 6d5f83965276..ade985b83652 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -127,14 +127,22 @@ module_param(wmarks_mid, ulong, 0600); static unsigned long wmarks_low __read_mostly = 50; module_param(wmarks_low, ulong, 0600); +static struct damon_attrs damon_lru_sort_mon_attrs = { + .sample_interval = 5000, + .aggr_interval = 100000, + .ops_update_interval = 0, + .min_nr_regions = 10, + .max_nr_regions = 1000, +}; + /* * Sampling interval for the monitoring in microseconds. * * The sampling interval of DAMON for the hot/cold memory monitoring. Please * refer to the DAMON documentation for more detail. 5 ms by default. */ -static unsigned long sample_interval __read_mostly = 5000; -module_param(sample_interval, ulong, 0600); +module_param_named(sample_interval, damon_lru_sort_mon_attrs.sample_interval, + ulong, 0600); /* * Aggregation interval for the monitoring in microseconds. @@ -142,8 +150,8 @@ module_param(sample_interval, ulong, 0600); * The aggregation interval of DAMON for the hot/cold memory monitoring. * Please refer to the DAMON documentation for more detail. 100 ms by default. */ -static unsigned long aggr_interval __read_mostly = 100000; -module_param(aggr_interval, ulong, 0600); +module_param_named(aggr_interval, damon_lru_sort_mon_attrs.aggr_interval, ulong, + 0600); /* * Minimum number of monitoring regions. @@ -153,8 +161,8 @@ module_param(aggr_interval, ulong, 0600); * But, setting this too high could result in increased monitoring overhead. * Please refer to the DAMON documentation for more detail. 10 by default. */ -static unsigned long min_nr_regions __read_mostly = 10; -module_param(min_nr_regions, ulong, 0600); +module_param_named(min_nr_regions, damon_lru_sort_mon_attrs.min_nr_regions, + ulong, 0600); /* * Maximum number of monitoring regions. @@ -164,8 +172,8 @@ module_param(min_nr_regions, ulong, 0600); * However, setting this too low could result in bad monitoring quality. * Please refer to the DAMON documentation for more detail. 1000 by default. */ -static unsigned long max_nr_regions __read_mostly = 1000; -module_param(max_nr_regions, ulong, 0600); +module_param_named(max_nr_regions, damon_lru_sort_mon_attrs.max_nr_regions, + ulong, 0600); /* * Start of the target memory region in physical address. @@ -350,25 +358,19 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres) static int damon_lru_sort_apply_parameters(void) { - struct damon_attrs attrs = { - .sample_interval = sample_interval, - .aggr_interval = aggr_interval, - .ops_update_interval = 0, - .min_nr_regions = min_nr_regions, - .max_nr_regions = max_nr_regions, - }; struct damos *scheme; struct damon_addr_range addr_range; unsigned int hot_thres, cold_thres; int err = 0; - err = damon_set_attrs(ctx, &attrs); + err = damon_set_attrs(ctx, &damon_lru_sort_mon_attrs); if (err) return err; /* aggr_interval / sample_interval is the maximum nr_accesses */ - hot_thres = aggr_interval / sample_interval * hot_thres_access_freq / - 1000; + hot_thres = damon_lru_sort_mon_attrs.aggr_interval / + damon_lru_sort_mon_attrs.sample_interval * + hot_thres_access_freq / 1000; scheme = damon_lru_sort_new_hot_scheme(hot_thres); if (!scheme) return -ENOMEM; @@ -376,7 +378,7 @@ static int damon_lru_sort_apply_parameters(void) if (err) return err; - cold_thres = cold_min_age / aggr_interval; + cold_thres = cold_min_age / damon_lru_sort_mon_attrs.aggr_interval; scheme = damon_lru_sort_new_cold_scheme(cold_thres); if (!scheme) return -ENOMEM; -- 2.25.1