From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796090736; b=4uECUiBycANroVNeOtgv/Fd6R0Eg36/tCrpVpAM/PeLZBXvU5wpmfKJdOh+A0LjuFpka pOMWXubJHmS6yESzrigtribfF9FeGIQYD061TdvSuNYGKSpSxmPI6ckMNHptuIxxjt4Gt 0hm3gq/6MQzNMR96xwueHz51MPaenTaKQZJD+S6tPsD25AJ+PbuITiuQacXtkUvyFiGP6 BBn2ATelJTSzZ9bhsgJlPJ4EjkjLScQhfXLftRYQBHbVHMbkxCW0Ov5zvhuwMJWwJwCtT KeaUhWzDOWLUySZGUxEcdQyIXSdfRZaCvRE2T7OVsk1ufD1AB8sX3epOw1AcvUxFZFg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796090736; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=T/OZNGnuBrNjghBVWKIIpKJdOtocCGPK6aRSKnYk8qE=; b=D6M2EPjQeDETo84CbOgdNHJcM5tAECp6agCsgMgclUBiosgC7izIV9rYhFEuiJcsOrYw wKLefjFuSWsEumgq02t3HfsLCbrGlj5VxO/uXxLqNPyheAIx8H1fcmzss+91QRzcCLWq6 cenyCGNByhvKDKh/9g7JpT5YFhRW/3hR/lifjwL8UV8rPA+dkGSzQCPKxCLF2dkM3Uz3W TeMn+if3QJqeF1wmf3SaDWIFTI0I+qAnn2pCiycDUQmPFojZ0rgL0Dc0dvbwah6UTk3uu nJ2O8QXjF2ljRWB3+P+rNUbBnSIi5NM0qTr0f9mjtAdefhNtIf94bxtsu3rlJ17wKQw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VlFAYj+n; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67501606A31A for ; Tue, 1 Dec 2026 02:05:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VlFAYj+n Received: by smtp.kernel.org (Postfix) with ESMTPSA id B47D11F000C1; Tue, 1 Dec 2026 02:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796090735; bh=T/OZNGnuBrNjghBVWKIIpKJdOtocCGPK6aRSKnYk8qE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VlFAYj+nnr8u3aywbegBJP8oGSjw46jQwXQSfm7AekZi81IUDaIF6a+D5Qo5p1rl9 La0bLsuQala9W9i1mFEARDVsq0dCapY2f2AXXQ4ENyssprTIoUoDSG7QI1jscJKSDW rHuYiYa4xLR+P0HZXJDD+lirFOtb2IISFpafKN+Soy9H5ZIewvSnc5QScaOuXp4FVY PtnA3LB5YVSLI23jELrDJKToaBOfcqT3I7GIsbtNj5U+hBtCdEigCq5xj7Emt8uFnt 5KnylFzUWYnZKo7spMBE5+BC3Cj5bq/cOvhWO6DxqIOXlrTAQ2XK3YaS94ZBsOYu9C M808trnTQRQRg== From: SJ Park To: Arijit Desai via B4 Relay Cc: SJ Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, Arijit Desai Subject: Re: [PATCH] mm/damon/reclaim: use age_ms filter for min_age Date: Mon, 30 Nov 2026 18:05:28 -0800 Message-ID: <20261201020528.120881-1-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130-damon-reclaim-age-ms-v1-1-595659163211@crusoe.ai> References: X-Mailing-List: damon@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi Arijit, On Mon, 30 Nov 2026 21:53:45 +0000 Arijit Desai via B4 Relay wrote: > From: Arijit Desai > > DAMON_RECLAIM converts its min_age parameter (in microseconds) into > DAMOS min_age_region, which is in aggregation intervals, once when the > parameters are applied. When autotune_monitoring_intervals is enabled, > the conversion uses the initial 100 ms aggregation interval, but the > auto-tuning soon grows the interval. The region age threshold therefore > stays at the same number of aggregation intervals while each interval > becomes much longer. For the default min_age of 120 seconds, the > threshold becomes 1,200 aggregation intervals, which is about 2.5 hours > once the aggregation interval grows to about 7.5 seconds. As a result, > DAMON_RECLAIM reclaims almost nothing in that setup. > > Use a DAMOS_FILTER_TYPE_AGE_MS filter that rejects regions younger than > min_age instead, and set min_age_region to zero. The filter compares > the region age converted with the current aggregation interval, so it > stays correct while the intervals change. For fixed intervals, the > behavior is unchanged. Regions rejected by the filter are not charged > to the quota and do not count as tried regions. > > Keep accepting any min_age, as before. If min_age is smaller than a > millisecond, add no filter, so every region is old enough. > > Tested on a 16 vCPU / 62 GiB VM with a cold anonymous buffer plus 1 GiB > of hot anonymous memory, autotune_monitoring_intervals=Y, min_age=120 s > and watermarks forced active: > > kernel cold buffer 10 min result > unpatched 8 GiB no region tried, nothing paged out > unpatched 48 GiB no region tried, nothing paged out > patched 48 GiB nothing paged out before 181 s, then > steady pageout (~1 GiB swapped out by > 600 s, limited by the time quota) > > The same age_ms filter based min_age was also tested with a DAMOS > pageout scheme set up via the DAMON sysfs interface, on a vLLM CPU > inference workload (3B model, 32 concurrent users, intervals > auto-tuning, min_age 120 s, 4 runs per setup). Compared to no DAMON, > it reduced the vLLM worker's resident memory by about 1.8 GiB (of > 18.4 GiB), at a cost of 0.2% output throughput and 0.3% inter-token > latency. With the classic LRU instead of MGLRU, it reduced 1.55 GiB at > 0.1% throughput and 0.1% latency cost. The same scheme with min_age > converted to aggregation intervals once, as DAMON_RECLAIM does now, > reduced only 0.06 GiB. > > The DAMON kunit tests pass. > > An AI coding assistant (Claude Code) helped write this patch and the > changelog, and ran the tests above. I reviewed the change and the > test results. I think the above two paragraphs are better to be put in the commentary area. > > Link: https://lore.kernel.org/20261121015324.83753-1-sj@kernel.org When you add a link, it would be nice to add a context. I understand this is the initial issue sharing. Maybe the commit message can be updated like, : As a result, DAMON_RECLAIM reclaims almost nothing [1] in that setup. : [...] : [1] https://lore.kernel.org/20261121015324.83753-1-sj@kernel.org > Signed-off-by: Arijit Desai > --- > mm/damon/reclaim.c | 25 +++++++++++++++++++++---- > 1 file changed, 21 insertions(+), 4 deletions(-) > > diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c > index a84cea070..f46822656 100644 > --- a/mm/damon/reclaim.c > +++ b/mm/damon/reclaim.c > @@ -164,7 +164,7 @@ DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_reclaim_stat, > static struct damon_ctx *ctx; > static struct damon_target *target; > > -static struct damos *damon_reclaim_new_scheme(unsigned long aggr_interval) > +static struct damos *damon_reclaim_new_scheme(void) > { > struct damos_access_pattern pattern = { > /* Find regions having PAGE_SIZE or larger size */ > @@ -173,8 +173,8 @@ static struct damos *damon_reclaim_new_scheme(unsigned long aggr_interval) > /* and not accessed at all */ > .min_nr_accesses = 0, > .max_nr_accesses = 0, > - /* for min_age or more micro-seconds */ > - .min_age_region = min_age / aggr_interval, > + /* min_age is applied via a DAMOS_FILTER_TYPE_AGE_MS filter */ > + .min_age_region = 0, > .max_age_region = UINT_MAX, > }; > > @@ -227,7 +227,7 @@ static int damon_reclaim_apply_parameters(void) > goto out; > > err = -ENOMEM; > - scheme = damon_reclaim_new_scheme(attrs.aggr_interval); > + scheme = damon_reclaim_new_scheme(); > if (!scheme) > goto out; > damon_set_schemes(param_ctx, &scheme, 1); > @@ -249,6 +249,23 @@ static int damon_reclaim_apply_parameters(void) > damos_add_quota_goal(&scheme->quota, goal); > } > > + /* > + * Reject regions younger than min_age. Use an age_ms filter rather > + * than min_age_region, because the latter is in aggregation intervals > + * and becomes wrong once intervals auto-tuning changes the aggregation > + * interval. Keep the old behavior of accepting any min_age; values > + * smaller than a millisecond make every region old enough. > + */ I think the above comment is too much detail. I believe the code is self-explaining what it does. I'd suggest removing the comment. > + if (min_age >= USEC_PER_MSEC) { > + filter = damos_new_filter(DAMOS_FILTER_TYPE_AGE_MS, true, > + false); > + if (!filter) > + goto out; > + filter->range_min = 0; > + filter->range_max = min_age / USEC_PER_MSEC - 1; > + damos_add_filter(scheme, filter); > + } > + I'd prefer having allow filter always, since it feels simpler to me. Not a blocker for this patch, though. Other than the above trivial nits for commit message and comments, Reviewed-by: SJ Park Assuming you agree to my above comments for commit message and comments, I modified this patch as I suggested, and applied to damon/next [2] tree. Please let me know if you disagree to any of the comments. I will repost it soon (~1 week) as an mm.git merge request. So, no action from your side is needed for now. [1] https://docs.kernel.org/process/submitting-patches.html#commentary [2] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees Thanks, SJ [...]