From nobody Fri Dec 19 10:34:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C918283C97; Thu, 9 Oct 2025 21:20:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044848; cv=none; b=pJX1U9/zP0VWarV+kuPzgOgx1nwYv/B5NI4uvf0I7R89O5bAWx+5KbR+ALbSaSugpvXju1PlHM49A4ilstqthGHb41hRH+yF49T/wFLxEwRxob2ZPDridzkTZXo/3oHr0RFX3OPdxWkEDFowCEn9Sen4hrWYhi+EjZlauhTtynQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044848; c=relaxed/simple; bh=w2pLgMeh4x2vtx8hkxpF0higLdemtjuZby1GC48TrEA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XgexVGSbTHZaHDGrK+rSQCNLcggpcVQ91vTYqzi6joF8XoUS0xck1nQMZsAFQEMQAhXLT0Y7zZuJ1gL/zkjWJjbKnE6yFk3g0rSfyzCMsULnZ718dIYvXgYa4iGMglp/2UsyKWowvftmPQATDloCmX6Fc3rsaVkWCHFyuGO52/w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AoE0x/Bc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AoE0x/Bc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEB76C4CEFE; Thu, 9 Oct 2025 21:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760044847; bh=w2pLgMeh4x2vtx8hkxpF0higLdemtjuZby1GC48TrEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AoE0x/BcAqmaV2Wgjw0N5gfW/vKHaPIWbzMAPPNOuwRHVJx+nfGi6F9/eOMbJrETc lOUGYD4jUkMYnd7r/uqczxMG5O0feC1chueyOngV2+s5nsbBO6UeA7I6Ea7oHviRe5 Zwswpw3JBw/w7ejFNRTDruikLC7I3+0NVCbbqRD0VegD2C1McfJDwVbxBtY6IAmfFp 0DIcIrFxGF2AQ6UJLmuZMHz4CJB362AvW6Y12Sl62UAvt18BjZwKeBkdCCe2xGHwse 3zZ9uxxCSH37afEwUd/j9HCdMUUWFSm2F+6lheSXl7SF6kPDuIYCxkW0AN30Nq7jqW EMw9vpuJaGmkg== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 01/10] mm/damon: document damos_quota_goal->nid use case Date: Thu, 9 Oct 2025 14:20:33 -0700 Message-Id: <20251009212042.60084-2-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251009212042.60084-1-sj@kernel.org> References: <20251009212042.60084-1-sj@kernel.org> 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" damos_quota_goal kerneldoc comment is not explaining when @metric is used. Update the comment for that. Signed-off-by: SeongJae Park --- include/linux/damon.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index cae8c613c5fc..dc9c310e0e75 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -176,6 +176,9 @@ enum damos_quota_goal_metric { * If @metric is DAMOS_QUOTA_USER_INPUT, @current_value should be manually * entered by the user, probably inside the kdamond callbacks. Otherwise, * DAMON sets @current_value with self-measured value of @metric. + * + * If @metric is DAMOS_QUOTA_NODE_MEM_{USED,FREE}_BP, @nid represents the = node + * id of the target node to account the used/free memory. */ struct damos_quota_goal { enum damos_quota_goal_metric metric; --=20 2.39.5 From nobody Fri Dec 19 10:34:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0301283FEA; Thu, 9 Oct 2025 21:20:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044849; cv=none; b=JhULQOXEIne3yNPzoHdSPO/UvxOKFnFODnDe2o0NVlXwK/0R2mdx798vvedEa6Uu3z6TNGJ9BcXYz/v+i1NEdnZH77PjEo2gZNn8qimnuidByBRRg6A8IPBdadljBrZg6wQV9Llk159Ht3dM+ck6oVYYx6a1FrXEJsmbS3CfNfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044849; c=relaxed/simple; bh=1CIUK+8rJXZdcUGVSAXbpo+NPkJ8Yup2LU3ew0CDXuY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=twe2g1Wtqrc5pCuN91BRnYhUGNetbh2wC7au0wymqih+0TS0m0X1QDcSRDRF7DbT1kMu4PFnlvFcrOz9DPJOJ9eYBhg281yQQkIaVpOUta8ozXPzVWnIwymSNTojhdqwJ3dgjUGGsCPDWB9FzzBn+Vn6GPH3qbFiaLs0u7ZPJL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jL5dvLdK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jL5dvLdK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AA3AC4CEFE; Thu, 9 Oct 2025 21:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760044849; bh=1CIUK+8rJXZdcUGVSAXbpo+NPkJ8Yup2LU3ew0CDXuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jL5dvLdKsBzT9ZGTax9IUxnfFckwub2guE+Nbf6VOC/LsoUruROAkfDj+3MR8hL5m hZ2Py91uHheq/rMel/lyVBEHxt1xtyAXm8I8Eqt2ADnbaDJRAWQ5EYC2GVM6htOu7D +a9gqXt2p8XoeUw8z1HRe5SX/ty/2+QhCDHM0KXYd52CSMR2bhMqKhcYeH1imoxcxJ MSvIarMhK7E2FXdGpm9dODpZNuOWu9RtIH/BHmZ0VqVjHU6ctsQnDsaT/EsONx9Obu nbhjh7DLcyxfqPOvw6HxFZaa8MZ3R4fGLG14NLHd9YfyuoLV9S4tMPV5H9aZf0+hIu msjumprO4kjUA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 02/10] mm/damon: add DAMOS quota goal type for per-memcg per-node memory usage Date: Thu, 9 Oct 2025 14:20:34 -0700 Message-Id: <20251009212042.60084-3-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251009212042.60084-1-sj@kernel.org> References: <20251009212042.60084-1-sj@kernel.org> 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" Define a new DAMOS quota auto-tuning target metric for per-cgroup per-node memory usage. For specifying the cgroup of the interest, add a field, namely memcg_id, to damos_quota_goal struct. Note that this commit is only implementing the interface. The handling of the interface (the metric value calculation) will be implemented in the following commit. Signed-off-by: SeongJae Park --- include/linux/damon.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index dc9c310e0e75..0d63ceb7e6ef 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -147,6 +147,7 @@ enum damos_action { * @DAMOS_QUOTA_SOME_MEM_PSI_US: System level some memory PSI in us. * @DAMOS_QUOTA_NODE_MEM_USED_BP: MemUsed ratio of a node. * @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. * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. * * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupport= ed. @@ -156,6 +157,7 @@ enum damos_quota_goal_metric { DAMOS_QUOTA_SOME_MEM_PSI_US, DAMOS_QUOTA_NODE_MEM_USED_BP, DAMOS_QUOTA_NODE_MEM_FREE_BP, + DAMOS_QUOTA_NODE_MEMCG_USED_BP, NR_DAMOS_QUOTA_GOAL_METRICS, }; =20 @@ -166,6 +168,7 @@ enum damos_quota_goal_metric { * @current_value: Current value of @metric. * @last_psi_total: Last measured total PSI * @nid: Node id. + * @memcg_id: Memcg id. * @list: List head for siblings. * * Data structure for getting the current score of the quota tuning goal. = The @@ -179,6 +182,9 @@ enum damos_quota_goal_metric { * * If @metric is DAMOS_QUOTA_NODE_MEM_{USED,FREE}_BP, @nid represents the = node * id of the target node to account the used/free memory. + * + * If @metric is DAMOS_QUOTA_NODE_MEMCG_USED_BP, @nid and @memcg_id repres= ents + * the node id and the cgroup to account the used memory for. */ struct damos_quota_goal { enum damos_quota_goal_metric metric; @@ -187,7 +193,10 @@ struct damos_quota_goal { /* metric-dependent fields */ union { u64 last_psi_total; - int nid; + struct { + int nid; + unsigned short memcg_id; + }; }; struct list_head list; }; --=20 2.39.5 From nobody Fri Dec 19 10:34:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBA402848BA; Thu, 9 Oct 2025 21:20:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044851; cv=none; b=WcQX5bTrokqZ6EN9gP5d45tGTuPnM+p0O+kyl+I6XGPyttIyodVpjg5c4mKDkNt6eHAoau1S4VC30EkCXeQfSf2/sv1AjRY5HpVhzlhzkg8Q5x48kh+AOS/i57WFdfHlUgu0ym+Czm77lamob2E+LB6WTFCveSmkuB5VPaRrNSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044851; c=relaxed/simple; bh=MELVaEdB76EUyKbmw0NbQ1QbyTF6YUPeLThLKL8ekdI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ayIWcSAU4e/yYOl9v0KM2aX+cwcA/pZX0aasmP4bipkH6EaafioAUPqjDr47smhGConBoTa1XHZVAaIsxjMIb24k4ZWUmPnsdLOb9nABXZymOSIPs3Euj+X3x0brebck7ARRCTd/hVsb/Kux6by5LxaYgz2SF59kWzRmBs6Zvnw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PZ2h/KzW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PZ2h/KzW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38DA5C4CEF5; Thu, 9 Oct 2025 21:20:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760044851; bh=MELVaEdB76EUyKbmw0NbQ1QbyTF6YUPeLThLKL8ekdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PZ2h/KzWkitVsziIxgaErvpPM9viuTpu0shAGsztfn/w1g7LyXyWlYKhhdz5QPSa7 qORE1jFoMNu7CtMBFlwtcu7CzXU4nc4FCaFs2xUBnclVOpdOb8AeIwe2mgJgPX7mha 197naWxHrdYB1uxa7Lr9cPe0bIUluaWJK0jU3rf+nHrwpUy/6SNlExHp1l6eiDwXQl Ujo30TV9LJPaaQ50xinRxP8TXoReG7+YYOrkXHcBZ8LuAdLGn2BvQdX0Tg4pGDvw+j 43W2tj0aAnNgMFp/Pqjc/nPdKoAAU9i78kGGVNzwIHUvI6bANiF5RSBLmd0WyR3IIO WMRnrlpDXHdGw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 03/10] mm/damon/core: implement DAMOS_QUOTA_NODE_MEMCG_USED_BP Date: Thu, 9 Oct 2025 14:20:35 -0700 Message-Id: <20251009212042.60084-4-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251009212042.60084-1-sj@kernel.org> References: <20251009212042.60084-1-sj@kernel.org> 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" Implement the handling of the new DAMOS quota goal metric for per-memcg per-node memory usage, namely DAMOS_QUOTA_NODE_MEMCG_USED_BP. The metric value is calculated as the sum of active/inactive anon/file pages of the given cgroup for a given NUMA node. Signed-off-by: SeongJae Park --- mm/damon/core.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index 93848b4c6944..1eacf78aa358 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -2032,12 +2033,46 @@ static __kernel_ulong_t damos_get_node_mem_bp( numerator =3D i.freeram; return numerator * 10000 / i.totalram; } + +static unsigned long damos_get_node_memcg_used_bp( + struct damos_quota_goal *goal) +{ + struct mem_cgroup *memcg; + struct lruvec *lruvec; + unsigned long used_pages; + struct sysinfo i; + + rcu_read_lock(); + memcg =3D mem_cgroup_from_id(goal->memcg_id); + rcu_read_unlock(); + if (!memcg) { + if (goal->metric =3D=3D DAMOS_QUOTA_NODE_MEMCG_USED_BP) + return 0; + else /* DAMOS_QUOTA_NODE_MEMCG_FREE_BP */ + return 10000; + } + mem_cgroup_flush_stats(memcg); + lruvec =3D mem_cgroup_lruvec(memcg, NODE_DATA(goal->nid)); + used_pages =3D lruvec_page_state(lruvec, NR_ACTIVE_ANON); + used_pages +=3D lruvec_page_state(lruvec, NR_INACTIVE_ANON); + used_pages +=3D lruvec_page_state(lruvec, NR_ACTIVE_FILE); + used_pages +=3D lruvec_page_state(lruvec, NR_INACTIVE_FILE); + + si_meminfo_node(&i, goal->nid); + return used_pages * 10000 / i.totalram; +} #else static __kernel_ulong_t damos_get_node_mem_bp( struct damos_quota_goal *goal) { return 0; } + +static unsigned long damos_get_node_memcg_used_bp( + struct damos_quota_goal *goal) +{ + return 0; +} #endif =20 =20 @@ -2058,6 +2093,9 @@ static void damos_set_quota_goal_current_value(struct= damos_quota_goal *goal) case DAMOS_QUOTA_NODE_MEM_FREE_BP: goal->current_value =3D damos_get_node_mem_bp(goal); break; + case DAMOS_QUOTA_NODE_MEMCG_USED_BP: + goal->current_value =3D damos_get_node_memcg_used_bp(goal); + break; default: break; } --=20 2.39.5 From nobody Fri Dec 19 10:34:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D870D2853EF; Thu, 9 Oct 2025 21:20:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044852; cv=none; b=kcLsCMo670SuLuqfwmBH4tY31l3IjRai8GY/lPQUh5D1LVrrPaWbNjCsz7K9uHLxW/x9fg8fIF7X1gTKa1epWDepsem0oEfhhN7jFm2o85cWRUjZfbAmVXjZyhkER88ennjmlPFiTi9P5FAoGH4VtuvPjQjx3kHJ7AoRbKnpMrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044852; c=relaxed/simple; bh=lWuxWajqY0wRfIc7Y8gXn7A3jSIMXiwp/Agt3iLR4VI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PXhMGnkS9AsaqT8DY8me4ozzfbPK4kLeLRaBVkUgST8heVT0FpNKqoBl9I+d0w9ea00+R2BtdCZKm6trnMdgm86Y69WAmnveUk6NJxjyMDy7xxo1Vy71FSUZFkxkU+xkXypg3gGzuyAoq3NDkj2FIgX/7IuVrn+2+Pasvi73I88= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F4s7+kv8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F4s7+kv8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5466AC116B1; Thu, 9 Oct 2025 21:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760044852; bh=lWuxWajqY0wRfIc7Y8gXn7A3jSIMXiwp/Agt3iLR4VI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F4s7+kv8TSItrEO/33Tty5z6jdTawVF4XjHqmKPEv748eygzP5rt46knLZjDqjSNq 9CjXV+5I0EkFy+mj/YSUJ1pMEdbw3hbijefv3pyYfmQ2lRT/mKomhuGb7keuaOLVnG gEZX/KgthWsRjb+91b3zKHQbCfi/3Z+rq1wwEmCZb2f/dMOjqwX8vDf8Lq7I1SbbBN nr3kHS+RcLRNnx95v/Uq15OAQrK34oPCVAAPCdsnFpRUvHo/M9KaLWDJa2i9skPz7H slvKE12ysSoF2MAoOeX3vv1bH4kFDtlw12H6lQkeoAUt6X4VN0ZPG5bXmSQfD0O83Y I7RyBduEJ9g2g== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 04/10] mm/damon/sysfs-schemes: implement path file under quota goal directory Date: Thu, 9 Oct 2025 14:20:36 -0700 Message-Id: <20251009212042.60084-5-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251009212042.60084-1-sj@kernel.org> References: <20251009212042.60084-1-sj@kernel.org> 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 DAMOS sysfs file for specifying the cgroup of the interest for DAMOS_QUOTA_NODE_MEMCG_USED_BP. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 6536f16006c9..2c440a2b80e6 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -999,6 +999,7 @@ struct damos_sysfs_quota_goal { unsigned long target_value; unsigned long current_value; int nid; + char *path; }; =20 static struct damos_sysfs_quota_goal *damos_sysfs_quota_goal_alloc(void) @@ -1128,10 +1129,39 @@ static ssize_t nid_store(struct kobject *kobj, return err ? err : count; } =20 +static ssize_t path_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damos_sysfs_quota_goal *goal =3D container_of(kobj, + struct damos_sysfs_quota_goal, kobj); + + return sysfs_emit(buf, "%s\n", goal->path ? goal->path : ""); +} + +static ssize_t path_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damos_sysfs_quota_goal *goal =3D container_of(kobj, + struct damos_sysfs_quota_goal, kobj); + char *path =3D kmalloc_array(size_add(count, 1), sizeof(*path), + GFP_KERNEL); + + if (!path) + return -ENOMEM; + + strscpy(path, buf, count + 1); + kfree(goal->path); + goal->path =3D path; + return count; +} + static void damos_sysfs_quota_goal_release(struct kobject *kobj) { - /* or, notify this release to the feed callback */ - kfree(container_of(kobj, struct damos_sysfs_quota_goal, kobj)); + struct damos_sysfs_quota_goal *goal =3D container_of(kobj, + struct damos_sysfs_quota_goal, kobj); + + kfree(goal->path); + kfree(goal); } =20 static struct kobj_attribute damos_sysfs_quota_goal_target_metric_attr =3D @@ -1146,11 +1176,15 @@ static struct kobj_attribute damos_sysfs_quota_goal= _current_value_attr =3D static struct kobj_attribute damos_sysfs_quota_goal_nid_attr =3D __ATTR_RW_MODE(nid, 0600); =20 +static struct kobj_attribute damos_sysfs_quota_goal_path_attr =3D + __ATTR_RW_MODE(path, 0600); + static struct attribute *damos_sysfs_quota_goal_attrs[] =3D { &damos_sysfs_quota_goal_target_metric_attr.attr, &damos_sysfs_quota_goal_target_value_attr.attr, &damos_sysfs_quota_goal_current_value_attr.attr, &damos_sysfs_quota_goal_nid_attr.attr, + &damos_sysfs_quota_goal_path_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damos_sysfs_quota_goal); --=20 2.39.5 From nobody Fri Dec 19 10:34:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C7C9285C9C; Thu, 9 Oct 2025 21:20:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044854; cv=none; b=AMIyIAWNg1bUPaqjUyUKZVQ/WKQK+hJ12n7B77Kg4bjxP5aetF5XSVzqMvl+DZzINeKVTgcqWsh9sbEwF0txhILk+hFMHu7hVvebALGELBcaKQTdhT0CGwqTPPbmxHKZn0YDEIZarQQBfTcWwfEcB4PpRlfJDaQdTTIl5f5pJ48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044854; c=relaxed/simple; bh=HTdQH6mS8J+MYD3Rj6pztEN9kH+IjfPCcbROi0+eWaY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i/p6XueHOU0LMtsA8BoApGwy+JDcFFdPfH0hyZtHnUtNbdC3M4kENgqPr7bJxq83PwFga/FWdrlfzldV6fC6TWGY08tYlyecOVbnmgkfXL5orh3acmLgmOAbkKUMBumrJzEq80B2qTYMIdkxt7w9DQI+6dx4iCCq7DOpmjCaOQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cwwztoHQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cwwztoHQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 678EAC116B1; Thu, 9 Oct 2025 21:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760044853; bh=HTdQH6mS8J+MYD3Rj6pztEN9kH+IjfPCcbROi0+eWaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cwwztoHQq0gOcUnJhit9e34YwWQL1uZxDEk3qMp3ncNP0zWYl+8aCxSBwwT/s171Y pN3DDPCQayfFcwVCLZc3jsdyFnVGQ1rLXDNPoTjBK/rquZ/pFLQw2UIuyTJnkhGfT+ CvuTkinu3pEdQkgy2C+GSfZ1qJNmJnNsuzakgsM9c8wAm6uilNyWneV5KX5L2KnDqc W8w6P8XPeQPCVFRjwQ8IRe1bQR8n1nxzY0IJrd64qV3I3QWafo2bCYYrxA/2l1xjEX bzPdq7GL3XSozfrTBGW3QRrCJX96184b+EKytuCv5b8BmevNQxMlA4Vtnsafcm5f9D iCC9XZQOc5dgQ== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 05/10] mm/damon/sysfs-schemes: support DAMOS_QUOTA_NODE_MEMCG_USED_BP Date: Thu, 9 Oct 2025 14:20:37 -0700 Message-Id: <20251009212042.60084-6-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251009212042.60084-1-sj@kernel.org> References: <20251009212042.60084-1-sj@kernel.org> 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 support of DAMOS_QUOTA_NODE_MEMCG_USED_BP. For this, extend quota goal metric inputs for the new metric, and update DAMOS core layer request construction logic to set the target cgroup, which is specified by the user, via the 'path' file. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 2c440a2b80e6..c679e62fd4b9 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1030,6 +1030,10 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgo= al_metric_names[] =3D { .metric =3D DAMOS_QUOTA_NODE_MEM_FREE_BP, .name =3D "node_mem_free_bp", }, + { + .metric =3D DAMOS_QUOTA_NODE_MEMCG_USED_BP, + .name =3D "node_memcg_used_bp", + }, }; =20 static ssize_t target_metric_show(struct kobject *kobj, @@ -2526,7 +2530,7 @@ static int damos_sysfs_add_quota_score( struct damos_quota *quota) { struct damos_quota_goal *goal; - int i; + int i, err; =20 for (i =3D 0; i < sysfs_goals->nr; i++) { struct damos_sysfs_quota_goal *sysfs_goal =3D @@ -2547,6 +2551,15 @@ static int damos_sysfs_add_quota_score( case DAMOS_QUOTA_NODE_MEM_FREE_BP: goal->nid =3D sysfs_goal->nid; break; + case DAMOS_QUOTA_NODE_MEMCG_USED_BP: + err =3D damon_sysfs_memcg_path_to_id( + sysfs_goal->path, &goal->memcg_id); + if (err) { + damos_destroy_quota_goal(goal); + return err; + } + goal->nid =3D sysfs_goal->nid; + break; default: break; } --=20 2.39.5 From nobody Fri Dec 19 10:34:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 308E72820DB; Thu, 9 Oct 2025 21:20:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044855; cv=none; b=Iia2RCGWJf3dg3qdnFRyZwGRy+8YdxM1KNM49EPTZfykcyP95GNfjbDxULvSDoiZ8q371BUrep67WNaAlfsZ85CHdKMz5KhHuUgKJ/0PinELPWIsVj2GM/n2MvJk4hkaMHqYIl9X+0PkXHcB4YoegsmuiF2kuHsxoqQuCxqUwa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044855; c=relaxed/simple; bh=CkhTLsuJMtU34HmXX0O02XR+nCAeXgrwHrAqstQf9yE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lFMTF+OsC1c09pO7egJn/aUAIeWToY4anh3cQv8TLnK0lwOcNUHjvDj5ajEB7oyKQlmO+SfKrtnlBeagTYlZhWuk2L256lheNHuU+zsxxtq0glCavq5J00rF0EkZuB9JrChuOB55Mwi2totzhBnuThOPCZ90bV7ENhQK+VRkG9U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JEVumExa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JEVumExa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8266DC113D0; Thu, 9 Oct 2025 21:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760044854; bh=CkhTLsuJMtU34HmXX0O02XR+nCAeXgrwHrAqstQf9yE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JEVumExa/JemdD+OCfcpdTleOjTbQhH/UBhfCnnG/kq3lyQD+OIVN1PzJI9YBObXs dCvMgOALWBGYu7MNRIRSWRCq92x1JKNgQzcsY6mXS9bVXnMRYQXi0Q+vowzSeJH3+o GHieqAC4FdPUcc+yDKyJT4pMxYChEl0x4opfEqPfylL2IVAP/O1f6WeADIPIbkxoND pa5hslqk2R0ZH+mRkQK6mHwZT1IPPQb6sFIlW6KCs0crcbRm9IUlyOoPwgcIq9Ett2 kZLNGw0z7wxyKMr7HWxtkIVk+MoS1AsB/b9gC8Lw76dgANzwsLsqnEdZDN/mKTsDM1 rbwC3AYpqbybA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 06/10] mm/damon/core: add DAMOS quota gaol metric for per-memcg per-numa free memory Date: Thu, 9 Oct 2025 14:20:38 -0700 Message-Id: <20251009212042.60084-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251009212042.60084-1-sj@kernel.org> References: <20251009212042.60084-1-sj@kernel.org> 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 variant of DAMOS_QUOTA_NODE_MEMCG_USED_BP, for the free memory portion. The value of the metric is implemented as the entire memory of the given NUMA node subtracted by the given cgroup's usage. So from a perspective, "unused" could be a better term than "free". But arguably it is not very clear what is better, so use the term "free". Signed-off-by: SeongJae Park --- include/linux/damon.h | 6 ++++-- mm/damon/core.c | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 0d63ceb7e6ef..0edf41d36ea1 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -148,6 +148,7 @@ enum damos_action { * @DAMOS_QUOTA_NODE_MEM_USED_BP: MemUsed ratio of a node. * @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. * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. * * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupport= ed. @@ -158,6 +159,7 @@ enum damos_quota_goal_metric { DAMOS_QUOTA_NODE_MEM_USED_BP, DAMOS_QUOTA_NODE_MEM_FREE_BP, DAMOS_QUOTA_NODE_MEMCG_USED_BP, + DAMOS_QUOTA_NODE_MEMCG_FREE_BP, NR_DAMOS_QUOTA_GOAL_METRICS, }; =20 @@ -183,8 +185,8 @@ enum damos_quota_goal_metric { * If @metric is DAMOS_QUOTA_NODE_MEM_{USED,FREE}_BP, @nid represents the = node * id of the target node to account the used/free memory. * - * If @metric is DAMOS_QUOTA_NODE_MEMCG_USED_BP, @nid and @memcg_id repres= ents - * the node id and the cgroup to account the used memory for. + * 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. */ struct damos_quota_goal { enum damos_quota_goal_metric metric; diff --git a/mm/damon/core.c b/mm/damon/core.c index 1eacf78aa358..a31ede50906c 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -2039,7 +2039,7 @@ static unsigned long damos_get_node_memcg_used_bp( { struct mem_cgroup *memcg; struct lruvec *lruvec; - unsigned long used_pages; + unsigned long used_pages, numerator; struct sysinfo i; =20 rcu_read_lock(); @@ -2059,7 +2059,11 @@ static unsigned long damos_get_node_memcg_used_bp( used_pages +=3D lruvec_page_state(lruvec, NR_INACTIVE_FILE); =20 si_meminfo_node(&i, goal->nid); - return used_pages * 10000 / i.totalram; + if (goal->metric =3D=3D DAMOS_QUOTA_NODE_MEMCG_USED_BP) + numerator =3D used_pages; + else /* DAMOS_QUOTA_NODE_MEMCG_FREE_BP */ + numerator =3D i.totalram - used_pages; + return numerator * 10000 / i.totalram; } #else static __kernel_ulong_t damos_get_node_mem_bp( @@ -2094,6 +2098,7 @@ static void damos_set_quota_goal_current_value(struct= damos_quota_goal *goal) goal->current_value =3D damos_get_node_mem_bp(goal); break; case DAMOS_QUOTA_NODE_MEMCG_USED_BP: + case DAMOS_QUOTA_NODE_MEMCG_FREE_BP: goal->current_value =3D damos_get_node_memcg_used_bp(goal); break; default: --=20 2.39.5 From nobody Fri Dec 19 10:34:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46D8D28689B; Thu, 9 Oct 2025 21:20:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044856; cv=none; b=Dz7NCrrZ/z+YH4HzKGgdgU5Zchf6KvsIAwd+gxytJX7SSbXYOhUztJl+WmBR+gDVPaxZmwTZ1dpU1eOXFvqqA9HJvFyPGR/AhHomQBGPhSrZB/wVXgazW1SF7cG5/oQXmldu1p8BO/jxe5LVu+CI3ZlHuOfgq5pEKwXNji575UA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044856; c=relaxed/simple; bh=LW/6mDf7N5tp3NVaa/MTw5MzAUr1eIrJZfX1KpNkybA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZOLTmeSDy4dFqWlpaR9uJJHc2SYmtNjKybtUT5wUfZl1UA3Ly8D49NPsRMhpPe99r000ulC2/u1clpVsZrCUkObNuJwd7tzaQSaqVbydeUsRUmfOK4JtwhdWqzUtN+VN27Rt8oc6cTKLvJLJ0nW3i6sXnWVVU9BZUk5h86uM7mQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tz90siZg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tz90siZg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BA1CC116D0; Thu, 9 Oct 2025 21:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760044855; bh=LW/6mDf7N5tp3NVaa/MTw5MzAUr1eIrJZfX1KpNkybA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tz90siZgJeVmm6nJG5948QdV75YE3e3vx6SMoOo30urTFGr8SXMhYgE1BdGVItvUE ao0smPENqeNMT+3IRdPWVPkxrh63rfPjDqPIqecuGVQgdowuXFvPOtSEqlf6S3WU7w sIlL7ZjanGac5t9WD7wpXlJFwiy0yainSj6eVtsZEznYvZ0RJFXl5izlXaYz4INTZU 3EaBRmhJpQs+qKyjY14VqNVGzhYbjfRz++1EtaCBKfWoFtMuHcrzY0eI6n0qP55wKN PAe0T1j6IhOVZVGWfG4rCXmh9/jBzqt+mj0hDMRt6lx113NgKZX5COGYZJUzTCr7MZ q2rNXksuqaeXw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 07/10] mm/damon/sysfs-schemes: support DAMOS_QUOTA_NODE_MEMCG_FREE_BP Date: Thu, 9 Oct 2025 14:20:39 -0700 Message-Id: <20251009212042.60084-8-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251009212042.60084-1-sj@kernel.org> References: <20251009212042.60084-1-sj@kernel.org> 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" Extend DAMON sysfs to support DAMOS_QUOTA_NODE_MEMCG_FREE_BP. Signed-off-by: SeongJae Park --- 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 c679e62fd4b9..c98cf4bd2fbb 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1034,6 +1034,10 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgo= al_metric_names[] =3D { .metric =3D DAMOS_QUOTA_NODE_MEMCG_USED_BP, .name =3D "node_memcg_used_bp", }, + { + .metric =3D DAMOS_QUOTA_NODE_MEMCG_FREE_BP, + .name =3D "node_memcg_free_bp", + }, }; =20 static ssize_t target_metric_show(struct kobject *kobj, @@ -2552,6 +2556,7 @@ static int damos_sysfs_add_quota_score( goal->nid =3D sysfs_goal->nid; break; case DAMOS_QUOTA_NODE_MEMCG_USED_BP: + case DAMOS_QUOTA_NODE_MEMCG_FREE_BP: err =3D damon_sysfs_memcg_path_to_id( sysfs_goal->path, &goal->memcg_id); if (err) { --=20 2.39.5 From nobody Fri Dec 19 10:34:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F048286D73; Thu, 9 Oct 2025 21:20:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044858; cv=none; b=QJ3FjFwjS+o8fz0ut8iHMNMdwNl+3shJwS+Q0RZT3JFDhjBpFEYuy3441Ww/KMc/KDI4MLjqG19DatiMXHECX7wP7GgVJvIqNMG1ZvYfWEn25NRQVjF19FZY0bJ6Mqg3am7F5u8DTuakjBT1OVuBoGojgorner4nKJorUzROV9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044858; c=relaxed/simple; bh=iYqIOlBPNnXz4smGK3ct25Bt+psvuvYa3PTnXBMC96s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gddHo9y2/XyPQN78J+Y8yZVcXjs4EeqraS+M2XqCTWcEUCXP1sGiwMXV5KXQ6vRoBiNoVa/O4LkBc5zI/9rA/0pXmINDandEXCiDa4pW0fg34yhmGhvImEd13GRATYd9HawgcG9/DXTEmEE0qdKTbPiRqJ5f0E28poe0QtuvbR0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fsZJkrSA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fsZJkrSA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEB18C4CEE7; Thu, 9 Oct 2025 21:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760044857; bh=iYqIOlBPNnXz4smGK3ct25Bt+psvuvYa3PTnXBMC96s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fsZJkrSAFJEJJLDKmJO2px5MRhIl/Y8a7LsCOSzS7pxW2kFDEh3zUtAwA9i4z4DYp kBTw+4KcA7oK5MwKs8kt8e7NK2/kuKXjgOZw6v247C1WtsBRi8CqhlyqAfDaFaTlYQ pY7FlQ3Fd5Vz0YMqidMIdbf5IMu9kqm02eeCentFFzIQZ3dEQQ+vudU9CoYtwaa4QF 76WXDGgRzNgxzwkAdsd4ivR2yEhYN2CFNGv0gi2BTwyx/nD7reQ1PxOJEO/UY3J9JF AoksE2Nzi70gRjv9xWY9PMfkCc5u95OzyR8WtyTUu1xmrGPNd32pcClBsIGqzDozMX XT7W/T/8j3vXQ== From: SeongJae Park To: Cc: SeongJae Park , "Liam R. Howlett" , Andrew Morton , David Hildenbrand , Jonathan Corbet , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Suren Baghdasaryan , Vlastimil Babka , damon@lists.linux.dev, kernel-team@meta.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 08/10] Docs/mm/damon/design: document DAMOS_QUOTA_NODE_MEMCG_{USED,FREE}_BP Date: Thu, 9 Oct 2025 14:20:40 -0700 Message-Id: <20251009212042.60084-9-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251009212042.60084-1-sj@kernel.org> References: <20251009212042.60084-1-sj@kernel.org> 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" Update design doc for the newly added two DAMOS quota auto-tuning target goal metrics, DAMOS_QUOTA_NODE_MEMCG_{USED,FREE}_BP. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/des= ign.rst index 80354f4f42ba..b54925ea78e9 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -564,9 +564,9 @@ aggressiveness (the quota) of the corresponding scheme.= For example, if DAMOS is under achieving the goal, DAMOS automatically increases the quota. If = DAMOS is over achieving the goal, it decreases the quota. =20 -The goal can be specified with four parameters, namely ``target_metric``, -``target_value``, ``current_value`` and ``nid``. The auto-tuning mechanism -tries to make ``current_value`` of ``target_metric`` be same to +The goal can be specified with five parameters, namely ``target_metric``, +``target_value``, ``current_value``, ``nid`` and ``path``. The auto-tuning +mechanism tries to make ``current_value`` of ``target_metric`` be same to ``target_value``. =20 - ``user_input``: User-provided value. Users could use any metric that th= ey @@ -581,9 +581,18 @@ tries to make ``current_value`` of ``target_metric`` b= e same to set by users at the initial time. In other words, DAMOS does self-feedb= ack. - ``node_mem_used_bp``: Specific NUMA node's used memory ratio in bp (1/10= ,000). - ``node_mem_free_bp``: Specific NUMA node's free memory ratio in bp (1/10= ,000). - -``nid`` is optionally required for only ``node_mem_used_bp`` and -``node_mem_free_bp`` to point the specific NUMA node. +- ``node_memcg_used_bp``: Specific cgroup's node used memory ratio for a + specific NUMA node, in bp (1/10,000). +- ``node_memcg_free_bp``: Specific cgroup's node unused memory ratio for a + specific NUMA node, in bp (1/10,000). + +``nid`` is optionally required for only ``node_mem_used_bp``, +``node_mem_free_bp``, ``node_memcg_used_bp`` and ``node_memcg_free_bp`` to +point the specific NUMA node. + +``path`` is optionally required for only ``node_memcg_used_bp`` and +``node_memcg_free_bp`` to point the path to the cgroup. The value should = be +the path of the memory cgroup from the cgroups mount point. =20 To know how user-space can set the tuning goal metric, the target value, a= nd/or the current value via :ref:`DAMON sysfs interface `, refe= r to --=20 2.39.5 From nobody Fri Dec 19 10:34:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21A9B287268; Thu, 9 Oct 2025 21:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044859; cv=none; b=eGuGCHz7ykpd6deWnEoW0nWGK7Pi7/KbQZi53ge1+HY/CFyVznxhoAq2nCzveyipcX0B3iOr9T4PmNbuvncLtn2S9TpQ70tTNH0kTb7azzO2g9xQ2Xy/UfB9jmqzSSUofXb2kKNGGCZH8Z98LGDxKYFyMv9amTRvwz3TYAWFUF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044859; c=relaxed/simple; bh=c3w+jGZIkcFz1bj37NYQVYFms2ZoPQQJjnr1dqcqrzk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=m7UfycnvHk+pnSyr9ZKVIY1YWpIhgEONXgkt3o+znfljbobhqSIaDH4x3frN4f48PvIcgoRveHoFJlyILDgYwa9aZSUQcBxCb+4km5OeK6SxlMR1d4gaG0EuC8APwjeeYhAunYldIGiMBZiHUBENLdEiYOCe7/s5nL4ezamPc/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iwiq+z9N; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iwiq+z9N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C657DC4CEE7; Thu, 9 Oct 2025 21:20:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760044859; bh=c3w+jGZIkcFz1bj37NYQVYFms2ZoPQQJjnr1dqcqrzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iwiq+z9N7k5zhBrw09Vtp1n2Tn6BSsrEl88mOt1tkYea/S5Gz33b45jExVLY/CrKj pKuxINooLI4m/Lv8IX31vpMCFI6OjKRvt1RipEAUWpm93fEcMIQBBE/EtMWE0I7bov hWbb8JxfaqLO8xWEJhFkDQz/C2WMrL0vwBHMZ/EEGKOABodFzOhqvN0UVon0AeQhWJ lMxPpTDHRwBUwTBRS0t1DjxHlTGsFWHSA0pvijHwK7i2bUsHTFo7+G8UJanNqTjhNC DAuW/Z7juLiVu5Mx45odTE4zN156Qf1tGcAEl8yylYfE0IN4CEhNeK3G9+nNJOM9ZS 2EZkYzxQ3ns7w== From: SeongJae Park To: Cc: SeongJae Park , "Liam R. Howlett" , Andrew Morton , David Hildenbrand , Jonathan Corbet , Lorenzo Stoakes , Michal Hocko , Mike Rapoport , Suren Baghdasaryan , Vlastimil Babka , damon@lists.linux.dev, kernel-team@meta.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 09/10] Docs/admin-guide/mm/damon/usage: document DAMOS quota goal path file Date: Thu, 9 Oct 2025 14:20:41 -0700 Message-Id: <20251009212042.60084-10-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251009212042.60084-1-sj@kernel.org> References: <20251009212042.60084-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable A new DAMON sysfs interface file, namely 'path' has been added under DAMOS quota goal directory, for specifying the cgroup for DAMOS_QUOTA_NODE_MEMCG_{USED,FREE}_BP metrics. Document it on the usage document. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/a= dmin-guide/mm/damon/usage.rst index eae534bc1bee..98958975604d 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -81,7 +81,7 @@ comma (","). =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`quotas `/ms,bytes,reset_interval_ms,effective_bytes =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 weights/sz_permil,nr_accesses_permil,age_permil =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 :ref:`goals `/nr_goals - =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 =E2=94=82 0/target_metric,target_value,current_value,nid + =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 =E2=94=82 0/target_metric,target_value,current_value,nid,path =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`watermarks `/metric,interval_us,high,mid,low =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = :ref:`{core_,ops_,}filters `/nr_filters =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 = =E2=94=82 0/type,matching,allow,memcg_path,addr_start,addr_end,target_idx,m= in,max @@ -402,9 +402,9 @@ number (``N``) to the file creates the number of child = directories named ``0`` to ``N-1``. Each directory represents each goal and current achievement. Among the multiple feedback, the best one is used. =20 -Each goal directory contains four files, namely ``target_metric``, -``target_value``, ``current_value`` and ``nid``. Users can set and get the -four parameters for the quota auto-tuning goals that specified on the +Each goal directory contains five files, namely ``target_metric``, +``target_value``, ``current_value`` ``nid`` and ``path``. Users can set a= nd +get the five parameters for the quota auto-tuning goals that specified on = the :ref:`design doc ` by writing to and reading from each of the files. Note that users should further write ``commit_schemes_quota_goals`` to the ``state`` file of the :ref:`kdamond --=20 2.39.5 From nobody Fri Dec 19 10:34:41 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C965E2877D8; Thu, 9 Oct 2025 21:21:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044860; cv=none; b=e4KMI8rWGusgbCD9kWvAeBka5sENUsWSuW5wouMgjK2u6tLEExExkXJsrFrQFr0kwM374HT0h4kluES7Vd0PirZ7fAdQQ4PxcBXLjvvCmM2t+LA6HJhAET3ARjRveMagWji/ZLYwQVwti9cc7wsVyAQvW7ioILLwgFDpg1VC2g8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760044860; c=relaxed/simple; bh=LT7SzPWNmkjozXj4ZRhtWHCKmd+a1TEy/eHu+98PlFw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Pia90lKtMB+wLNhgZU4EGO57ye926Bu7vlMcKj7JrE3Nq4yLXIWFwLtjkftip6RasLOYWYGSbTB8bq5I0lIdGZNuH5wYS16/wrkBPC5qgjvBxNBvHf0p7j2ZvenfHPN8hyYxIedYqKNmuRR1OOGtSRMrwQvY9VugP3SQgFdwY6c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oBbSm2sg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oBbSm2sg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28AF7C4CEFE; Thu, 9 Oct 2025 21:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760044860; bh=LT7SzPWNmkjozXj4ZRhtWHCKmd+a1TEy/eHu+98PlFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oBbSm2sgSupxR4duimHSUEtMTKGebV5ysf2bamIpK2SDE/2Ok5vmMThgdHNAs4MN2 u/eUHUFGnSZWVTHQ6ezelpQr6nlV4CEyQIaLmwc88n0vXcwnTHct2Jh54jrFDkbc94 AOEDhWcbQstqmAfyVceckgjTRPiGZW7Tba6nWNwbbWOTC2fq733OwlHzB1GQhyPZ2J rGoxq7OgmtZ/J5wMlpzPtvox+8BZuJQXkO2MEniKGb5oyfs9BKUJESeb/Sw++Zkpyt hV656KabYwa45eOorPmUvwqrwg/Wl7j5EQvCio/Itqd4BIdv4aemIzvyPhTA0BRUwL yP3gqKxI5HeqA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 10/10] Docs/ABI/damon: document DAMOS quota goal path file Date: Thu, 9 Oct 2025 14:20:42 -0700 Message-Id: <20251009212042.60084-11-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251009212042.60084-1-sj@kernel.org> References: <20251009212042.60084-1-sj@kernel.org> 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" A DAMON sysfs interface file for DAMOS quota goal's optional path argument has been added. Document it on the ABI doc. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentatio= n/ABI/testing/sysfs-kernel-mm-damon index b6b71db36ca7..dce6c2cda4e8 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -303,6 +303,12 @@ Contact: SeongJae Park Description: Writing to and reading from this file sets and gets the nid parameter of the goal. =20 +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//qu= otas/goals//path +Date: Oct 2025 +Contact: SeongJae Park +Description: Writing to and reading from this file sets and gets the path + parameter of the goal. + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//qu= otas/weights/sz_permil Date: Mar 2022 Contact: SeongJae Park --=20 2.39.5