From patchwork Tue Sep 13 17:44:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975087 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 5ED57C6FA82 for ; Tue, 13 Sep 2022 17:45:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81DB980015; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 780A480011; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AA4D80015; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 41F5D80014 for ; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1F71B1A03A0 for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) X-FDA: 79907788296.30.D8EEDAB Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf20.hostedemail.com (Postfix) with ESMTP id 94E781C00BD for ; Tue, 13 Sep 2022 17:45:07 +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 ams.source.kernel.org (Postfix) with ESMTPS id 7B4FCB81098; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8063C4314B; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091105; bh=qZmiFc1Nc82ylFf2RlnRQAmg5LcM9WJjL5ftMxpc9Tk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BB374hfZv4lK06Nj4HgDd75pbYfHPfeFxPQ3Xjt/cz2hsv/aWWPi+WTgisy1XCo1g pjg2H6jqjFT4AOYIOmVse24brY8ClPTPcIQwlN8UwP+19TilWDubDQSho9kqu4E8Pu GMvpdtW9cKXgQqp2mcz7axPBiGT/Rk365rLZhsCkfQuVLu/+BlcKFMGe5MZtIRF4NW OxwoHMlnk9xXSAhE/vStWlWrwr4HOqsl8MUTZ+vX375YF7UtWc6v00HgsPB+mnumGH ViI3StyG6zLvY9d3ivDvJfY04ME++3mtJXZIIu2j9RR5H3Ptivgx8IqdWU9Do9Bjv3 NCY1EzCxzmVag== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/22] mm/damon/reclaim: use stat parameters generator Date: Tue, 13 Sep 2022 17:44:43 +0000 Message-Id: <20220913174449.50645-17-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-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BB374hfZ; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 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=1663091107; a=rsa-sha256; cv=none; b=TARcIzzOsqEdkRIPmXf0vTsKxzwYAtQ53VeJI05FypdeSb9+1S607H4yQtyvFRpU54LGf5 XNKLPpnlqdrRNXKA0n75srL/CyLFa65zguj/izY5OmYFxvcxqAjYE8aBWAYnh4Qr2oAoNi EbTSwrJGBCJN77YRpuqhsGnicovQSng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091107; 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=a5gNwwe8G4hYkWQuAF0BTiCkTEEnkUrlC8kWdicyhPI=; b=wKYU5Nce/GaZ0+XB2LRdqaUxP2dfmdwfGELnC4AR66aK5/FOsiOcjPubipUa3RKny7kJNn 9EDkFCoGlazTt0um6gGW0Cz3OlhZyogof/cfc+QkwC45aP07wNLQNG6SpTf7DVZJfqgkvT qcjNUZH60zgQ5M7fWBgynQYdPfHqCkQ= Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BB374hfZ; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Queue-Id: 94E781C00BD X-Rspamd-Server: rspam04 X-Stat-Signature: h7aujk9tpnd6gz7njbnzn7qrm8b3f3nw X-HE-Tag: 1663091107-104561 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_RECLAIM to generate the module parameters for DAMOS statistics using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 7f845f617dc5..1ef8353ac15a 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -136,35 +136,9 @@ module_param(monitor_region_end, ulong, 0600); static int kdamond_pid __read_mostly = -1; module_param(kdamond_pid, int, 0400); -/* - * Number of memory regions that tried to be reclaimed. - */ -static unsigned long nr_reclaim_tried_regions __read_mostly; -module_param(nr_reclaim_tried_regions, ulong, 0400); - -/* - * Total bytes of memory regions that tried to be reclaimed. - */ -static unsigned long bytes_reclaim_tried_regions __read_mostly; -module_param(bytes_reclaim_tried_regions, ulong, 0400); - -/* - * Number of memory regions that successfully be reclaimed. - */ -static unsigned long nr_reclaimed_regions __read_mostly; -module_param(nr_reclaimed_regions, ulong, 0400); - -/* - * Total bytes of memory regions that successfully be reclaimed. - */ -static unsigned long bytes_reclaimed_regions __read_mostly; -module_param(bytes_reclaimed_regions, ulong, 0400); - -/* - * Number of times that the time/space quota limits have exceeded - */ -static unsigned long nr_quota_exceeds __read_mostly; -module_param(nr_quota_exceeds, ulong, 0400); +static struct damos_stat damon_reclaim_stat; +DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_reclaim_stat, + reclaim_tried_regions, reclaimed_regions, quota_exceeds); static struct damon_ctx *ctx; static struct damon_target *target; @@ -318,13 +292,8 @@ static int damon_reclaim_after_aggregation(struct damon_ctx *c) struct damos *s; /* update the stats parameter */ - damon_for_each_scheme(s, c) { - nr_reclaim_tried_regions = s->stat.nr_tried; - bytes_reclaim_tried_regions = s->stat.sz_tried; - nr_reclaimed_regions = s->stat.nr_applied; - bytes_reclaimed_regions = s->stat.sz_applied; - nr_quota_exceeds = s->stat.qt_exceeds; - } + damon_for_each_scheme(s, c) + damon_reclaim_stat = s->stat; return damon_reclaim_handle_commit_inputs(); }