Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6977750rwn; Tue, 13 Sep 2022 11:47:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR6v4C9044LZATW+aR6OFXWuZEmiIGsRtxj33Sxt9vTiSqffTNElIuGI6t8C9VJ8IQv5kMug X-Received: by 2002:a17:907:1c08:b0:77c:8d2:bb9 with SMTP id nc8-20020a1709071c0800b0077c08d20bb9mr10388343ejc.177.1663094852210; Tue, 13 Sep 2022 11:47:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663094852; cv=none; d=google.com; s=arc-20160816; b=pv61ReCn93tjRO+ceALClBbQKEFu+sG8Aj1C2v+3TKFng1pKRg3v63EqmgnDs6WEAO FPqEI+c+kaWI6yHlF4iNXXBG9BiqMMQGAt+fGclBdJL1HBvZNq4NzxMef5v4vK4lRGNm NL9hZnsyMVZFt+MQtw6fCoD09Hci5ryZDT41y4QnI9vM9XFcPg1Q24KApYdAGV4hoNzx i9J/NV9STvcGwotkOFeV6db9bfFlljgA7J+O8e/A4zARK4IQfmwIGE7QJzROv8AlKRwh 7jcOFMUT4E6hjzif4MOmCP6LcpG+IWl005QBs8qp1gw7HayjhcZ6j2lR7i7dGBN4ejgF +Wig== 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=YuQ8Cnkkp1VtdKNj68whNwXLXfGR+OZ+4C0+Gm8loII=; b=hCLqF3UbMod5ReWk7hVMX1Mwb55K5xL1PIMZPeAsOud+WSDbY+zgXDbfzCWZY4J89u qUc7OOwjmlytYnyviLLOeqMxu7/YJxHj+HAEHnR5PVnw4goXcfIcUJUmqi9/BTfpjT/9 LdYmCrywDwqpZ1ov9kOzlrIitr/0tGkwrzRbbyTU8SJqDrgT3QQn4fh4iZgAt8zm1AK9 901vNPDGD0IpCx5QMJzT1e1UusPpgVVNXwiigEdX/+RTIOYpTO3NckFpQxLivdQqXWDf i3MF4OriM6akvr4Q5cICo1ESNYSYRrCL7OYqmoIS38mffGD23sVZLC49fLrL37yBc8Y7 p8XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rNWe89E2; 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 ga32-20020a1709070c2000b00730a4424a40si2931435ejc.160.2022.09.13.11.47.06; Tue, 13 Sep 2022 11:47:32 -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=rNWe89E2; 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 S232573AbiIMS1r (ORCPT + 99 others); Tue, 13 Sep 2022 14:27:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232211AbiIMS0w (ORCPT ); Tue, 13 Sep 2022 14:26:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C6545FAE7 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 0CB756154D for ; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 797F2C43144; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091099; bh=weWy/2YvUWIofhX6Yg4PxkLbauvFc1P8+Pog3c5HCQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNWe89E2W4HG4Qc4c5ym3tC6m8DqT09MtflLX5NQn2wKg99VI2QxGhRhr1dGRcNtB yCkIWEvTXjvuIEgtgIeuN5D+7ejYSNd1T1nM9ISx0Y7Mf8BpzMtWFJzxUHgotwZ1GF eC53jZPOZvrnVL6UE10nsoX8Vm/R6zMn435XDwdHYO/WCljc2omiMuCADFWLZKnTCp oM5R6qmKYlTOZ+4h63qyc2v4afrw5GYHOA4urdD28HAOZisRSPjJ31oosApurqCj9F v7h6fVDLGvANvAowyLhgNI/h1MZG9dahfv+8+2eTQ06+I2V2GsOH73fxM5BrdR2KFM opUKzr6qZHerA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/22] mm/damon/reclaim: use 'struct damon_attrs' for storing parameters for it Date: Tue, 13 Sep 2022 17:44:34 +0000 Message-Id: <20220913174449.50645-8-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_RECLAIM receives monitoring attributes by parameters one by one to separate variables, and then combine 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/reclaim.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index bc841efbab45..d35a00d8dde2 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -129,14 +129,22 @@ module_param(wmarks_mid, ulong, 0600); static unsigned long wmarks_low __read_mostly = 200; module_param(wmarks_low, ulong, 0600); +static struct damon_attrs damon_reclaim_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 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_reclaim_mon_attrs.sample_interval, + ulong, 0600); /* * Aggregation interval for the monitoring in microseconds. @@ -144,8 +152,8 @@ module_param(sample_interval, ulong, 0600); * The aggregation interval of DAMON for the 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_reclaim_mon_attrs.aggr_interval, ulong, + 0600); /* * Minimum number of monitoring regions. @@ -155,8 +163,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_reclaim_mon_attrs.min_nr_regions, + ulong, 0600); /* * Maximum number of monitoring regions. @@ -166,8 +174,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_reclaim_mon_attrs.max_nr_regions, + ulong, 0600); /* * Start of the target memory region in physical address. @@ -239,7 +247,8 @@ static struct damos *damon_reclaim_new_scheme(void) .min_nr_accesses = 0, .max_nr_accesses = 0, /* for min_age or more micro-seconds */ - .min_age_region = min_age / aggr_interval, + .min_age_region = min_age / + damon_reclaim_mon_attrs.aggr_interval, .max_age_region = UINT_MAX, }; struct damos_watermarks wmarks = { @@ -275,18 +284,11 @@ static struct damos *damon_reclaim_new_scheme(void) static int damon_reclaim_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; int err = 0; - err = damon_set_attrs(ctx, &attrs); + err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs); if (err) return err; -- 2.25.1