From nobody Sat Jul 25 02:45:20 2026 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 D492740929A for ; Mon, 20 Jul 2026 12:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784548915; cv=none; b=APwzkT/eRvejhxn7oraimPyO79ggCaIZm7j22zDyaACb1hZ/jQkaWXNWUo1deOSl3gQNm7CJsfMFn99GX0cm6DvcZMrRLiS6/pXblSQSCKGSTgirAsmNxwqo1IcxK/e4Dpcf+wqP+VPOwEKrJWV8llQAES2xZADWQXh6pEbN8ao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784548915; c=relaxed/simple; bh=+Vz99Cj4p9gikvJ08u1bdK/IN5xyoYGGvJ00+jdUxhw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=auw+NHlXSdH2Bp3hfoo6tCfjT/uDUXHln8vaADs5aX6TfYeqjpsmYWjCerLmplKJia4fnlNI8CupuebWA2ODCXdMjJETIpwdwFQe5i89Tfjy2qHn2FVitpfChUvM5LO/HhaWhXyMB7jgboUjcmfGdtt0uNBuBhWriiFbq3Gjn8k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei-partners.com; spf=pass smtp.mailfrom=huawei-partners.com; dkim=pass (1024-bit key) header.d=huawei-partners.com header.i=@huawei-partners.com header.b=l0RYnj0d; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei-partners.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei-partners.com header.i=@huawei-partners.com header.b="l0RYnj0d" dkim-signature: v=1; a=rsa-sha256; d=huawei-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=IsJhOa/Z1KGfdfHrs3xDiPTpetSErP5ztLNsSTsvK+s=; b=l0RYnj0durVJjLO1JPNhWxPWahYDusTT8OpLKHlUAycuv7RT8/AXANQ9NW9QAl7MqucCK1+zk nfQtT8a8UNAmETQ+NnVRwNz9+09/IDus6ZjOmyUVqCanhPTnC0HcCjig2ifXgANBUnuoX2iPim/ PapqlgS7tGxpYuj2hrY2NSY= Received: from mail.maildlp.com (unknown [172.18.224.150]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4h3fHn3Px9zJ46ZJ; Mon, 20 Jul 2026 20:01:25 +0800 (CST) Received: from mscpeml500003.china.huawei.com (unknown [7.188.49.51]) by mail.maildlp.com (Postfix) with ESMTPS id ED3DB40570; Mon, 20 Jul 2026 20:01:43 +0800 (CST) Received: from mscphis01197.huawei.com (10.123.65.218) by mscpeml500003.china.huawei.com (7.188.49.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 20 Jul 2026 15:01:43 +0300 From: To: , , , , , , , , , , Subject: [PATCH v3 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE auto tuning Date: Mon, 20 Jul 2026 12:01:38 +0000 Message-ID: <20260720120140.881468-2-gutierrez.asier@huawei-partners.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720120140.881468-1-gutierrez.asier@huawei-partners.com> References: <20260720120140.881468-1-gutierrez.asier@huawei-partners.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 X-ClientProxiedBy: mscpeml100003.china.huawei.com (10.199.174.67) To mscpeml500003.china.huawei.com (7.188.49.51) Content-Type: text/plain; charset="utf-8" From: Asier Gutierrez Introduce DAMOS_QUOTA_HUGEPAGE_MEM_BP auto tuning. Add a new DAMOS quota goal metric to measure the amount of huge page consumption to total memory consumption ratio. Vmstat may lag, which in some cases may lead to NR_FREE_PAGES being equal to the amount of RAM in the system. A guard is added to avoid the extremely unlikely case of a division by 0.[1] In that we return INT_MAX, which should be enough not to apply any DAMOS action until the NR_FREE_PAGES is updated. [1] https://lore.kernel.org/all/20260715151615.99767-1-sj@kernel.org/ Signed-off-by: Asier Gutierrez Reviewed-by: SJ Park --- include/linux/damon.h | 2 ++ mm/damon/core.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 327f534696aa..0d0b7bb233b7 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -153,6 +153,7 @@ enum damos_action { * @DAMOS_QUOTA_INACTIVE_MEM_BP: Inactive to total LRU memory ratio. * @DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP: Scheme-eligible memory ratio of a * node in basis points (0-10000). + * @DAMOS_QUOTA_HUGEPAGE_MEM_BP: Huge page to total used memory ratio. * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. * * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupport= ed. @@ -167,6 +168,7 @@ enum damos_quota_goal_metric { DAMOS_QUOTA_ACTIVE_MEM_BP, DAMOS_QUOTA_INACTIVE_MEM_BP, DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP, + DAMOS_QUOTA_HUGEPAGE_MEM_BP, NR_DAMOS_QUOTA_GOAL_METRICS, }; =20 diff --git a/mm/damon/core.c b/mm/damon/core.c index 603b102ff80f..73aaee43c6f7 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -3004,6 +3004,24 @@ static unsigned int damos_get_in_active_mem_bp(bool = active_ratio) return mult_frac(inactive, 10000, total); } =20 +static unsigned int damos_hugepage_mem_bp(void) +{ + unsigned long thp, total; + + thp =3D global_node_page_state(NR_ANON_THPS) + + global_node_page_state(NR_SHMEM_THPS) + + global_node_page_state(NR_FILE_THPS); + total =3D totalram_pages() - global_zone_page_state(NR_FREE_PAGES); + + /* + * vmstat may lag in idle systems and lead to free pages equaling to + * the total RAM in the system. + */ + if (!total) + return INT_MAX; + return mult_frac(thp, 10000, total); +} + static void damos_set_quota_goal_current_value(struct damon_ctx *c, struct damos *s, struct damos_quota_goal *goal) { @@ -3035,6 +3053,9 @@ static void damos_set_quota_goal_current_value(struct= damon_ctx *c, goal->current_value =3D damos_get_node_eligible_mem_bp(c, s, goal->nid); break; + case DAMOS_QUOTA_HUGEPAGE_MEM_BP: + goal->current_value =3D damos_hugepage_mem_bp(); + break; default: break; } --=20 2.43.0 From nobody Sat Jul 25 02:45:20 2026 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 D2FD9409278 for ; Mon, 20 Jul 2026 12:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784548914; cv=none; b=W+E1bclqwjmXCQj34FqPhXuuk9mqYXftXrdHYNRLzrfG5NvQfJoHYLyxWj8lhfr/uy3joZPfAqM5kAo+Qwhlaba1U3ZlmgP5Ch23JKBIhF+bYp4HzIl4gAs3O1AWND/0OGjbtkLvV61M+mQ8HdQB4AbfHOMXyaDxmhEBnUOPFgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784548914; c=relaxed/simple; bh=iCkOj4E5pGJbFL+6/u+llz5h/zsnyXDsF8Qojj1TzdU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=saLdaSnQyKiYnx/Erk/fe0sGVSJr2u3IxB5XDJmgkgO55mgGRzXU1C5+GPHT7xH4MVrKpAAH7Cvvz14XkkwOYN87vbnGRV7qMckOIdsfbj4xesMn5yqrq2EhZIP1ofQKM94OPdqWe2tbkkBztYbQhyZDaiKlWLrrauIomyXdnoc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei-partners.com; spf=pass smtp.mailfrom=huawei-partners.com; dkim=pass (1024-bit key) header.d=huawei-partners.com header.i=@huawei-partners.com header.b=SGkHzx+b; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei-partners.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei-partners.com header.i=@huawei-partners.com header.b="SGkHzx+b" dkim-signature: v=1; a=rsa-sha256; d=huawei-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=e/YQPAgOQrSG3+15c/29ezD+K1P4Be7L3Rah6eZxjWc=; b=SGkHzx+bvAljk7vLYPDLYWTY4AOlUJMnF4SxiBBhsMs+N1EGfkuJHrhuX6BK8GCMbieshH7jK MXy49TjA8IS8HSv8n4PsRWpp38+49jqt5DxMNGGBnHeBC0/DtJqc5E6CTr2H7MgRD8OJE/DiuP6 Pr5Eq4Xzngm19FJexNco4Tk= Received: from mail.maildlp.com (unknown [172.18.224.150]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4h3fHj6HJVzHnH4x; Mon, 20 Jul 2026 20:01:21 +0800 (CST) Received: from mscpeml500003.china.huawei.com (unknown [7.188.49.51]) by mail.maildlp.com (Postfix) with ESMTPS id 0D8BD40571; Mon, 20 Jul 2026 20:01:44 +0800 (CST) Received: from mscphis01197.huawei.com (10.123.65.218) by mscpeml500003.china.huawei.com (7.188.49.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 20 Jul 2026 15:01:43 +0300 From: To: , , , , , , , , , , Subject: [PATCH v3 2/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric Date: Mon, 20 Jul 2026 12:01:39 +0000 Message-ID: <20260720120140.881468-3-gutierrez.asier@huawei-partners.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720120140.881468-1-gutierrez.asier@huawei-partners.com> References: <20260720120140.881468-1-gutierrez.asier@huawei-partners.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 X-ClientProxiedBy: mscpeml100003.china.huawei.com (10.199.174.67) To mscpeml500003.china.huawei.com (7.188.49.51) Content-Type: text/plain; charset="utf-8" From: Asier Gutierrez DAMOS has a new autotune policy metric: DAMOS_QUOTA_HUGEPAGE_MEM_BP. This patch exposes DAMOS_QUOTA_HUGEPAGE_MEM_BP through sysfs. Add the "hugepage_mem_bp" to the sysfs-schemes interface. Signed-off-by: Asier Gutierrez Reviewed-by: SeongJae Park Reviewed-by: SJ Park --- mm/damon/sysfs-schemes.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 32f495a96b17..d9b81d7b5910 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1269,6 +1269,10 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgo= al_metric_names[] =3D { .metric =3D DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP, .name =3D "node_eligible_mem_bp", }, + { + .metric =3D DAMOS_QUOTA_HUGEPAGE_MEM_BP, + .name =3D "hugepage_mem_bp", + }, }; =20 static ssize_t target_metric_show(struct kobject *kobj, --=20 2.43.0 From nobody Sat Jul 25 02:45:20 2026 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 D691F40929B for ; Mon, 20 Jul 2026 12:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784548913; cv=none; b=U0ThM3huwFGYLagtnrkQveN/FLdfIKhziiS0l4GXaAnPH7QRxcmzXvxON52z2lVAgpIcVyxS4iRVW+iOtD/BCupPpGfSSKJixrmiyeJNiTenn7qGfNmEfQWrRCMeRG2qVwQYlBJ5uB1cZj45rdfs/1SBn28Zmyejbn+a7/qmqC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784548913; c=relaxed/simple; bh=dkAR92jis8STtC64GAqFUhy2cPmVcY6pES7V+MghZSo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cz6AjlOIic51vXS1CcJAcJ24TDwq6a1Ek+nScw6CbADVJdf6vwUxp8bb/ruj8ErTrycb7D4w/W4DYMjtg9QQoE3NyYDUsNeMG/Iw8QHr+yWAwAHteSjIgCqdCMY6ggAFEExZ+kfRZHh7cbnbcYx9YJSEcIlgSgarVqP53XMRwW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei-partners.com; spf=pass smtp.mailfrom=huawei-partners.com; dkim=pass (1024-bit key) header.d=huawei-partners.com header.i=@huawei-partners.com header.b=GDnvskj1; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei-partners.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei-partners.com header.i=@huawei-partners.com header.b="GDnvskj1" dkim-signature: v=1; a=rsa-sha256; d=huawei-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=o7VcgX5vIHVzpuEW1mQLqgVH3WPDkCDx6B6ye8bU6SE=; b=GDnvskj1Y3CRxQwlfdqkMCVN7KbsUN9TRUXS6qtHZJL3c3/OfKyFY4YHsbTGCPrwi4pcPyBWo iMYDoqAfLmtTarkKKHMkjTgqop2hDVexyj09QbH0Z6FW5sxkdO+/X+WQktbMhS4lkrnB3EovgmD Amwn80nGqOFofRoaMRIruWs= Received: from mail.maildlp.com (unknown [172.18.224.150]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4h3fHj6t8bzHnH5k; Mon, 20 Jul 2026 20:01:21 +0800 (CST) Received: from mscpeml500003.china.huawei.com (unknown [7.188.49.51]) by mail.maildlp.com (Postfix) with ESMTPS id 21FA640570; Mon, 20 Jul 2026 20:01:44 +0800 (CST) Received: from mscphis01197.huawei.com (10.123.65.218) by mscpeml500003.china.huawei.com (7.188.49.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 20 Jul 2026 15:01:43 +0300 From: To: , , , , , , , , , , Subject: [PATCH v3 3/3] Docs/mm/damon/design: Document hugepage_mem_bp target metric Date: Mon, 20 Jul 2026 12:01:40 +0000 Message-ID: <20260720120140.881468-4-gutierrez.asier@huawei-partners.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260720120140.881468-1-gutierrez.asier@huawei-partners.com> References: <20260720120140.881468-1-gutierrez.asier@huawei-partners.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 X-ClientProxiedBy: mscpeml100003.china.huawei.com (10.199.174.67) To mscpeml500003.china.huawei.com (7.188.49.51) Content-Type: text/plain; charset="utf-8" From: Asier Gutierrez Document hugepage_mem_bp metric exposed by sysfs. Signed-off-by: Asier Gutierrez Reviewed-by: SJ Park --- Documentation/mm/damon/design.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/des= ign.rst index aed6cb1cf483..a8c163475ef2 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -713,6 +713,8 @@ mechanism tries to make ``current_value`` of ``target_m= etric`` be same to bp (1/10,000). - ``node_eligible_mem_bp``: Scheme target access pattern-eligible memory r= atio of a node in bp (1/10,000). +- ``hugepage_mem_bp``: Total huge page to total used memory ratio in bp + (1/10,000). =20 ``nid`` is optionally required for ``node_mem_used_bp``, ``node_mem_free_b= p``, ``node_memcg_used_bp``, ``node_memcg_free_bp`` and ``node_eligible_mem_bp`= ` to --=20 2.43.0