From patchwork Tue Sep 13 17:44:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975088 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 AB353C54EE9 for ; Tue, 13 Sep 2022 17:45:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B056180011; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6CFC80016; 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 66D4B80014; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2F50580011 for ; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0D7F7AB40E for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) X-FDA: 79907788254.08.7F3952A Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf26.hostedemail.com (Postfix) with ESMTP id 2F5391400C8 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 1DB14B810A6; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E1C5C43140; Tue, 13 Sep 2022 17:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091104; bh=gmkQIvgsS3o7E0kw20g1nY/rU6PdiC7nZb5s3NkPL2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JylOBtODAgJiw9eaH6HLYcsFje7zpwtzLk/brt56MBMuN1KWnaiYrbiYtAN8ohXAf H4FiJjzVDV9FJfQlLvtBh2KXVkd4dluSslzGUFFR1fVlIo7XxNIoyWkIh1YygmOmXq 9uLhAtMYgy3CTVSuP/dQ7AAxkK3KIf7W1kzmceKmDKQqop0PB8YP+PdWdax9AddBO3 W/saUg7P7HTcjQSK3Em4AF6VR+lNWj38CPeNLXAkiI/iRt9woF23okgQsmUtvP5po2 kXtnKUsX38Zfvj2Ha45qqMl7F7+4E8uDA9rh9EHWgNRXcwKUGTphaGaR6+epC4LcWi XsXwjjqBnjxJw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/22] mm/damon/reclaim: use watermarks parameters generator macro Date: Tue, 13 Sep 2022 17:44:41 +0000 Message-Id: <20220913174449.50645-15-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091107; a=rsa-sha256; cv=none; b=S9zUqxtLzJu7LQAYYRZHLYMDWC/DeuUYgHpanZEjMEftquLKoMBAfCJSPaR/NvA5CkuTPZ vzr6tXa8jV5qzvSm/AcMWO8ycd8WUzMs0nW/z/LMSabg+cfsR8HfT+WzS2JuKAKed5fghp +NcpmX26WIhsnPDp+jH9k51s9ykat08= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JylOBtOD; spf=pass (imf26.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-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=WG0dt6ApzB7DPVNdL+jZsVJe3Ipmy7V7dyeNpqVKydA=; b=kDYwJlcRzylJqDLpWGP6NKSIIh1GUoATlFplO9wgw7TZs4gP3K1FR8sR5XHvfJY1eSDVD7 sy0+y+zjXGgZSHGEmmc4EVBnQuEsAm444hfHz5z05wpasfQA6dB5M8E5NGloujOtiNa8A0 wYr1PthQ1cDnw3hpE7ucxoLIbZMtmBw= X-Stat-Signature: 357xzut1jpw983t6sheoy4fc6wupa4yh X-Rspamd-Queue-Id: 2F5391400C8 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JylOBtOD; spf=pass (imf26.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-Server: rspam11 X-HE-Tag: 1663091107-294613 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 watermarks using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 56 ++++++++-------------------------------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 48326bef20f5..7f845f617dc5 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -91,45 +91,14 @@ module_param(quota_sz, ulong, 0600); static unsigned long quota_reset_interval_ms __read_mostly = 1000; module_param(quota_reset_interval_ms, ulong, 0600); -/* - * The watermarks check time interval in microseconds. - * - * Minimal time to wait before checking the watermarks, when DAMON_RECLAIM is - * enabled but inactive due to its watermarks rule. 5 seconds by default. - */ -static unsigned long wmarks_interval __read_mostly = 5000000; -module_param(wmarks_interval, ulong, 0600); - -/* - * Free memory rate (per thousand) for the high watermark. - * - * If free memory of the system in bytes per thousand bytes is higher than - * this, DAMON_RECLAIM becomes inactive, so it does nothing but periodically - * checks the watermarks. 500 (50%) by default. - */ -static unsigned long wmarks_high __read_mostly = 500; -module_param(wmarks_high, ulong, 0600); - -/* - * Free memory rate (per thousand) for the middle watermark. - * - * If free memory of the system in bytes per thousand bytes is between this and - * the low watermark, DAMON_RECLAIM becomes active, so starts the monitoring - * and the reclaiming. 400 (40%) by default. - */ -static unsigned long wmarks_mid __read_mostly = 400; -module_param(wmarks_mid, ulong, 0600); - -/* - * Free memory rate (per thousand) for the low watermark. - * - * If free memory of the system in bytes per thousand bytes is lower than this, - * DAMON_RECLAIM becomes inactive, so it does nothing but periodically checks - * the watermarks. In the case, the system falls back to the LRU-based page - * granularity reclamation logic. 200 (20%) by default. - */ -static unsigned long wmarks_low __read_mostly = 200; -module_param(wmarks_low, ulong, 0600); +struct damos_watermarks damon_reclaim_wmarks = { + .metric = DAMOS_WMARK_FREE_MEM_RATE, + .interval = 5000000, /* 5 seconds */ + .high = 500, /* 50 percent */ + .mid = 400, /* 40 percent */ + .low = 200, /* 20 percent */ +}; +DEFINE_DAMON_MODULES_WMARKS_PARAMS(damon_reclaim_wmarks); static struct damon_attrs damon_reclaim_mon_attrs = { .sample_interval = 5000, /* 5 ms */ @@ -214,13 +183,6 @@ static struct damos *damon_reclaim_new_scheme(void) damon_reclaim_mon_attrs.aggr_interval, .max_age_region = UINT_MAX, }; - struct damos_watermarks wmarks = { - .metric = DAMOS_WMARK_FREE_MEM_RATE, - .interval = wmarks_interval, - .high = wmarks_high, - .mid = wmarks_mid, - .low = wmarks_low, - }; struct damos_quota quota = { /* * Do not try reclamation for more than quota_ms milliseconds @@ -242,7 +204,7 @@ static struct damos *damon_reclaim_new_scheme(void) /* under the quota. */ "a, /* (De)activate this according to the watermarks. */ - &wmarks); + &damon_reclaim_wmarks); } static int damon_reclaim_apply_parameters(void)