From nobody Sat Feb 7 15:09:53 2026 Received: from mail-dl1-f65.google.com (mail-dl1-f65.google.com [74.125.82.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 891AC366816 for ; Thu, 29 Jan 2026 21:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769723902; cv=none; b=I4t7iHYJAJqmbFYsCJTFv+TIKsM//rKvGIvL3txbo8mL0n677qmupi4SkKm4F1XeZx7eiTlvVQU49kKdp/rhajUokI+FqSjeXbDoWpKmlLzUcbQpV+NZaoc7B5nMM7k0seotcXYODjnHCl73hmPs5P2+GIQxJOb0DdTV0OzJnew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769723902; c=relaxed/simple; bh=E2PzmQBsrkUQlUCjGwf4xR0qYrrxe/5JAZuNmStoFY4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bDynhCVgPxeNWJ5GHByAzB+G7ZqydJCQcQZUZxTWgTuxLriDKqt5Mg5TBvhfZjxA1heb2bCR0k0UUjDKJJ9Ci7NwaYX0rOHWWk6QNwEhg3eG/CGaH+a32lILLAdZm6boLTzhxZCpxZMNGbTGnF2SJHJP3kZ8XKOtgMmFboSf21s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EYnDmlqw; arc=none smtp.client-ip=74.125.82.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EYnDmlqw" Received: by mail-dl1-f65.google.com with SMTP id a92af1059eb24-1233c155a42so2488129c88.1 for ; Thu, 29 Jan 2026 13:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769723901; x=1770328701; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JuNybkTlqvH+9m8T0FgwqGQF2N52zzKrzPQ6MtpsUMY=; b=EYnDmlqw1d61nLN0ymqNCon1i7a6Ca9sH9gdzOC+SQA5VMW+RHtLi3AFqzC2F0BkYG KQUvGTHYP0um0Z60ZucCcbBXFpbjeDV40yU+0Dz0MUGk/WEn5IgTaBzjxL3VAKbEiPgI tjmeDqff6I4ybIDhlAwJrLqZJBzK1HrybzEflJcBq1mhNNtS5+iET3mMkLK6toAAwlNy iYFlsAdy0WPYGtdjy8JE8j+Imp4L3wBiOZ8kl/6SQGdneMvZftcng7hN9DDLUMYjVP6Q 1ViXRDG3t7zV8eMJ6dCHp0VGcUhdnKBGcDvNqf3y3RpFpCXuUyUO8DKmII9RnIe6bI7r gdnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769723901; x=1770328701; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JuNybkTlqvH+9m8T0FgwqGQF2N52zzKrzPQ6MtpsUMY=; b=K+oYkKdgyEENZn1XEa90nN4wTyBph3uQNy0RJxhQL4k2XcV7YSQFAGF7jwDZs1T+W/ 0P3YlAUXFdnM+N0byH1FTDkz2M9C0AQTRCGh+WQjefF9POWxtL4U1WQgL5jqKCuPrA3Y gf/v7U6omDFFk9tAsf3QJhOtexgzRaDKBwLcMwPGud9jPgJlmyUQ5jNSJB5INce5E77m UShjfJ+/QI24jCfkqu5CzE0Xq4odd4pJOvMCfCnrlY0K7tBQVIhSiWU7jWMMpvEGqK0d HGPzyTqZ4J5kqx8a4QMfjiJ6sSKEJJhJaiYfojhyYEeNL00gjKTM11AX+NbSSyplFVuJ MYNg== X-Forwarded-Encrypted: i=1; AJvYcCUIBgwL+z3iUND37GOF3eeDvnb+CcRBxggBcSdhkqWwS55zEvHo1AnyHG7M89bpJ76zwGjpAVuNn5VWRu4=@vger.kernel.org X-Gm-Message-State: AOJu0YwkENjogqi7vw9Yt0kS0jend76QuOVzbaI0WcFevKS4g3BB+zdw Wha0tfCh8YXcsyE2xJWwp/u1vR7dKdqB9Rce94SRXxMAlkifozqwEY0= X-Gm-Gg: AZuq6aKYgW8ejFyLcb5yCJ/57DpVorNaTcLIhb3fBUK0zWqEQyHXWkJL+Zoa5cSLOl1 cHQio98Ef6da335UD6HKXt95qkoIxHd7Y2QbjWIzJoqdmJDI5IhLKJho3QUil9Z+GzK04F/Kkyy pifzO7geG3EkdWCGVvHEqeJbm4J3QksAI0L4p+DeDPYwUp70Jk2F5ZbxXBt57R7S0CNIrKbtIuA gy+OrOogVIbtBFEJBHiKA3w1GZl/W3f2VIlHNo+4xc5XN9AX4VErICGV1V4rtUjwWCy/bRgOrfC hTYpoq+THYOTSoAe7VM0xSNIdBNboEWXOuQnUQjHIu/siVSWuZQRbW2hF98LmqXYVPZdpJlHu1f KTP9cPT/t52R0JR3r6uiJ5GMM6gxOnRBBMsDEN/flCujH04jFRQG0G6JS6lLRUablcFmPItEhp0 42AUWfqCiwbQ== X-Received: by 2002:a05:7300:6404:b0:2b0:4c12:d74d with SMTP id 5a478bee46e88-2b7c865541fmr553751eec.15.1769723900641; Thu, 29 Jan 2026 13:58:20 -0800 (PST) Received: from localhost ([137.201.204.52]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b7a16cf8d6sm8585570eec.3.2026.01.29.13.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 13:58:20 -0800 (PST) From: Ravi Jonnalagadda To: sj@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: akpm@linux-foundation.org, corbet@lwn.net, bijan311@gmail.com, ajayjoshi@micron.com, honggyu.kim@sk.com, yunjeong.mun@sk.com, Ravi Jonnalagadda Subject: [PATCH 1/3] mm/damon/core: add DAMOS_QUOTA_NODE_TARGET_MEM_BP metric Date: Thu, 29 Jan 2026 13:58:12 -0800 Message-ID: <20260129215814.1618-2-ravis.opensrc@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260129215814.1618-1-ravis.opensrc@gmail.com> References: <20260129215814.1618-1-ravis.opensrc@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a new quota goal metric DAMOS_QUOTA_NODE_TARGET_MEM_BP for physical address space-based DAMON operation schemes. This metric represents the ratio of scheme-eligible memory on a specific NUMA node to that node's total capacity, expressed in basis points (1/10000). The metric enables auto-tuning of DAMOS quotas based on how much memory on a node matches the scheme's access pattern criteria, which is essential for controlling memory migration in heterogeneous memory systems (e.g., DRAM and CXL memory tiering). Suggested-by: SeongJae Park Signed-off-by: Ravi Jonnalagadda --- include/linux/damon.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 3813373a9200..5eebb8aaab85 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -155,6 +155,7 @@ enum damos_action { * @DAMOS_QUOTA_NODE_MEM_FREE_BP: MemFree ratio of a node. * @DAMOS_QUOTA_NODE_MEMCG_USED_BP: MemUsed ratio of a node for a cgroup. * @DAMOS_QUOTA_NODE_MEMCG_FREE_BP: MemFree ratio of a node for a cgroup. + * @DAMOS_QUOTA_NODE_TARGET_MEM_BP: Scheme-eligible memory ratio of a node. * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. * * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupport= ed. @@ -166,6 +167,7 @@ enum damos_quota_goal_metric { DAMOS_QUOTA_NODE_MEM_FREE_BP, DAMOS_QUOTA_NODE_MEMCG_USED_BP, DAMOS_QUOTA_NODE_MEMCG_FREE_BP, + DAMOS_QUOTA_NODE_TARGET_MEM_BP, NR_DAMOS_QUOTA_GOAL_METRICS, }; =20 @@ -193,6 +195,9 @@ enum damos_quota_goal_metric { * * If @metric is DAMOS_QUOTA_NODE_MEMCG_{USED,FREE}_BP, @nid and @memcg_id * represents the node id and the cgroup to account the used memory for. + * + * If @metric is DAMOS_QUOTA_NODE_TARGET_MEM_BP, @nid represents the node + * to measure scheme-eligible memory ratio against its capacity. */ struct damos_quota_goal { enum damos_quota_goal_metric metric; --=20 2.43.0 From nobody Sat Feb 7 15:09:53 2026 Received: from mail-dy1-f195.google.com (mail-dy1-f195.google.com [74.125.82.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F150367F46 for ; Thu, 29 Jan 2026 21:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769723904; cv=none; b=Rcrar8X78FWvRoJ1wJ6EnD/Ivq4emAvsxXMyNwwaQFy2DiCWsVKyyv4Kw8KjeWtP51oWLsG+EEPIx37l6wDQgXMmrhZ6L8G3ajaMUJCcDaeH827Wf3rgf4P2nchWSr5vaysK0vuYkl7YHGKZXtTCa7mOZf9HLOKFIsrGxq2AskA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769723904; c=relaxed/simple; bh=Lz87npd8Ymj4dgzZ8guZFLbK7FQeXfTehjSY3ldIw48=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UKgjMe6xzh7KCkr9KuBc9txRVYwPOubavvof5oCWgNzw+rncwSPEdv/jh8vgXCWX6rdXXcMi+79S08vwaGWIKzPu5n6827qmf6l0WFhnli3Xa1GmFlTLpr8cpXEnSm0/6YnSK+vhcycD72M5/E3Ej9zLKZ9FBQXRa0Zm1+WE2rk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bp0qT+ak; arc=none smtp.client-ip=74.125.82.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bp0qT+ak" Received: by mail-dy1-f195.google.com with SMTP id 5a478bee46e88-2b720bb90d0so1565102eec.0 for ; Thu, 29 Jan 2026 13:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769723902; x=1770328702; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0za+mTabqTtCcABlRwV4DBkxWsk326LNSJGiU0z1JGs=; b=bp0qT+ak9ggjTSkgp8Jx848Fkj4cRlVNy5tNIMFmBmUhIeiBjzk/uBTjcj7W4tJp6x Hiss37TRpQHA6RpF/3+c2km77qef9KRCezf8CJtNJpEUdjuKumqOFOeQkXu4xEkzHJAW E75bisoEpmDPHRFCqeOopMYcZaTeKWGJ94rq2pSoQFEkzpJFaI8SVMds3WzfjXiEoQBp mfCzWiwL377CSv6cltJ/NZtMRXL5y+I9DFuO1qdazAcRrFjvOARAmc1M1l+fauSq0tTX thAh/4Ciygz9zjBJg4RdCgT6OS0hrHSEu/1l2yTbBxmTZWPO4wRUVwNwEd1Ttxi7tVZR W1kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769723902; x=1770328702; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0za+mTabqTtCcABlRwV4DBkxWsk326LNSJGiU0z1JGs=; b=RBB7/lJEL3A+g8m5mhr7ekA3UmslQUR3EEsi13/sRGo3tEjngZauJUVg8pI9npTLIp Ch5SQYwCFhWlxGueFJ+k6Q3nW7Dglfw457dZ0/I0F1j+GfSILlFKG8Jur+2d6I9Zlf10 e7AFPzBR1OwqZkwR+S76ES3+l7FeLAgVtIWVjY1zjjBwXKNZ8RL30WKLe10he3pJv+jS X8ZVDwgAzOKPk00VnXWf6mBP6fYBHYx4B63L57IhcCIBSTcHZaI4CImmqVcAJJ13rMgX EqJHMW5xC6tftrKkTOOmZ3Scko6zcgdHbNMSZLcZQbzx9Bp229tuQqh7vqaPJF1lz5As vNQQ== X-Forwarded-Encrypted: i=1; AJvYcCVUmXJjMQ1qnnJQA/qbwsWv5R4JG3KrKvAYu76DKOrArRCKwdkMdGGPNVsOg3DHT2D0CVaXDfdiJpIA3fY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/juuGsDqiyjD7W6zPmyNY3TFhRfNf7nNppkjt1mE1gCE1bjer 8XqoyGViRKolXrT7fgGcqBdwBZz+aZrW0QGVf/B/GtMhUpcypqTMFxo= X-Gm-Gg: AZuq6aLhQvCjVbAi+nCJFZBizPeZ+4HOy97PyFPln4UFQCZpRnmvjmBZNqSaH6WnsSB MN4irs5SFbGRZ5iMf9UTLoMki8qVdR3eml9lwK8GU+RYl3u6jjF4km3FaC2nroE7juzHcGfUV8u xRmEMb0fMX4X0u2mLaTneXa0+VExuUxsXyBuc/2kh84Xo7MyVxBDWfO7sjqvnJGR5xinSTfkwvf RBPNGV8ZV5u5tgOCFL+D0stSQs46r33WITvBSwIqm7L7yCD2gjJyXCu/MdFzb2AEtaDi0UVcfZT f2/zBgiO/a9tqM1Xyio1aN2WogBoT4X50qDyupgBasDNf+RT0hUKbeHDbWT5so2SAQgjbbHb241 jM2iuupwpH/gHpl2Z2liabnFiIzxaznJDP/pYwpexhvoJfNDsoSAxvbKUDUqvcABsCUYvFgy46T dc6oTdc1yGIw== X-Received: by 2002:a05:7300:bc05:b0:2ae:4f61:892e with SMTP id 5a478bee46e88-2b7c8903199mr438341eec.36.1769723902104; Thu, 29 Jan 2026 13:58:22 -0800 (PST) Received: from localhost ([137.201.204.52]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b7a16ec51csm8713746eec.10.2026.01.29.13.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 13:58:21 -0800 (PST) From: Ravi Jonnalagadda To: sj@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: akpm@linux-foundation.org, corbet@lwn.net, bijan311@gmail.com, ajayjoshi@micron.com, honggyu.kim@sk.com, yunjeong.mun@sk.com, Ravi Jonnalagadda Subject: [PATCH 2/3] mm/damon/core: implement NODE_TARGET_MEM_BP metric calculation Date: Thu, 29 Jan 2026 13:58:13 -0800 Message-ID: <20260129215814.1618-3-ravis.opensrc@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260129215814.1618-1-ravis.opensrc@gmail.com> References: <20260129215814.1618-1-ravis.opensrc@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add damos_get_node_target_mem_bp() function that calculates the ratio of scheme-eligible memory on a specific NUMA node to the total node capacity, expressed in basis points (bp, 1/10000). The function iterates through all regions that match the scheme's access pattern criteria (checked via __damos_valid_target) and counts how many pages from those regions reside on the specified node. This enables quota auto-tuning based on the actual distribution of hot/cold pages across NUMA nodes. To support this new metric which requires access to both the DAMON context and scheme: - Update damos_set_quota_goal_current_value() signature - Update damos_quota_score() to pass ctx and scheme through - Update damos_set_effective_quota() and its callers This metric is particularly useful for heterogeneous memory systems (e.g., DRAM + CXL) where controlling the distribution of hot pages across nodes can optimize memory bandwidth utilization. Suggested-by: SeongJae Park Signed-off-by: Ravi Jonnalagadda --- mm/damon/core.c | 66 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 84f80a20f233..1482c97828e8 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -2119,8 +2120,52 @@ static unsigned long damos_get_node_memcg_used_bp( } #endif =20 +static unsigned long damos_get_node_target_mem_bp( + struct damon_ctx *ctx, struct damos *scheme, + struct damos_quota_goal *goal) +{ + int nid =3D goal->nid; + unsigned long node_capacity, scheme_node_bytes =3D 0; + unsigned long addr_unit =3D ctx->addr_unit; + struct damon_target *t; + struct damon_region *r; + unsigned long start_pfn, end_pfn, pfn; + + /* Only supported for physical address space monitoring */ + if (ctx->ops.id !=3D DAMON_OPS_PADDR) + return 0; + + if (nid < 0 || nid >=3D MAX_NUMNODES || !node_online(nid)) + return 0; + + node_capacity =3D NODE_DATA(nid)->node_spanned_pages << PAGE_SHIFT; + if (!node_capacity) + return 0; + + damon_for_each_target(t, ctx) { + damon_for_each_region(r, t) { + if (!__damos_valid_target(r, scheme)) + continue; + + start_pfn =3D (phys_addr_t)r->ar.start * + addr_unit >> PAGE_SHIFT; + end_pfn =3D (phys_addr_t)r->ar.end * + addr_unit >> PAGE_SHIFT; + + for (pfn =3D start_pfn; pfn < end_pfn; pfn++) { + if (pfn_valid(pfn) && + page_to_nid(pfn_to_page(pfn)) =3D=3D nid) + scheme_node_bytes +=3D PAGE_SIZE; + } + } + } + + return mult_frac(scheme_node_bytes, 10000, node_capacity); +} =20 -static void damos_set_quota_goal_current_value(struct damos_quota_goal *go= al) +static void damos_set_quota_goal_current_value( + struct damon_ctx *ctx, struct damos *scheme, + struct damos_quota_goal *goal) { u64 now_psi_total; =20 @@ -2141,19 +2186,25 @@ static void damos_set_quota_goal_current_value(stru= ct damos_quota_goal *goal) case DAMOS_QUOTA_NODE_MEMCG_FREE_BP: goal->current_value =3D damos_get_node_memcg_used_bp(goal); break; + case DAMOS_QUOTA_NODE_TARGET_MEM_BP: + goal->current_value =3D damos_get_node_target_mem_bp( + ctx, scheme, goal); + break; default: break; } } =20 /* Return the highest score since it makes schemes least aggressive */ -static unsigned long damos_quota_score(struct damos_quota *quota) +static unsigned long damos_quota_score( + struct damon_ctx *ctx, struct damos *scheme, + struct damos_quota *quota) { struct damos_quota_goal *goal; unsigned long highest_score =3D 0; =20 damos_for_each_quota_goal(goal, quota) { - damos_set_quota_goal_current_value(goal); + damos_set_quota_goal_current_value(ctx, scheme, goal); highest_score =3D max(highest_score, goal->current_value * 10000 / goal->target_value); @@ -2165,7 +2216,8 @@ static unsigned long damos_quota_score(struct damos_q= uota *quota) /* * Called only if quota->ms, or quota->sz are set, or quota->goals is not = empty */ -static void damos_set_effective_quota(struct damos_quota *quota) +static void damos_set_effective_quota(struct damon_ctx *ctx, + struct damos *scheme, struct damos_quota *quota) { unsigned long throughput; unsigned long esz =3D ULONG_MAX; @@ -2176,7 +2228,7 @@ static void damos_set_effective_quota(struct damos_qu= ota *quota) } =20 if (!list_empty("a->goals)) { - unsigned long score =3D damos_quota_score(quota); + unsigned long score =3D damos_quota_score(ctx, scheme, quota); =20 quota->esz_bp =3D damon_feed_loop_next_input( max(quota->esz_bp, 10000UL), @@ -2227,7 +2279,7 @@ static void damos_adjust_quota(struct damon_ctx *c, s= truct damos *s) /* First charge window */ if (!quota->total_charged_sz && !quota->charged_from) { quota->charged_from =3D jiffies; - damos_set_effective_quota(quota); + damos_set_effective_quota(c, s, quota); } =20 /* New charge window starts */ @@ -2240,7 +2292,7 @@ static void damos_adjust_quota(struct damon_ctx *c, s= truct damos *s) quota->charged_sz =3D 0; if (trace_damos_esz_enabled()) cached_esz =3D quota->esz; - damos_set_effective_quota(quota); + damos_set_effective_quota(c, s, quota); if (trace_damos_esz_enabled() && quota->esz !=3D cached_esz) damos_trace_esz(c, s, quota); } --=20 2.43.0 From nobody Sat Feb 7 15:09:53 2026 Received: from mail-dy1-f193.google.com (mail-dy1-f193.google.com [74.125.82.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71055367F4A for ; Thu, 29 Jan 2026 21:58:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769723906; cv=none; b=HDVOo+yWFqc+5uPplQHToAuHgkHreQ6OURGBeeROiaD59vP4CzZO4XHc6dLtL5XxTfsBdenQY6ibcz4honM/zaWsJhweaJLUqNDmOJbeiO1/xtqK+VVf3G0rH+0OW1ko9kf/CPbx5oroQSxY/Y97/axpPeq0fdRL9eZA7AVH9wY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769723906; c=relaxed/simple; bh=MmVKleijncFNV3VTWlVTPh9Yt+NHsjAHFsJeZAvuy5g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jplPoMIO4DrGS7AZQ2JnC+MWIlKMzCk3cHwF8ZBXKMK7cuwONXj4rl+LWaJ1vXW7mWseRn1ZUQyMM8d60XlXMqzhMQk5ThWExSw/97DcjbKkjAbQZAYPB9l1Bd3+mjRDAgTAt3HFb3373PiJSrHsFb+kl82x5Efn6rMLE2qRRB0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=S1EyKUdm; arc=none smtp.client-ip=74.125.82.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S1EyKUdm" Received: by mail-dy1-f193.google.com with SMTP id 5a478bee46e88-2b720bb90d0so1565116eec.0 for ; Thu, 29 Jan 2026 13:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769723904; x=1770328704; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nmNgqwiRPaM50yoR4bSwou2vHJzKZmxQW0OFYL7FLjQ=; b=S1EyKUdmk+gJvCtyvML8FSLY+7zEcHBFLJ4KyUjUU0wz/PmIL2ju5Mo0Lz6NG5eTk1 GHQEPGFaSTNmH/xUq/ybEU0AQMtrLGPLdG9698i8XDPB1+3YCDqf7z+//oU0FQvrhElH RZwMV5+kNQTA1HuqRWIhpcoMF/ooMDQ+FdG534GDzO1WWFnKywBB0FRbfnrM8AqhVqIv AtVCOmkYG+nNacYAifD7yQYJ7VnpfaT/+x+HuwEukfBQrEDBW3PjusYF4zultxDBWtTd CRnfE80oUyEOi9sFmsw0kRj8+0RPX0HtG18sYXuAnGYnQn3vX+hR8jX44e8Csuxvzv9i uQhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769723904; x=1770328704; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=nmNgqwiRPaM50yoR4bSwou2vHJzKZmxQW0OFYL7FLjQ=; b=Kos2+7sstEJdAw5jjT+0uHr8t4NofEzmDmbSp09zjTFqp4Nt2XP7L5+pBqjNTAnAUr JzLguBHZDBN1or1vtgbJ7GZrGFzz7FBZhMwmHKR2BpjVoWh5yd7FtcIRBXI9uqJn4Zib PSWTIP8kLen4NhQb5VztT0w0f2FHoAmZQSZxDiVEOMlS7fSXajdz/zh0DFejDHJpMh8S AOPjPzi9OkES+XHGm3Orx3dC169adLkMaPfhaMPMkUg0t+6ZYl16NroV353x9rag89Hk JIa3/0OiBhynGPYMYVlEH+qsyJXIHyFkasj+s6zZVe2PsVVPqs6zuY26iPeEORZEIIG2 /hEQ== X-Forwarded-Encrypted: i=1; AJvYcCVj+REskL8MJzRnyjcBooNZCVUPOtzQ3kH6DeZqoyfQ2VFchn+UXw5ykdmECCHpnZ/tEgi1rxJ7hIidZYs=@vger.kernel.org X-Gm-Message-State: AOJu0YwbBSpg6qc/hGNOEJlFmziZwAQptWcp+uL3WIev6QFWTmZdK9bB 047wXYGGWbVHHbyfKempGHJYT0qR+NblzQgrBM3al5bF56l0B6xWQy4= X-Gm-Gg: AZuq6aJTFbPA7dIuRW3TorUtij6Moi3kujbUtZ1DTukTeAhU6b0enktv+t+JKYc/3di U/+gjUN/Ui79BkrwSA0QqfZdsgxv/HTue47QO+bHozyH+ueEJo1QMoZCx5CFm4521m5hwbFHky8 YCvr7P9ydPBIc0RiEnkvebo8DPiWYngVw8fL6rScR3YPvqWNirdUH0op1x3sdT+nnhHUI+5Y25W jP4TAUqcdNl8Qv44WzDxPoa1lR9KdF+E4twc64ZZ35Cc9bMpm5AXa2zGpb02Ahws5i00gRDHf7E jSeMus3k8P50hjMG79e4rWCAFScQ/0zocfE/DUnc5wmNf0N4Lw1OB4WQjgcX0nm4ZUIV4Si6nKw j+ghkfTQIKMe9HwXAo6tlnYx8HaHSj7lz1swRTYllUSz32YwD+AFAyiNfWS03eoFLcnLwBgV6CP bgrDYIzg9F+w== X-Received: by 2002:a05:7300:a984:b0:2ac:21b5:f43c with SMTP id 5a478bee46e88-2b7c86db7e2mr415692eec.20.1769723903529; Thu, 29 Jan 2026 13:58:23 -0800 (PST) Received: from localhost ([137.201.204.52]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b7a16cf8f2sm9659960eec.7.2026.01.29.13.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 13:58:23 -0800 (PST) From: Ravi Jonnalagadda To: sj@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: akpm@linux-foundation.org, corbet@lwn.net, bijan311@gmail.com, ajayjoshi@micron.com, honggyu.kim@sk.com, yunjeong.mun@sk.com, Ravi Jonnalagadda Subject: [PATCH 3/3] mm/damon/sysfs-schemes: expose NODE_TARGET_MEM_BP metric Date: Thu, 29 Jan 2026 13:58:14 -0800 Message-ID: <20260129215814.1618-4-ravis.opensrc@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260129215814.1618-1-ravis.opensrc@gmail.com> References: <20260129215814.1618-1-ravis.opensrc@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add sysfs support for the new NODE_TARGET_MEM_BP quota goal metric. This exposes the metric as 'node_target_mem_bp' under the quota goal's target_metric attribute. The metric measures the ratio of scheme-eligible memory (regions matching the scheme's access pattern) on a specified NUMA node to the node's total capacity, expressed in basis points (bp, 1/10000). Users can configure this metric by: 1. Setting target_metric to 'node_target_mem_bp' 2. Setting nid to the target NUMA node 3. Setting target_value to the desired ratio in basis points The current_value attribute shows the measured ratio, which can be used by userspace to compute the actual bytes of scheme-eligible memory on the node: bytes =3D current_value * node_capacity / 10000. This is particularly useful for tiered memory systems to monitor and control the distribution of hot pages across NUMA nodes. Suggested-by: SeongJae Park Signed-off-by: Ravi Jonnalagadda --- mm/damon/sysfs-schemes.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 3a699dcd5a7f..50133263c592 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1038,6 +1038,10 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgo= al_metric_names[] =3D { .metric =3D DAMOS_QUOTA_NODE_MEMCG_FREE_BP, .name =3D "node_memcg_free_bp", }, + { + .metric =3D DAMOS_QUOTA_NODE_TARGET_MEM_BP, + .name =3D "node_target_mem_bp", + }, }; =20 static ssize_t target_metric_show(struct kobject *kobj, @@ -2554,6 +2558,7 @@ static int damos_sysfs_add_quota_score( break; case DAMOS_QUOTA_NODE_MEM_USED_BP: case DAMOS_QUOTA_NODE_MEM_FREE_BP: + case DAMOS_QUOTA_NODE_TARGET_MEM_BP: goal->nid =3D sysfs_goal->nid; break; case DAMOS_QUOTA_NODE_MEMCG_USED_BP: --=20 2.43.0