From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF39AC54EE9 for ; Tue, 13 Sep 2022 18:27:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231244AbiIMS1R (ORCPT ); Tue, 13 Sep 2022 14:27:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232568AbiIMS0q (ORCPT ); Tue, 13 Sep 2022 14:26:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A91635FDF for ; Tue, 13 Sep 2022 10:44:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9F1DB61547 for ; Tue, 13 Sep 2022 17:44:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B87CC433C1; Tue, 13 Sep 2022 17:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091094; bh=A+CgN3B+g3StjvR1ecSJxFzUf8y+UUwnpB+0EtAIiO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CaZNkoG/DVyccvLtqoqoXyvYOsHQtVbs6/wMr5ibaQ7DAm+4nezKW8iI7X+nPrA/L ZQiVPvS/2eoWgjc45bbWm9hmWeeoxRGXCrEYslIJMGLNa6nuHsgWuBSsmFfL1DfABf of72OPPFBIWP3hapXUV0alxnuRiZx3zVSIXg8XXPNpNQVW5dwTex4KEDlPQAO5Xe34 OsdNZRiLs4KjD0ofUTXPgIAI88nH4KUH8FcBu9Dw3JwbR/idcFmxqE46Qe29kkfuvQ 9j2yEPtwNm2knoIE4eAI+4gV1axPzGOMUwTDlyMrXqhHIQuMEY7occdn9bn74VZdT2 VqhFkGWzuH27g== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/22] mm/damon/paddr: make supported DAMOS actions of paddr clear Date: Tue, 13 Sep 2022 17:44:28 +0000 Message-Id: <20220913174449.50645-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The 'swtich-case' statement in 'damon_va_apply_scheme()' function provides a 'case' for every supported DAMOS action while all not-yet-supported DAMOS actions fall through the 'default' case, and comment it so that people can easily know which actions are supported. Its counterpart in 'paddr', 'damon_pa_apply_scheme()', however, doesn't. This commit makes the 'paddr' side function follows the pattern of 'vaddr' for better readability and consistency. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index f00cbe74a00e..5eba09d50855 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -274,7 +274,10 @@ static unsigned long damon_pa_apply_scheme(struct damo= n_ctx *ctx, return damon_pa_mark_accessed(r); case DAMOS_LRU_DEPRIO: return damon_pa_deactivate_pages(r); + case DAMOS_STAT: + break; default: + /* DAMOS actions that not yet supported by 'paddr'. */ break; } return 0; --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB92CC54EE9 for ; Tue, 13 Sep 2022 18:27:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229887AbiIMS1X (ORCPT ); Tue, 13 Sep 2022 14:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231503AbiIMS0r (ORCPT ); Tue, 13 Sep 2022 14:26:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 157C83ED41 for ; Tue, 13 Sep 2022 10:44:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 570E461520 for ; Tue, 13 Sep 2022 17:44:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57CE3C433C1; Tue, 13 Sep 2022 17:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091096; bh=K7noZZXWc7OYsglqBcB0HhttVkm6j87iOZkQHk+Jwew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gjqjlZf4JKxlU1qngINKNjIQRI28bhKmxR92VUaRZcndWGVsHxTgjpcRt1D0Zuwi/ ePWweOxeH7mPuBSxxkL4zVMcsH4BEUV1NwoCQfXffHgIhxad80QCQ2qV008KHhn1Vv hoROFzflbLsBCI3TbtUudMRip+AD3zcKQc/WxZWvjH+kvUUrRZf1kgRbUHtIKUbl93 uDwfi6aqAsyDMGoFYTAiRhyXbFN6YYa4qhwczpJtNWzGb73RaAA7rnjEVaNxUf1bNf DphOwtdl5EriObrDYPtNfFlpiKLOUudJbjBdUgRbArSbBe91yejtE9j/5NCe9eevAu ls+6bACVYRRGw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/22] mm/damon/paddr: deduplicate damon_pa_{mark_accessed,deactivate_pages}() Date: Tue, 13 Sep 2022 17:44:29 +0000 Message-Id: <20220913174449.50645-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The bodies of damon_pa_{mark_accessed,deactivate_pages}() contains duplicates. This commit factors out the common part to a separate function and removes the duplicates. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 5eba09d50855..dfeebffe82f4 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -231,7 +231,8 @@ static unsigned long damon_pa_pageout(struct damon_regi= on *r) return applied * PAGE_SIZE; } =20 -static unsigned long damon_pa_mark_accessed(struct damon_region *r) +static inline unsigned long damon_pa_mark_accessed_or_deactivate( + struct damon_region *r, bool mark_accessed) { unsigned long addr, applied =3D 0; =20 @@ -240,27 +241,24 @@ static unsigned long damon_pa_mark_accessed(struct da= mon_region *r) =20 if (!page) continue; - mark_page_accessed(page); + if (mark_accessed) + mark_page_accessed(page); + else + deactivate_page(page); put_page(page); applied++; } return applied * PAGE_SIZE; } =20 -static unsigned long damon_pa_deactivate_pages(struct damon_region *r) +static unsigned long damon_pa_mark_accessed(struct damon_region *r) { - unsigned long addr, applied =3D 0; - - for (addr =3D r->ar.start; addr < r->ar.end; addr +=3D PAGE_SIZE) { - struct page *page =3D damon_get_page(PHYS_PFN(addr)); + return damon_pa_mark_accessed_or_deactivate(r, true); +} =20 - if (!page) - continue; - deactivate_page(page); - put_page(page); - applied++; - } - return applied * PAGE_SIZE; +static unsigned long damon_pa_deactivate_pages(struct damon_region *r) +{ + return damon_pa_mark_accessed_or_deactivate(r, false); } =20 static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C4C0ECAAD8 for ; Tue, 13 Sep 2022 18:27:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232688AbiIMS1d (ORCPT ); Tue, 13 Sep 2022 14:27:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232356AbiIMS0u (ORCPT ); Tue, 13 Sep 2022 14:26:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B42F5C363 for ; Tue, 13 Sep 2022 10:45:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9702DB80CBC for ; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F29C2C433D7; Tue, 13 Sep 2022 17:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091097; bh=0FJOrqHiBH1OMZ45Xdi5Z4U0goCpXjUFgshxwmAlQlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=es99vqn1ffMbBBFLbtJGVKcjrXyHgR79vSQyF0z+ScdGpaJVr4lW+yHoZQY+cSeoA sDnWKHHLwouvB+Zqwonl+asV8uuQ5yR3RntZz1IOzHkyWWrBqHL+dCMk1djGjKD2w/ cadkRl8b9QdRMDShd4e8ji6ZM44RrDr5DaZoBADBZCiKrMoShbygsJBMtDTVNIH9fJ bZLFnSUNJJ1OTq/ZZO/TQSFP2yIjj3mZpxhQA4R/6qcuZYoCskfcc+6uDPI8/TywE6 Lw9m7KejLWOzndrIP8VeFBEQAs1J/S2f7h+Q5xNCBA33BVfctyyg2DNBGdTuErwq+U uoTiG3DLxRwoA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/22] mm/damon/core: copy struct-to-struct instead of field-to-field in damon_new_scheme() Date: Tue, 13 Sep 2022 17:44:30 +0000 Message-Id: <20220913174449.50645-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The function for new 'struct damos' creation, 'damon_new_scheme()', copies each field of the struct one by one, though it could simply copied via struct to struct. This commit replaces the unnecessarily verbose field-to-field copies with struct-to-struct copies to make code simple and short. Signed-off-by: SeongJae Park --- mm/damon/core.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index c21f5fe5928a..27e0c312f7a5 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -276,22 +276,13 @@ struct damos *damon_new_scheme(struct damos_access_pa= ttern *pattern, scheme =3D kmalloc(sizeof(*scheme), GFP_KERNEL); if (!scheme) return NULL; - scheme->pattern.min_sz_region =3D pattern->min_sz_region; - scheme->pattern.max_sz_region =3D pattern->max_sz_region; - scheme->pattern.min_nr_accesses =3D pattern->min_nr_accesses; - scheme->pattern.max_nr_accesses =3D pattern->max_nr_accesses; - scheme->pattern.min_age_region =3D pattern->min_age_region; - scheme->pattern.max_age_region =3D pattern->max_age_region; + scheme->pattern =3D *pattern; scheme->action =3D action; scheme->stat =3D (struct damos_stat){}; INIT_LIST_HEAD(&scheme->list); =20 - scheme->quota.ms =3D quota->ms; - scheme->quota.sz =3D quota->sz; - scheme->quota.reset_interval =3D quota->reset_interval; - scheme->quota.weight_sz =3D quota->weight_sz; - scheme->quota.weight_nr_accesses =3D quota->weight_nr_accesses; - scheme->quota.weight_age =3D quota->weight_age; + scheme->quota =3D *quota; + /* caller might not zero-initialized the private fileds */ scheme->quota.total_charged_sz =3D 0; scheme->quota.total_charged_ns =3D 0; scheme->quota.esz =3D 0; @@ -300,11 +291,7 @@ struct damos *damon_new_scheme(struct damos_access_pat= tern *pattern, scheme->quota.charge_target_from =3D NULL; scheme->quota.charge_addr_from =3D 0; =20 - scheme->wmarks.metric =3D wmarks->metric; - scheme->wmarks.interval =3D wmarks->interval; - scheme->wmarks.high =3D wmarks->high; - scheme->wmarks.mid =3D wmarks->mid; - scheme->wmarks.low =3D wmarks->low; + scheme->wmarks =3D *wmarks; scheme->wmarks.activated =3D true; =20 return scheme; --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3111BECAAD8 for ; Tue, 13 Sep 2022 18:27:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232635AbiIMS13 (ORCPT ); Tue, 13 Sep 2022 14:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbiIMS0u (ORCPT ); Tue, 13 Sep 2022 14:26:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A87FE4505C for ; Tue, 13 Sep 2022 10:44:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 95FA161546 for ; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A331C433B5; Tue, 13 Sep 2022 17:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091098; bh=vJRpVbuRNEWxiwJhtSxeIniDUyu+JoVCpD8GHbjL3iI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oa67jNZTl390H4yWs/1PtCmIDFSn0aIjc4wOuOXCSz50qUjEsDezOvqO40mBPvRBb JUqkSUSti/9RzAq9wIXpJ9bVY4V+KGnatsFN9xP62cAbc0b2R0l7y9232rPe/ehdi4 4diPT6xyF1GWkQxGDSKEvTnVsLMkMf4gIvMxMUWWFdAyzm9ad05f7365FDP5wyXYB2 t3XGfWvJlYcP231su+/HpzPF23arUhQ1wjp4YdxXPn6uta8Qb5L7ZheEYatfDBsBQb eNZJvCqQXW3ZwEqG21pchF6xekZzdau7IIzVqNBiLwPog0t5W/PxfU9QK/tgEdukdN zpRO4nyJerBOw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/22] mm/damon/core: factor out 'damos_quota' private fileds initialization Date: Tue, 13 Sep 2022 17:44:31 +0000 Message-Id: <20220913174449.50645-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The 'struct damos' creation function, 'damon_new_scheme()', does initialization of private fileds of 'struct damos_quota' in it. As its verbose and makes the function unnecessarily long, this commit factors it out to separate function. Signed-off-by: SeongJae Park --- mm/damon/core.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 27e0c312f7a5..6767580c0a27 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -267,6 +267,19 @@ int damon_set_regions(struct damon_target *t, struct d= amon_addr_range *ranges, return 0; } =20 +/* initialize private fields of damos_quota and return the pointer */ +static struct damos_quota *damos_quota_init_priv(struct damos_quota *quota) +{ + quota->total_charged_sz =3D 0; + quota->total_charged_ns =3D 0; + quota->esz =3D 0; + quota->charged_sz =3D 0; + quota->charged_from =3D 0; + quota->charge_target_from =3D NULL; + quota->charge_addr_from =3D 0; + return quota; +} + struct damos *damon_new_scheme(struct damos_access_pattern *pattern, enum damos_action action, struct damos_quota *quota, struct damos_watermarks *wmarks) @@ -281,15 +294,7 @@ struct damos *damon_new_scheme(struct damos_access_pat= tern *pattern, scheme->stat =3D (struct damos_stat){}; INIT_LIST_HEAD(&scheme->list); =20 - scheme->quota =3D *quota; - /* caller might not zero-initialized the private fileds */ - scheme->quota.total_charged_sz =3D 0; - scheme->quota.total_charged_ns =3D 0; - scheme->quota.esz =3D 0; - scheme->quota.charged_sz =3D 0; - scheme->quota.charged_from =3D 0; - scheme->quota.charge_target_from =3D NULL; - scheme->quota.charge_addr_from =3D 0; + scheme->quota =3D *(damos_quota_init_priv(quota)); =20 scheme->wmarks =3D *wmarks; scheme->wmarks.activated =3D true; --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C803CECAAD8 for ; Tue, 13 Sep 2022 18:27:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232696AbiIMS1i (ORCPT ); Tue, 13 Sep 2022 14:27:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232353AbiIMS0u (ORCPT ); Tue, 13 Sep 2022 14:26:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A96F848C85 for ; Tue, 13 Sep 2022 10:44:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 378506153C for ; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 372B1C43142; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091098; bh=NmwfN6rjHtuY0cGSf7TZTGlKmFrWA2cYVA41QNlR/mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y4SBKtFVloi7aHyiVt/VGkmApQhdA9O4SPaKa4oro1nPzJrYjcjQHOxeK6yRUdh/h 788AcjFDF9ERysE6ASER7jfwL1KMbwCD+qVljfPwskuYABnKGY5w+k2vMj3izd3NCi d5m+sW4ppjCbdaDx/fHvUjTdx1MXlDNcw8jG1cKidC39bZYg2napwAvyHsQQqWWhRW Sd5QA/aogI3AiExpbw1B8PzQ9py1HrKAYOGgEnGJGj+aDFMe4nOB3w42YATbdiATEE yDjt4qUcWFXWKas2AEIewEU3tu/Y5R40jgXCpCYSp0tDKJXOmq8Q5v/ZZsRQyaBoNL b840F7R8bMAng== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/22] mm/damon/core: use a dedicated struct for monitoring attributes Date: Tue, 13 Sep 2022 17:44:32 +0000 Message-Id: <20220913174449.50645-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" DAMON monitoring attributes are directly defined as fields of 'struct damon_ctx'. This makes 'struct damon_ctx' a little long and complicated. This commit defines and uses a struct, 'struct damon_attrs', which is dedicated for only the monitoring attributes to make the purpose of the five values clearer and simplify 'struct damon_ctx'. Signed-off-by: SeongJae Park --- include/linux/damon.h | 30 ++++++++++++++++++++---------- mm/damon/core.c | 34 +++++++++++++++++----------------- mm/damon/dbgfs.c | 6 +++--- mm/damon/ops-common.c | 4 ++-- mm/damon/vaddr.c | 4 ++-- 5 files changed, 44 insertions(+), 34 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 016b6c9c03d6..2ceee8b07726 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -389,13 +389,15 @@ struct damon_callback { }; =20 /** - * struct damon_ctx - Represents a context for each monitoring. This is t= he - * main interface that allows users to set the attributes and get the resu= lts - * of the monitoring. + * struct damon_attrs - Monitoring attributes for accuracy/overhead contro= l. * * @sample_interval: The time between access samplings. * @aggr_interval: The time between monitor results aggregations. * @ops_update_interval: The time between monitoring operations updates. + * @min_nr_regions: The minimum number of adaptive monitoring + * regions. + * @max_nr_regions: The maximum number of adaptive monitoring + * regions. * * For each @sample_interval, DAMON checks whether each region is accessed= or * not. It aggregates and keeps the access information (number of accesse= s to @@ -405,7 +407,21 @@ struct damon_callback { * @ops_update_interval. All time intervals are in micro-seconds. * Please refer to &struct damon_operations and &struct damon_callback for= more * detail. + */ +struct damon_attrs { + unsigned long sample_interval; + unsigned long aggr_interval; + unsigned long ops_update_interval; + unsigned long min_nr_regions; + unsigned long max_nr_regions; +}; + +/** + * struct damon_ctx - Represents a context for each monitoring. This is t= he + * main interface that allows users to set the attributes and get the resu= lts + * of the monitoring. * + * @attrs: Monitoring attributes for accuracy/overhead control. * @kdamond: Kernel thread who does the monitoring. * @kdamond_lock: Mutex for the synchronizations with @kdamond. * @@ -427,15 +443,11 @@ struct damon_callback { * @ops: Set of monitoring operations for given use cases. * @callback: Set of callbacks for monitoring events notifications. * - * @min_nr_regions: The minimum number of adaptive monitoring regions. - * @max_nr_regions: The maximum number of adaptive monitoring regions. * @adaptive_targets: Head of monitoring targets (&damon_target) list. * @schemes: Head of schemes (&damos) list. */ struct damon_ctx { - unsigned long sample_interval; - unsigned long aggr_interval; - unsigned long ops_update_interval; + struct damon_attrs attrs; =20 /* private: internal use only */ struct timespec64 last_aggregation; @@ -448,8 +460,6 @@ struct damon_ctx { struct damon_operations ops; struct damon_callback callback; =20 - unsigned long min_nr_regions; - unsigned long max_nr_regions; struct list_head adaptive_targets; struct list_head schemes; }; diff --git a/mm/damon/core.c b/mm/damon/core.c index 6767580c0a27..1f43ea9d956c 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -405,17 +405,17 @@ struct damon_ctx *damon_new_ctx(void) if (!ctx) return NULL; =20 - ctx->sample_interval =3D 5 * 1000; - ctx->aggr_interval =3D 100 * 1000; - ctx->ops_update_interval =3D 60 * 1000 * 1000; + ctx->attrs.sample_interval =3D 5 * 1000; + ctx->attrs.aggr_interval =3D 100 * 1000; + ctx->attrs.ops_update_interval =3D 60 * 1000 * 1000; =20 ktime_get_coarse_ts64(&ctx->last_aggregation); ctx->last_ops_update =3D ctx->last_aggregation; =20 mutex_init(&ctx->kdamond_lock); =20 - ctx->min_nr_regions =3D 10; - ctx->max_nr_regions =3D 1000; + ctx->attrs.min_nr_regions =3D 10; + ctx->attrs.max_nr_regions =3D 1000; =20 INIT_LIST_HEAD(&ctx->adaptive_targets); INIT_LIST_HEAD(&ctx->schemes); @@ -471,11 +471,11 @@ int damon_set_attrs(struct damon_ctx *ctx, unsigned l= ong sample_int, if (min_nr_reg > max_nr_reg) return -EINVAL; =20 - ctx->sample_interval =3D sample_int; - ctx->aggr_interval =3D aggr_int; - ctx->ops_update_interval =3D ops_upd_int; - ctx->min_nr_regions =3D min_nr_reg; - ctx->max_nr_regions =3D max_nr_reg; + ctx->attrs.sample_interval =3D sample_int; + ctx->attrs.aggr_interval =3D aggr_int; + ctx->attrs.ops_update_interval =3D ops_upd_int; + ctx->attrs.min_nr_regions =3D min_nr_reg; + ctx->attrs.max_nr_regions =3D max_nr_reg; =20 return 0; } @@ -530,8 +530,8 @@ static unsigned long damon_region_sz_limit(struct damon= _ctx *ctx) sz +=3D r->ar.end - r->ar.start; } =20 - if (ctx->min_nr_regions) - sz /=3D ctx->min_nr_regions; + if (ctx->attrs.min_nr_regions) + sz /=3D ctx->attrs.min_nr_regions; if (sz < DAMON_MIN_REGION) sz =3D DAMON_MIN_REGION; =20 @@ -680,7 +680,7 @@ static bool damon_check_reset_time_interval(struct time= spec64 *baseline, static bool kdamond_aggregate_interval_passed(struct damon_ctx *ctx) { return damon_check_reset_time_interval(&ctx->last_aggregation, - ctx->aggr_interval); + ctx->attrs.aggr_interval); } =20 /* @@ -1062,12 +1062,12 @@ static void kdamond_split_regions(struct damon_ctx = *ctx) damon_for_each_target(t, ctx) nr_regions +=3D damon_nr_regions(t); =20 - if (nr_regions > ctx->max_nr_regions / 2) + if (nr_regions > ctx->attrs.max_nr_regions / 2) return; =20 /* Maybe the middle of the region has different access frequency */ if (last_nr_regions =3D=3D nr_regions && - nr_regions < ctx->max_nr_regions / 3) + nr_regions < ctx->attrs.max_nr_regions / 3) nr_subregions =3D 3; =20 damon_for_each_target(t, ctx) @@ -1085,7 +1085,7 @@ static void kdamond_split_regions(struct damon_ctx *c= tx) static bool kdamond_need_update_operations(struct damon_ctx *ctx) { return damon_check_reset_time_interval(&ctx->last_ops_update, - ctx->ops_update_interval); + ctx->attrs.ops_update_interval); } =20 /* @@ -1229,7 +1229,7 @@ static int kdamond_fn(void *data) ctx->callback.after_sampling(ctx)) break; =20 - kdamond_usleep(ctx->sample_interval); + kdamond_usleep(ctx->attrs.sample_interval); =20 if (ctx->ops.check_accesses) max_nr_accesses =3D ctx->ops.check_accesses(ctx); diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index 1422037cedd2..74e7542af6d3 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -55,9 +55,9 @@ static ssize_t dbgfs_attrs_read(struct file *file, =20 mutex_lock(&ctx->kdamond_lock); ret =3D scnprintf(kbuf, ARRAY_SIZE(kbuf), "%lu %lu %lu %lu %lu\n", - ctx->sample_interval, ctx->aggr_interval, - ctx->ops_update_interval, ctx->min_nr_regions, - ctx->max_nr_regions); + ctx->attrs.sample_interval, ctx->attrs.aggr_interval, + ctx->attrs.ops_update_interval, + ctx->attrs.min_nr_regions, ctx->attrs.max_nr_regions); mutex_unlock(&ctx->kdamond_lock); =20 return simple_read_from_buffer(buf, count, ppos, kbuf, ret); diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index f599838b5f64..9310df72e1c5 100644 --- a/mm/damon/ops-common.c +++ b/mm/damon/ops-common.c @@ -99,10 +99,10 @@ int damon_hot_score(struct damon_ctx *c, struct damon_r= egion *r, unsigned int age_weight =3D s->quota.weight_age; int hotness; =20 - max_nr_accesses =3D c->aggr_interval / c->sample_interval; + max_nr_accesses =3D c->attrs.aggr_interval / c->attrs.sample_interval; freq_subscore =3D r->nr_accesses * DAMON_MAX_SUBSCORE / max_nr_accesses; =20 - age_in_sec =3D (unsigned long)r->age * c->aggr_interval / 1000000; + age_in_sec =3D (unsigned long)r->age * c->attrs.aggr_interval / 1000000; for (age_in_log =3D 0; age_in_log < DAMON_MAX_AGE_IN_LOG && age_in_sec; age_in_log++, age_in_sec >>=3D 1) ; diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 39ea48d9cc15..3f84584f9982 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -251,8 +251,8 @@ static void __damon_va_init_regions(struct damon_ctx *c= tx, =20 for (i =3D 0; i < 3; i++) sz +=3D regions[i].end - regions[i].start; - if (ctx->min_nr_regions) - sz /=3D ctx->min_nr_regions; + if (ctx->attrs.min_nr_regions) + sz /=3D ctx->attrs.min_nr_regions; if (sz < DAMON_MIN_REGION) sz =3D DAMON_MIN_REGION; =20 --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AFD2C54EE9 for ; Tue, 13 Sep 2022 18:27:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232711AbiIMS1n (ORCPT ); Tue, 13 Sep 2022 14:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230194AbiIMS0v (ORCPT ); Tue, 13 Sep 2022 14:26:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E7E05A892 for ; Tue, 13 Sep 2022 10:45:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7083D61548 for ; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D303CC433D7; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091099; bh=c3UYaFklJ4IkklkRS/0v+7Mz4UKLXpTsJ9YYL0g2LqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jtvTIxy7OnysXwf/omjA/JoG6upB+Jyt+XBlqrSnddezs7pp/rSW39R6eoTLcbsqU uk52UePf1qOHcxJKzZHrU3UvlGlBTLDhkieL8vMfIB2N0S8gKGmkX6fkABKbTVB1Vj jfDbradKvvSm5mH6JErdjo7/tRL+LYqXCDTSO8tgN4BY8eG5xvyux17S0jPXu4awq5 pDWnWET8pfClirlz6ON4xEYC6bmgyQHxQuVmlz2Vkes2AeBqJ/qyM6xQgrX9r92FSU M/Vkzwm6168kmlq6LlnOpDtQhQX1Q6yrC4Rel+bN3Jr4TKowvbFt28NcSMlRqrFC/+ k9rlzenfG6DpA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/22] mm/damon/core: reduce parameters for damon_set_attrs() Date: Tue, 13 Sep 2022 17:44:33 +0000 Message-Id: <20220913174449.50645-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Number of parameters for 'damon_set_attrs()' is six. As it could be confusing and verbose, this commit reduces the number by receiving single pointer to a 'struct damon_attrs'. Signed-off-by: SeongJae Park --- include/linux/damon.h | 4 +--- mm/damon/core.c | 21 +++++---------------- mm/damon/dbgfs.c | 9 ++++++--- mm/damon/lru_sort.c | 10 ++++++++-- mm/damon/reclaim.c | 10 ++++++++-- mm/damon/sysfs.c | 12 ++++++++---- 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 2ceee8b07726..c5dc0c77c772 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -540,9 +540,7 @@ unsigned int damon_nr_regions(struct damon_target *t); =20 struct damon_ctx *damon_new_ctx(void); void damon_destroy_ctx(struct damon_ctx *ctx); -int damon_set_attrs(struct damon_ctx *ctx, unsigned long sample_int, - unsigned long aggr_int, unsigned long ops_upd_int, - unsigned long min_nr_reg, unsigned long max_nr_reg); +int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs); int damon_set_schemes(struct damon_ctx *ctx, struct damos **schemes, ssize_t nr_schemes); int damon_nr_running_ctxs(void); diff --git a/mm/damon/core.c b/mm/damon/core.c index 1f43ea9d956c..d9d1bebc6a78 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -451,32 +451,21 @@ void damon_destroy_ctx(struct damon_ctx *ctx) /** * damon_set_attrs() - Set attributes for the monitoring. * @ctx: monitoring context - * @sample_int: time interval between samplings - * @aggr_int: time interval between aggregations - * @ops_upd_int: time interval between monitoring operations updates - * @min_nr_reg: minimal number of regions - * @max_nr_reg: maximum number of regions + * @attrs: monitoring attributes * * This function should not be called while the kdamond is running. * Every time interval is in micro-seconds. * * Return: 0 on success, negative error code otherwise. */ -int damon_set_attrs(struct damon_ctx *ctx, unsigned long sample_int, - unsigned long aggr_int, unsigned long ops_upd_int, - unsigned long min_nr_reg, unsigned long max_nr_reg) +int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs) { - if (min_nr_reg < 3) + if (attrs->min_nr_regions < 3) return -EINVAL; - if (min_nr_reg > max_nr_reg) + if (attrs->min_nr_regions > attrs->max_nr_regions) return -EINVAL; =20 - ctx->attrs.sample_interval =3D sample_int; - ctx->attrs.aggr_interval =3D aggr_int; - ctx->attrs.ops_update_interval =3D ops_upd_int; - ctx->attrs.min_nr_regions =3D min_nr_reg; - ctx->attrs.max_nr_regions =3D max_nr_reg; - + ctx->attrs =3D *attrs; return 0; } =20 diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index 74e7542af6d3..c00eba4448d8 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -67,7 +67,7 @@ static ssize_t dbgfs_attrs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct damon_ctx *ctx =3D file->private_data; - unsigned long s, a, r, minr, maxr; + struct damon_attrs attrs; char *kbuf; ssize_t ret; =20 @@ -76,7 +76,10 @@ static ssize_t dbgfs_attrs_write(struct file *file, return PTR_ERR(kbuf); =20 if (sscanf(kbuf, "%lu %lu %lu %lu %lu", - &s, &a, &r, &minr, &maxr) !=3D 5) { + &attrs.sample_interval, &attrs.aggr_interval, + &attrs.ops_update_interval, + &attrs.min_nr_regions, + &attrs.max_nr_regions) !=3D 5) { ret =3D -EINVAL; goto out; } @@ -87,7 +90,7 @@ static ssize_t dbgfs_attrs_write(struct file *file, goto unlock_out; } =20 - ret =3D damon_set_attrs(ctx, s, a, r, minr, maxr); + ret =3D damon_set_attrs(ctx, &attrs); if (!ret) ret =3D count; unlock_out: diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 307ba71adcfa..6d5f83965276 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -350,13 +350,19 @@ static struct damos *damon_lru_sort_new_cold_scheme(u= nsigned int cold_thres) =20 static int damon_lru_sort_apply_parameters(void) { + struct damon_attrs attrs =3D { + .sample_interval =3D sample_interval, + .aggr_interval =3D aggr_interval, + .ops_update_interval =3D 0, + .min_nr_regions =3D min_nr_regions, + .max_nr_regions =3D max_nr_regions, + }; struct damos *scheme; struct damon_addr_range addr_range; unsigned int hot_thres, cold_thres; int err =3D 0; =20 - err =3D damon_set_attrs(ctx, sample_interval, aggr_interval, 0, - min_nr_regions, max_nr_regions); + err =3D damon_set_attrs(ctx, &attrs); if (err) return err; =20 diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index fe7bc0c55ecb..bc841efbab45 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -275,12 +275,18 @@ static struct damos *damon_reclaim_new_scheme(void) =20 static int damon_reclaim_apply_parameters(void) { + struct damon_attrs attrs =3D { + .sample_interval =3D sample_interval, + .aggr_interval =3D aggr_interval, + .ops_update_interval =3D 0, + .min_nr_regions =3D min_nr_regions, + .max_nr_regions =3D max_nr_regions, + }; struct damos *scheme; struct damon_addr_range addr_range; int err =3D 0; =20 - err =3D damon_set_attrs(ctx, sample_interval, aggr_interval, 0, - min_nr_regions, max_nr_regions); + err =3D damon_set_attrs(ctx, &attrs); if (err) return err; =20 diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 3606eec9b65d..1fa0023f136e 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2130,10 +2130,14 @@ static int damon_sysfs_set_attrs(struct damon_ctx *= ctx, struct damon_sysfs_intervals *sys_intervals =3D sys_attrs->intervals; struct damon_sysfs_ul_range *sys_nr_regions =3D sys_attrs->nr_regions_range; - - return damon_set_attrs(ctx, sys_intervals->sample_us, - sys_intervals->aggr_us, sys_intervals->update_us, - sys_nr_regions->min, sys_nr_regions->max); + struct damon_attrs attrs =3D { + .sample_interval =3D sys_intervals->sample_us, + .aggr_interval =3D sys_intervals->aggr_us, + .ops_update_interval =3D sys_intervals->update_us, + .min_nr_regions =3D sys_nr_regions->min, + .max_nr_regions =3D sys_nr_regions->max, + }; + return damon_set_attrs(ctx, &attrs); } =20 static void damon_sysfs_destroy_targets(struct damon_ctx *ctx) --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 175E2ECAAD8 for ; Tue, 13 Sep 2022 18:27:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232743AbiIMS1r (ORCPT ); Tue, 13 Sep 2022 14:27:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232211AbiIMS0w (ORCPT ); Tue, 13 Sep 2022 14:26:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C6545FAE7 for ; Tue, 13 Sep 2022 10:45:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0CB756154D for ; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 797F2C43144; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091099; bh=weWy/2YvUWIofhX6Yg4PxkLbauvFc1P8+Pog3c5HCQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNWe89E2W4HG4Qc4c5ym3tC6m8DqT09MtflLX5NQn2wKg99VI2QxGhRhr1dGRcNtB yCkIWEvTXjvuIEgtgIeuN5D+7ejYSNd1T1nM9ISx0Y7Mf8BpzMtWFJzxUHgotwZ1GF eC53jZPOZvrnVL6UE10nsoX8Vm/R6zMn435XDwdHYO/WCljc2omiMuCADFWLZKnTCp oM5R6qmKYlTOZ+4h63qyc2v4afrw5GYHOA4urdD28HAOZisRSPjJ31oosApurqCj9F v7h6fVDLGvANvAowyLhgNI/h1MZG9dahfv+8+2eTQ06+I2V2GsOH73fxM5BrdR2KFM opUKzr6qZHerA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/22] mm/damon/reclaim: use 'struct damon_attrs' for storing parameters for it Date: Tue, 13 Sep 2022 17:44:34 +0000 Message-Id: <20220913174449.50645-8-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" DAMON_RECLAIM receives monitoring attributes by parameters one by one to separate variables, and then combine those into 'struct damon_attrs'. This commit makes the module directly stores the parameter values to a static 'struct damon_attrs' variable and use it to simplify the code. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index bc841efbab45..d35a00d8dde2 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -129,14 +129,22 @@ module_param(wmarks_mid, ulong, 0600); static unsigned long wmarks_low __read_mostly =3D 200; module_param(wmarks_low, ulong, 0600); =20 +static struct damon_attrs damon_reclaim_mon_attrs =3D { + .sample_interval =3D 5000, + .aggr_interval =3D 100000, + .ops_update_interval =3D 0, + .min_nr_regions =3D 10, + .max_nr_regions =3D 1000, +}; + /* * Sampling interval for the monitoring in microseconds. * * The sampling interval of DAMON for the cold memory monitoring. Please = refer * to the DAMON documentation for more detail. 5 ms by default. */ -static unsigned long sample_interval __read_mostly =3D 5000; -module_param(sample_interval, ulong, 0600); +module_param_named(sample_interval, damon_reclaim_mon_attrs.sample_interva= l, + ulong, 0600); =20 /* * Aggregation interval for the monitoring in microseconds. @@ -144,8 +152,8 @@ module_param(sample_interval, ulong, 0600); * The aggregation interval of DAMON for the cold memory monitoring. Plea= se * refer to the DAMON documentation for more detail. 100 ms by default. */ -static unsigned long aggr_interval __read_mostly =3D 100000; -module_param(aggr_interval, ulong, 0600); +module_param_named(aggr_interval, damon_reclaim_mon_attrs.aggr_interval, u= long, + 0600); =20 /* * Minimum number of monitoring regions. @@ -155,8 +163,8 @@ module_param(aggr_interval, ulong, 0600); * But, setting this too high could result in increased monitoring overhea= d. * Please refer to the DAMON documentation for more detail. 10 by default. */ -static unsigned long min_nr_regions __read_mostly =3D 10; -module_param(min_nr_regions, ulong, 0600); +module_param_named(min_nr_regions, damon_reclaim_mon_attrs.min_nr_regions, + ulong, 0600); =20 /* * Maximum number of monitoring regions. @@ -166,8 +174,8 @@ module_param(min_nr_regions, ulong, 0600); * However, setting this too low could result in bad monitoring quality. * Please refer to the DAMON documentation for more detail. 1000 by defau= lt. */ -static unsigned long max_nr_regions __read_mostly =3D 1000; -module_param(max_nr_regions, ulong, 0600); +module_param_named(max_nr_regions, damon_reclaim_mon_attrs.max_nr_regions, + ulong, 0600); =20 /* * Start of the target memory region in physical address. @@ -239,7 +247,8 @@ static struct damos *damon_reclaim_new_scheme(void) .min_nr_accesses =3D 0, .max_nr_accesses =3D 0, /* for min_age or more micro-seconds */ - .min_age_region =3D min_age / aggr_interval, + .min_age_region =3D min_age / + damon_reclaim_mon_attrs.aggr_interval, .max_age_region =3D UINT_MAX, }; struct damos_watermarks wmarks =3D { @@ -275,18 +284,11 @@ static struct damos *damon_reclaim_new_scheme(void) =20 static int damon_reclaim_apply_parameters(void) { - struct damon_attrs attrs =3D { - .sample_interval =3D sample_interval, - .aggr_interval =3D aggr_interval, - .ops_update_interval =3D 0, - .min_nr_regions =3D min_nr_regions, - .max_nr_regions =3D max_nr_regions, - }; struct damos *scheme; struct damon_addr_range addr_range; int err =3D 0; =20 - err =3D damon_set_attrs(ctx, &attrs); + err =3D damon_set_attrs(ctx, &damon_reclaim_mon_attrs); if (err) return err; =20 --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A46D2C54EE9 for ; Tue, 13 Sep 2022 18:27:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232763AbiIMS1v (ORCPT ); Tue, 13 Sep 2022 14:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbiIMS0x (ORCPT ); Tue, 13 Sep 2022 14:26:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D3525FF77 for ; Tue, 13 Sep 2022 10:45:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9FED161551 for ; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 165DDC433B5; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091100; bh=t9hexQZJ8425+LB2Nnk1GDKOCK+nsv8kErzuC6jdjaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TzARBjc+b2EGph+GmNC6Uuaf+rE6285m8cIpolJIwlcgLD4RYkhT8rjd/UNjWXNyX kL6NPs3+Mvkqla410Y6Wg9HpYE9Wz5TsIrtegel/6wmVc9yhuNSprDlUazn97gUQFQ 5+QNIpfdHLk8vCrrXanRAU9ng/6v36aJhiYXfNdmpWEtg/kwCBZ+5iNvL/mWFDD/9m 7QjA+mT+1iRHREfBbXvWwWxBlYQZ5TCgl62KKns7DjJkK/iGonvXbyEzfnq7EyO5ho Dnvy+93O6xEpLNnEasEnxiX1uuo0tpqchbKEd+5eSN2nOsX+wOsH2SKE+Yg7kgx+t8 9Hu065mtEuOPg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/22] mm/damon/lru_sort: use 'struct damon_attrs' for storing parameters for it Date: Tue, 13 Sep 2022 17:44:35 +0000 Message-Id: <20220913174449.50645-9-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" DAMON_LRU_SORT receives monitoring attributes by parameters one by one to separate variables, and then combines those into 'struct damon_attrs'. This commit makes the module directly stores the parameter values to a static 'struct damon_attrs' variable and use it to simplify the code. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 6d5f83965276..ade985b83652 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -127,14 +127,22 @@ module_param(wmarks_mid, ulong, 0600); static unsigned long wmarks_low __read_mostly =3D 50; module_param(wmarks_low, ulong, 0600); =20 +static struct damon_attrs damon_lru_sort_mon_attrs =3D { + .sample_interval =3D 5000, + .aggr_interval =3D 100000, + .ops_update_interval =3D 0, + .min_nr_regions =3D 10, + .max_nr_regions =3D 1000, +}; + /* * Sampling interval for the monitoring in microseconds. * * The sampling interval of DAMON for the hot/cold memory monitoring. Ple= ase * refer to the DAMON documentation for more detail. 5 ms by default. */ -static unsigned long sample_interval __read_mostly =3D 5000; -module_param(sample_interval, ulong, 0600); +module_param_named(sample_interval, damon_lru_sort_mon_attrs.sample_interv= al, + ulong, 0600); =20 /* * Aggregation interval for the monitoring in microseconds. @@ -142,8 +150,8 @@ module_param(sample_interval, ulong, 0600); * The aggregation interval of DAMON for the hot/cold memory monitoring. * Please refer to the DAMON documentation for more detail. 100 ms by def= ault. */ -static unsigned long aggr_interval __read_mostly =3D 100000; -module_param(aggr_interval, ulong, 0600); +module_param_named(aggr_interval, damon_lru_sort_mon_attrs.aggr_interval, = ulong, + 0600); =20 /* * Minimum number of monitoring regions. @@ -153,8 +161,8 @@ module_param(aggr_interval, ulong, 0600); * But, setting this too high could result in increased monitoring overhea= d. * Please refer to the DAMON documentation for more detail. 10 by default. */ -static unsigned long min_nr_regions __read_mostly =3D 10; -module_param(min_nr_regions, ulong, 0600); +module_param_named(min_nr_regions, damon_lru_sort_mon_attrs.min_nr_regions, + ulong, 0600); =20 /* * Maximum number of monitoring regions. @@ -164,8 +172,8 @@ module_param(min_nr_regions, ulong, 0600); * However, setting this too low could result in bad monitoring quality. * Please refer to the DAMON documentation for more detail. 1000 by defau= lt. */ -static unsigned long max_nr_regions __read_mostly =3D 1000; -module_param(max_nr_regions, ulong, 0600); +module_param_named(max_nr_regions, damon_lru_sort_mon_attrs.max_nr_regions, + ulong, 0600); =20 /* * Start of the target memory region in physical address. @@ -350,25 +358,19 @@ static struct damos *damon_lru_sort_new_cold_scheme(u= nsigned int cold_thres) =20 static int damon_lru_sort_apply_parameters(void) { - struct damon_attrs attrs =3D { - .sample_interval =3D sample_interval, - .aggr_interval =3D aggr_interval, - .ops_update_interval =3D 0, - .min_nr_regions =3D min_nr_regions, - .max_nr_regions =3D max_nr_regions, - }; struct damos *scheme; struct damon_addr_range addr_range; unsigned int hot_thres, cold_thres; int err =3D 0; =20 - err =3D damon_set_attrs(ctx, &attrs); + err =3D damon_set_attrs(ctx, &damon_lru_sort_mon_attrs); if (err) return err; =20 /* aggr_interval / sample_interval is the maximum nr_accesses */ - hot_thres =3D aggr_interval / sample_interval * hot_thres_access_freq / - 1000; + hot_thres =3D damon_lru_sort_mon_attrs.aggr_interval / + damon_lru_sort_mon_attrs.sample_interval * + hot_thres_access_freq / 1000; scheme =3D damon_lru_sort_new_hot_scheme(hot_thres); if (!scheme) return -ENOMEM; @@ -376,7 +378,7 @@ static int damon_lru_sort_apply_parameters(void) if (err) return err; =20 - cold_thres =3D cold_min_age / aggr_interval; + cold_thres =3D cold_min_age / damon_lru_sort_mon_attrs.aggr_interval; scheme =3D damon_lru_sort_new_cold_scheme(cold_thres); if (!scheme) return -ENOMEM; --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EEC9C54EE9 for ; Tue, 13 Sep 2022 18:28:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232795AbiIMS2H (ORCPT ); Tue, 13 Sep 2022 14:28:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230424AbiIMS05 (ORCPT ); Tue, 13 Sep 2022 14:26:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F37C1659C5 for ; Tue, 13 Sep 2022 10:45:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 415C6B80CBC for ; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A92E0C43142; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091101; bh=kK1sxLOXEkaoDNnV++Rope2Ec8RZDVijxu5erLk09sQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bdVSywTxsq0Xeh3ZASYyycbEgiYJiKaQ5ta5McLxvRu2AiXwWQowXtIqqKC41LuQw hNgbHrDkc2xHScq2yRGwn6raCF4mMNpeuEtyZd4GNyM1cuxyYgOG5mgrURSS4LNa8D IK+Ip4ztkqRC7f8WiHYYRDMxavuASn6po6rLCFsQuPVfL7U/D40W7VsMfLMcCT6rjp Pie2gHvvQwJBFQq4xoJaJ6J5hEuuMj7Nn3eTT1yiN1/HuRhLEdLX5ZLyQPMDwAXDcO PHWGYlKXvIW2ZUztbr9nMwaqDBkUGZuq57AAB7uZrwRhk/K5KawdsTv8P/lpsXOSZm Sez7g0v2A+9Mg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: linux-kernel@vger.kernel.org, damon@lists.linux.dev, linux-mm@kvack.org Subject: [PATCH 09/22] mm/damon: implement a monitoring attributes module parameters generator macro Date: Tue, 13 Sep 2022 17:44:36 +0000 Message-Id: <20220913174449.50645-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" DAMON_RECLAIM and DAMON_LRU_SORT have module parameters for monitoring attributes that having same names. This commot implements a macro for generating such module parameters so that we can reuse later. Signed-off-by: SeongJae Park --- mm/damon/modules-common.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 mm/damon/modules-common.h diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h new file mode 100644 index 000000000000..0abd0636bc64 --- /dev/null +++ b/mm/damon/modules-common.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Common Primitives for DAMON Modules + * + * Author: SeongJae Park + */ + +#include + +#define DEFINE_DAMON_MODULES_MON_ATTRS_PARAMS(attrs) \ + module_param_named(sample_interval, attrs.sample_interval, \ + ulong, 0600); \ + module_param_named(aggr_interval, attrs.aggr_interval, ulong, \ + 0600); \ + module_param_named(min_nr_regions, attrs.min_nr_regions, ulong, \ + 0600); \ + module_param_named(max_nr_regions, attrs.max_nr_regions, ulong, \ + 0600); --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD0F7ECAAD8 for ; Tue, 13 Sep 2022 18:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231966AbiIMS2Q (ORCPT ); Tue, 13 Sep 2022 14:28:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232569AbiIMS07 (ORCPT ); Tue, 13 Sep 2022 14:26:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D15D9659E9 for ; Tue, 13 Sep 2022 10:45:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E2CD7B80DCB for ; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41D7BC43140; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091101; bh=ucRX7WkVCPXQIajil5D7e+L59pOLx2Mv/t/yKy7/hEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QBYnta/2AGgdSUfUisgCHWC65vMnHRWb5HvI3ucabhjRnXgU4A+2diqOC1pIausW/ 6hEar6RKEs6hAvo8D83Nq3z0u/51qnxVOo7kcMsDkgcLgzAVCWpsrdBeJynm7a6TTa k3mAQdnT0J0dNNB76+y4Rr1J7IaWHJL0cYNZ9zmipXrbWx0BLJBkh1LvAxAP6eH0J1 I+hCklmdP67C89sHRL0yL+gJ8zZuKb4xScKrmLNfOj6bsHukkVVEu/xRwGyXd7Dgid xUAarQyc6+MDXpxIDgG8PetXTzp2NqGDhUSladDw6OmX5df7xqI0fTRbMiYgKtd8VF tuGJxth1fI8+A== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/22] mm/damon/lru_sort: use monitoring attributes parameters generaotr macro Date: Tue, 13 Sep 2022 17:44:37 +0000 Message-Id: <20220913174449.50645-11-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit makes DAMON_LRU_SORT to generate the module parameters for DAMON monitoring attributes using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 47 +++++---------------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index ade985b83652..e95626acee6f 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -13,6 +13,8 @@ #include #include =20 +#include "modules-common.h" + #ifdef MODULE_PARAM_PREFIX #undef MODULE_PARAM_PREFIX #endif @@ -128,52 +130,13 @@ static unsigned long wmarks_low __read_mostly =3D 50; module_param(wmarks_low, ulong, 0600); =20 static struct damon_attrs damon_lru_sort_mon_attrs =3D { - .sample_interval =3D 5000, - .aggr_interval =3D 100000, + .sample_interval =3D 5000, /* 5 ms */ + .aggr_interval =3D 100000, /* 100 ms */ .ops_update_interval =3D 0, .min_nr_regions =3D 10, .max_nr_regions =3D 1000, }; - -/* - * Sampling interval for the monitoring in microseconds. - * - * The sampling interval of DAMON for the hot/cold memory monitoring. Ple= ase - * refer to the DAMON documentation for more detail. 5 ms by default. - */ -module_param_named(sample_interval, damon_lru_sort_mon_attrs.sample_interv= al, - ulong, 0600); - -/* - * Aggregation interval for the monitoring in microseconds. - * - * The aggregation interval of DAMON for the hot/cold memory monitoring. - * Please refer to the DAMON documentation for more detail. 100 ms by def= ault. - */ -module_param_named(aggr_interval, damon_lru_sort_mon_attrs.aggr_interval, = ulong, - 0600); - -/* - * Minimum number of monitoring regions. - * - * The minimal number of monitoring regions of DAMON for the hot/cold memo= ry - * monitoring. This can be used to set lower-bound of the monitoring qual= ity. - * But, setting this too high could result in increased monitoring overhea= d. - * Please refer to the DAMON documentation for more detail. 10 by default. - */ -module_param_named(min_nr_regions, damon_lru_sort_mon_attrs.min_nr_regions, - ulong, 0600); - -/* - * Maximum number of monitoring regions. - * - * The maximum number of monitoring regions of DAMON for the hot/cold memo= ry - * monitoring. This can be used to set upper-bound of the monitoring over= head. - * However, setting this too low could result in bad monitoring quality. - * Please refer to the DAMON documentation for more detail. 1000 by defau= lt. - */ -module_param_named(max_nr_regions, damon_lru_sort_mon_attrs.max_nr_regions, - ulong, 0600); +DEFINE_DAMON_MODULES_MON_ATTRS_PARAMS(damon_lru_sort_mon_attrs); =20 /* * Start of the target memory region in physical address. --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF31AC54EE9 for ; Tue, 13 Sep 2022 18:28:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231788AbiIMS15 (ORCPT ); Tue, 13 Sep 2022 14:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232525AbiIMS05 (ORCPT ); Tue, 13 Sep 2022 14:26:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3A49659C6 for ; Tue, 13 Sep 2022 10:45:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CD0A161510 for ; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2B54C433B5; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091102; bh=tFHqJ7jOLkswItslmys2QZPPIVwL8A4ty4xh6NVyqHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n/pdAxwMLzIzYIksGQm4SyVLptPt/nnH0sfzxQE0+Ffb/7fpqjSXYyhwhbH+4gs7t 8clwtJj+BeQ4Yb2yUI/L1xRJDF8ZxVo3dTgElUIoI5bnLu3gk41K2K2yOfqbn83xAD DWlQWRGkQrjL/4Q8IX8kIlf5T79Tk85FnP1Ya0TD8F/LAzEwZXwUjaObqLX/TZNfqo vu6iHJ93TI2ff5psq0lb3AiDe0+iNQ/GKgp4pGEvHURGqMewVSlRFWGmdosCsGJJcs +B+b0niFN7O3V92JW9XJRG6rxCyDzfnO0pv+8RDIGjwNafaw68EhVrhr3UvkGn80Hd KDizRAi/BxTJw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/22] mm/damon/reclaim: use monitoring attributes parameters generator macro Date: Tue, 13 Sep 2022 17:44:38 +0000 Message-Id: <20220913174449.50645-12-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit makes DAMON_RECLAIM to generate the module parameters for DAMON monitoring attributes using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 47 +++++----------------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index d35a00d8dde2..48326bef20f5 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -13,6 +13,8 @@ #include #include =20 +#include "modules-common.h" + #ifdef MODULE_PARAM_PREFIX #undef MODULE_PARAM_PREFIX #endif @@ -130,52 +132,13 @@ static unsigned long wmarks_low __read_mostly =3D 200; module_param(wmarks_low, ulong, 0600); =20 static struct damon_attrs damon_reclaim_mon_attrs =3D { - .sample_interval =3D 5000, - .aggr_interval =3D 100000, + .sample_interval =3D 5000, /* 5 ms */ + .aggr_interval =3D 100000, /* 100 ms */ .ops_update_interval =3D 0, .min_nr_regions =3D 10, .max_nr_regions =3D 1000, }; - -/* - * Sampling interval for the monitoring in microseconds. - * - * The sampling interval of DAMON for the cold memory monitoring. Please = refer - * to the DAMON documentation for more detail. 5 ms by default. - */ -module_param_named(sample_interval, damon_reclaim_mon_attrs.sample_interva= l, - ulong, 0600); - -/* - * Aggregation interval for the monitoring in microseconds. - * - * The aggregation interval of DAMON for the cold memory monitoring. Plea= se - * refer to the DAMON documentation for more detail. 100 ms by default. - */ -module_param_named(aggr_interval, damon_reclaim_mon_attrs.aggr_interval, u= long, - 0600); - -/* - * Minimum number of monitoring regions. - * - * The minimal number of monitoring regions of DAMON for the cold memory - * monitoring. This can be used to set lower-bound of the monitoring qual= ity. - * But, setting this too high could result in increased monitoring overhea= d. - * Please refer to the DAMON documentation for more detail. 10 by default. - */ -module_param_named(min_nr_regions, damon_reclaim_mon_attrs.min_nr_regions, - ulong, 0600); - -/* - * Maximum number of monitoring regions. - * - * The maximum number of monitoring regions of DAMON for the cold memory - * monitoring. This can be used to set upper-bound of the monitoring over= head. - * However, setting this too low could result in bad monitoring quality. - * Please refer to the DAMON documentation for more detail. 1000 by defau= lt. - */ -module_param_named(max_nr_regions, damon_reclaim_mon_attrs.max_nr_regions, - ulong, 0600); +DEFINE_DAMON_MODULES_MON_ATTRS_PARAMS(damon_reclaim_mon_attrs); =20 /* * Start of the target memory region in physical address. --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12C49ECAAD8 for ; Tue, 13 Sep 2022 18:28:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232808AbiIMS2L (ORCPT ); Tue, 13 Sep 2022 14:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232538AbiIMS07 (ORCPT ); Tue, 13 Sep 2022 14:26:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A0496B15E for ; Tue, 13 Sep 2022 10:45:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0A7EDB81095 for ; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7202BC43150; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091102; bh=w3PmzI3eXAtMjTvuW+AZdIXWuI7edjAfsNckFtn3Io4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d+gTc8Q3zvNURan9GfDYXpMFt0z7EM7ZU4Rk7rB6CF4TVUZ9u0lOC9R/mnSsqr1rU R09efwl3daVaFAsKHd+OnmT6ETvV0PMjyb4ottR6blkea3JwhH7siUgh+ef1mPMkU4 EKaFrbCBRaCJZXOHM29xOnmuI+YeeF34swnPisfOy1yL6mT6wVb1wKUEh4oXq34IwI eLdb6WfOc5+5tc+sbCgWEYV4dgsETv9WG00qb3xBPewMoB8T/VL0hZF3QnKA2oMvFA 6vRLl+ewWOzfgDKb1A4WAfcd+sFizn3ILxbC4f+DqYoawhNS02fcOoxPe0EIvzMD4/ jGRysRwAE1RFg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/22] mm/damon/modules-common: implement a watermarks module parameters generator macro Date: Tue, 13 Sep 2022 17:44:39 +0000 Message-Id: <20220913174449.50645-13-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" DAMON_RECLAIM and DAMON_LRU_SORT have module parameters for watermarks that having same names. This commit implements a macro for generating such module parameters so that we can reuse later. Signed-off-by: SeongJae Park --- mm/damon/modules-common.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index 0abd0636bc64..1370590a37d1 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -16,3 +16,10 @@ 0600); \ module_param_named(max_nr_regions, attrs.max_nr_regions, ulong, \ 0600); + +#define DEFINE_DAMON_MODULES_WMARKS_PARAMS(wmarks) \ + module_param_named(wmarks_interval, wmarks->interval, ulong, \ + 0600); \ + module_param_named(wmarks_high, wmarks.high, ulong, 0600); \ + module_param_named(wmarks_mid, wmarks.mid, ulong, 0600); \ + module_param_named(wmarks_low, wmarks.lowulong, 0600); --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AD72ECAAD8 for ; Tue, 13 Sep 2022 18:28:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232021AbiIMS2a (ORCPT ); Tue, 13 Sep 2022 14:28:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231915AbiIMS1D (ORCPT ); Tue, 13 Sep 2022 14:27:03 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E90B59262 for ; Tue, 13 Sep 2022 10:45:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 4978ECE1340 for ; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A7E9C43151; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091103; bh=EUuPVZLbnXd6SBFdDW4wKU/+gayhFIMwTcrg4+QxxWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JpUlnHdc26OPTg1yxMTXlAowNfl6YjCTuoTtN5FJ4KAKQb/tSBSm7kdH+sEMY9BvA qPxha3Saj5x3ct+8eiJHNju+ktvYbENaL7OLwQJ41lIHCNNOiKVPt36D6IAzDL6+P6 hMrnE5iJVW/z14sf/fqJnvD6hIBusVincW6EebBKMWKdFsPSvKKU7AXm8xNH3uj17g wWfW3p5Z+lHIY+sH1zlQa2omZPbPxlTl436USYWCDdo7S403sapHLQ94HerP8okiOr RN5OuNBhtk72du/6Q4K4nriCge71KpxuN2NYpXsqfKY9OCAS8dey9FS1w6XsOcjL7Y n8JTBGkcjUNAw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/22] mm/damon/lru_sort: use watermarks parameters generator macro Date: Tue, 13 Sep 2022 17:44:40 +0000 Message-Id: <20220913174449.50645-14-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit makes DAMON_LRU_SORT to generate the module parameters for DAMOS watermarks using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 64 ++++++--------------------------------- mm/damon/modules-common.h | 4 +-- 2 files changed, 12 insertions(+), 56 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index e95626acee6f..20760b39b50a 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -90,44 +90,14 @@ module_param(quota_ms, ulong, 0600); static unsigned long quota_reset_interval_ms __read_mostly =3D 1000; module_param(quota_reset_interval_ms, ulong, 0600); =20 -/* - * The watermarks check time interval in microseconds. - * - * Minimal time to wait before checking the watermarks, when DAMON_LRU_SOR= T is - * enabled but inactive due to its watermarks rule. 5 seconds by default. - */ -static unsigned long wmarks_interval __read_mostly =3D 5000000; -module_param(wmarks_interval, ulong, 0600); - -/* - * Free memory rate (per thousand) for the high watermark. - * - * If free memory of the system in bytes per thousand bytes is higher than - * this, DAMON_LRU_SORT becomes inactive, so it does nothing but periodica= lly - * checks the watermarks. 200 (20%) by default. - */ -static unsigned long wmarks_high __read_mostly =3D 200; -module_param(wmarks_high, ulong, 0600); - -/* - * Free memory rate (per thousand) for the middle watermark. - * - * If free memory of the system in bytes per thousand bytes is between thi= s and - * the low watermark, DAMON_LRU_SORT becomes active, so starts the monitor= ing - * and the LRU-lists sorting. 150 (15%) by default. - */ -static unsigned long wmarks_mid __read_mostly =3D 150; -module_param(wmarks_mid, ulong, 0600); - -/* - * Free memory rate (per thousand) for the low watermark. - * - * If free memory of the system in bytes per thousand bytes is lower than = this, - * DAMON_LRU_SORT becomes inactive, so it does nothing but periodically ch= ecks - * the watermarks. 50 (5%) by default. - */ -static unsigned long wmarks_low __read_mostly =3D 50; -module_param(wmarks_low, ulong, 0600); +struct damos_watermarks damon_lru_sort_wmarks =3D { + .metric =3D DAMOS_WMARK_FREE_MEM_RATE, + .interval =3D 5000000, /* 5 seconds */ + .high =3D 200, /* 20 percent */ + .mid =3D 150, /* 15 percent */ + .low =3D 50, /* 5 percent */ +}; +DEFINE_DAMON_MODULES_WMARKS_PARAMS(damon_lru_sort_wmarks); =20 static struct damon_attrs damon_lru_sort_mon_attrs =3D { .sample_interval =3D 5000, /* 5 ms */ @@ -242,13 +212,6 @@ static struct damos *damon_lru_sort_new_hot_scheme(uns= igned int hot_thres) .min_age_region =3D 0, .max_age_region =3D UINT_MAX, }; - struct damos_watermarks wmarks =3D { - .metric =3D DAMOS_WMARK_FREE_MEM_RATE, - .interval =3D wmarks_interval, - .high =3D wmarks_high, - .mid =3D wmarks_mid, - .low =3D wmarks_low, - }; struct damos_quota quota =3D { /* * Do not try LRU-lists sorting of hot pages for more than half @@ -270,7 +233,7 @@ static struct damos *damon_lru_sort_new_hot_scheme(unsi= gned int hot_thres) /* under the quota. */ "a, /* (De)activate this according to the watermarks. */ - &wmarks); + &damon_lru_sort_wmarks); } =20 /* Create a DAMON-based operation scheme for cold memory regions */ @@ -287,13 +250,6 @@ static struct damos *damon_lru_sort_new_cold_scheme(un= signed int cold_thres) .min_age_region =3D cold_thres, .max_age_region =3D UINT_MAX, }; - struct damos_watermarks wmarks =3D { - .metric =3D DAMOS_WMARK_FREE_MEM_RATE, - .interval =3D wmarks_interval, - .high =3D wmarks_high, - .mid =3D wmarks_mid, - .low =3D wmarks_low, - }; struct damos_quota quota =3D { /* * Do not try LRU-lists sorting of cold pages for more than @@ -316,7 +272,7 @@ static struct damos *damon_lru_sort_new_cold_scheme(uns= igned int cold_thres) /* under the quota. */ "a, /* (De)activate this according to the watermarks. */ - &wmarks); + &damon_lru_sort_wmarks); } =20 static int damon_lru_sort_apply_parameters(void) diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index 1370590a37d1..4c2ce84869d5 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -18,8 +18,8 @@ 0600); =20 #define DEFINE_DAMON_MODULES_WMARKS_PARAMS(wmarks) \ - module_param_named(wmarks_interval, wmarks->interval, ulong, \ + module_param_named(wmarks_interval, wmarks.interval, ulong, \ 0600); \ module_param_named(wmarks_high, wmarks.high, ulong, 0600); \ module_param_named(wmarks_mid, wmarks.mid, ulong, 0600); \ - module_param_named(wmarks_low, wmarks.lowulong, 0600); + module_param_named(wmarks_low, wmarks.low, ulong, 0600); --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15A0FECAAD8 for ; Tue, 13 Sep 2022 18:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232823AbiIMS2X (ORCPT ); Tue, 13 Sep 2022 14:28:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbiIMS1A (ORCPT ); Tue, 13 Sep 2022 14:27:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1995666117 for ; Tue, 13 Sep 2022 10:45:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3263A61520 for ; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E1C5C43140; Tue, 13 Sep 2022 17:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091104; bh=gmkQIvgsS3o7E0kw20g1nY/rU6PdiC7nZb5s3NkPL2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JylOBtODAgJiw9eaH6HLYcsFje7zpwtzLk/brt56MBMuN1KWnaiYrbiYtAN8ohXAf H4FiJjzVDV9FJfQlLvtBh2KXVkd4dluSslzGUFFR1fVlIo7XxNIoyWkIh1YygmOmXq 9uLhAtMYgy3CTVSuP/dQ7AAxkK3KIf7W1kzmceKmDKQqop0PB8YP+PdWdax9AddBO3 W/saUg7P7HTcjQSK3Em4AF6VR+lNWj38CPeNLXAkiI/iRt9woF23okgQsmUtvP5po2 kXtnKUsX38Zfvj2Ha45qqMl7F7+4E8uDA9rh9EHWgNRXcwKUGTphaGaR6+epC4LcWi XsXwjjqBnjxJw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/22] mm/damon/reclaim: use watermarks parameters generator macro Date: Tue, 13 Sep 2022 17:44:41 +0000 Message-Id: <20220913174449.50645-15-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit makes DAMON_RECLAIM to generate the module parameters for DAMOS watermarks using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 56 ++++++++-------------------------------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 48326bef20f5..7f845f617dc5 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -91,45 +91,14 @@ module_param(quota_sz, ulong, 0600); static unsigned long quota_reset_interval_ms __read_mostly =3D 1000; module_param(quota_reset_interval_ms, ulong, 0600); =20 -/* - * The watermarks check time interval in microseconds. - * - * Minimal time to wait before checking the watermarks, when DAMON_RECLAIM= is - * enabled but inactive due to its watermarks rule. 5 seconds by default. - */ -static unsigned long wmarks_interval __read_mostly =3D 5000000; -module_param(wmarks_interval, ulong, 0600); - -/* - * Free memory rate (per thousand) for the high watermark. - * - * If free memory of the system in bytes per thousand bytes is higher than - * this, DAMON_RECLAIM becomes inactive, so it does nothing but periodical= ly - * checks the watermarks. 500 (50%) by default. - */ -static unsigned long wmarks_high __read_mostly =3D 500; -module_param(wmarks_high, ulong, 0600); - -/* - * Free memory rate (per thousand) for the middle watermark. - * - * If free memory of the system in bytes per thousand bytes is between thi= s and - * the low watermark, DAMON_RECLAIM becomes active, so starts the monitori= ng - * and the reclaiming. 400 (40%) by default. - */ -static unsigned long wmarks_mid __read_mostly =3D 400; -module_param(wmarks_mid, ulong, 0600); - -/* - * Free memory rate (per thousand) for the low watermark. - * - * If free memory of the system in bytes per thousand bytes is lower than = this, - * DAMON_RECLAIM becomes inactive, so it does nothing but periodically che= cks - * the watermarks. In the case, the system falls back to the LRU-based pa= ge - * granularity reclamation logic. 200 (20%) by default. - */ -static unsigned long wmarks_low __read_mostly =3D 200; -module_param(wmarks_low, ulong, 0600); +struct damos_watermarks damon_reclaim_wmarks =3D { + .metric =3D DAMOS_WMARK_FREE_MEM_RATE, + .interval =3D 5000000, /* 5 seconds */ + .high =3D 500, /* 50 percent */ + .mid =3D 400, /* 40 percent */ + .low =3D 200, /* 20 percent */ +}; +DEFINE_DAMON_MODULES_WMARKS_PARAMS(damon_reclaim_wmarks); =20 static struct damon_attrs damon_reclaim_mon_attrs =3D { .sample_interval =3D 5000, /* 5 ms */ @@ -214,13 +183,6 @@ static struct damos *damon_reclaim_new_scheme(void) damon_reclaim_mon_attrs.aggr_interval, .max_age_region =3D UINT_MAX, }; - struct damos_watermarks wmarks =3D { - .metric =3D DAMOS_WMARK_FREE_MEM_RATE, - .interval =3D wmarks_interval, - .high =3D wmarks_high, - .mid =3D wmarks_mid, - .low =3D wmarks_low, - }; struct damos_quota quota =3D { /* * Do not try reclamation for more than quota_ms milliseconds @@ -242,7 +204,7 @@ static struct damos *damon_reclaim_new_scheme(void) /* under the quota. */ "a, /* (De)activate this according to the watermarks. */ - &wmarks); + &damon_reclaim_wmarks); } =20 static int damon_reclaim_apply_parameters(void) --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F412ECAAD8 for ; Tue, 13 Sep 2022 18:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231715AbiIMS2T (ORCPT ); Tue, 13 Sep 2022 14:28:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232381AbiIMS1A (ORCPT ); Tue, 13 Sep 2022 14:27:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F6C467160 for ; Tue, 13 Sep 2022 10:45:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BFB5F61549 for ; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B463C43144; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091104; bh=9Ie/eYWIDmaeWIIzjho1hLTkE8OQk0TsC6fyZAjKC84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pxRWRVz4xS5qVWe0ZeEo+e/hBelBW8BPMyZafRuBCXoJrRDNz1nALb/Sf/2DOVjJD mNrKJnwvEdDCg6m6D1X6N4wVNEmxcdegxtNWe+GcmTyYdGioHK64En+VztzAuQXsUK SZ07SpZurtmGYM9ySOXA9xshufEBcFNxjJwPNYZLCSFRJb+Quro+hey6JeF60M+7Yp kyeOuG1jQhZwOJM8p/tQZ2KRiw8xpWYW90HispIXRVkON86iKUGTfqylXV2hKeDn9o dijqj+f38tCRUTBqoIOb0vN876wv4buHFms+KzPbT0rAC5gHkA3Id5l0yTer8F3EYo rIZdrvbrhAhTQ== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/22] mm/damon/modules-common: implement a stats parameters generator macro Date: Tue, 13 Sep 2022 17:44:42 +0000 Message-Id: <20220913174449.50645-16-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" DAMON_RECLAIM and DAMON_LRU_SORT have module parameters for DAMOS statistics that having same names. This commit implements a macro for generating such module parameters so that we can reuse later. Signed-off-by: SeongJae Park --- mm/damon/modules-common.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index 4c2ce84869d5..ed973e0770ae 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -23,3 +23,15 @@ module_param_named(wmarks_high, wmarks.high, ulong, 0600); \ module_param_named(wmarks_mid, wmarks.mid, ulong, 0600); \ module_param_named(wmarks_low, wmarks.low, ulong, 0600); + +#define DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(stat, try_name, \ + succ_name, qt_exceed_name) \ + module_param_named(nr_##try_name, stat.nr_tried, ulong, 0400); \ + module_param_named(bytes_##try_name, stat.sz_tried, ulong, \ + 0400); \ + module_param_named(nr_##succ_name, stat.nr_applied, ulong, \ + 0400); \ + module_param_named(bytes_##succ_name, stat.sz_applied, ulong, \ + 0400); \ + module_param_named(qt_exceed_name, stat.qt_exceeds, ulong, \ + 0400); --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7052C54EE9 for ; Tue, 13 Sep 2022 18:28:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232828AbiIMS22 (ORCPT ); Tue, 13 Sep 2022 14:28:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231583AbiIMS1A (ORCPT ); Tue, 13 Sep 2022 14:27:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 450026B15A for ; Tue, 13 Sep 2022 10:45:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5AE1F6154F for ; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8063C4314B; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091105; bh=qZmiFc1Nc82ylFf2RlnRQAmg5LcM9WJjL5ftMxpc9Tk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BB374hfZv4lK06Nj4HgDd75pbYfHPfeFxPQ3Xjt/cz2hsv/aWWPi+WTgisy1XCo1g pjg2H6jqjFT4AOYIOmVse24brY8ClPTPcIQwlN8UwP+19TilWDubDQSho9kqu4E8Pu GMvpdtW9cKXgQqp2mcz7axPBiGT/Rk365rLZhsCkfQuVLu/+BlcKFMGe5MZtIRF4NW OxwoHMlnk9xXSAhE/vStWlWrwr4HOqsl8MUTZ+vX375YF7UtWc6v00HgsPB+mnumGH ViI3StyG6zLvY9d3ivDvJfY04ME++3mtJXZIIu2j9RR5H3Ptivgx8IqdWU9Do9Bjv3 NCY1EzCxzmVag== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/22] mm/damon/reclaim: use stat parameters generator Date: Tue, 13 Sep 2022 17:44:43 +0000 Message-Id: <20220913174449.50645-17-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit makes DAMON_RECLAIM to generate the module parameters for DAMOS statistics using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 7f845f617dc5..1ef8353ac15a 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -136,35 +136,9 @@ module_param(monitor_region_end, ulong, 0600); static int kdamond_pid __read_mostly =3D -1; module_param(kdamond_pid, int, 0400); =20 -/* - * Number of memory regions that tried to be reclaimed. - */ -static unsigned long nr_reclaim_tried_regions __read_mostly; -module_param(nr_reclaim_tried_regions, ulong, 0400); - -/* - * Total bytes of memory regions that tried to be reclaimed. - */ -static unsigned long bytes_reclaim_tried_regions __read_mostly; -module_param(bytes_reclaim_tried_regions, ulong, 0400); - -/* - * Number of memory regions that successfully be reclaimed. - */ -static unsigned long nr_reclaimed_regions __read_mostly; -module_param(nr_reclaimed_regions, ulong, 0400); - -/* - * Total bytes of memory regions that successfully be reclaimed. - */ -static unsigned long bytes_reclaimed_regions __read_mostly; -module_param(bytes_reclaimed_regions, ulong, 0400); - -/* - * Number of times that the time/space quota limits have exceeded - */ -static unsigned long nr_quota_exceeds __read_mostly; -module_param(nr_quota_exceeds, ulong, 0400); +static struct damos_stat damon_reclaim_stat; +DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_reclaim_stat, + reclaim_tried_regions, reclaimed_regions, quota_exceeds); =20 static struct damon_ctx *ctx; static struct damon_target *target; @@ -318,13 +292,8 @@ static int damon_reclaim_after_aggregation(struct damo= n_ctx *c) struct damos *s; =20 /* update the stats parameter */ - damon_for_each_scheme(s, c) { - nr_reclaim_tried_regions =3D s->stat.nr_tried; - bytes_reclaim_tried_regions =3D s->stat.sz_tried; - nr_reclaimed_regions =3D s->stat.nr_applied; - bytes_reclaimed_regions =3D s->stat.sz_applied; - nr_quota_exceeds =3D s->stat.qt_exceeds; - } + damon_for_each_scheme(s, c) + damon_reclaim_stat =3D s->stat; =20 return damon_reclaim_handle_commit_inputs(); } --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DDBBECAAD8 for ; Tue, 13 Sep 2022 18:29:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232609AbiIMS3L (ORCPT ); Tue, 13 Sep 2022 14:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231699AbiIMS1Y (ORCPT ); Tue, 13 Sep 2022 14:27:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E15C5FF7D for ; Tue, 13 Sep 2022 10:45:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2CC21B80CBC for ; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63EF1C433B5; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091105; bh=u1GfgXM7mUjFBfeDP+toubTJ/FRGtWide9LOC5L8HRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ANJQGfxDIqc7hST47btF5G7cY3Nee8GwTbGmGlsyCZgW1CwnmWLuo9umE9c4I5Wcu je75w/e6+bs6GhWiu5jU0uWr6tsdyJnyx7KakgcBUCnItnQiuKx2beptNm5L10MVBQ 5+VP+IYMUcmWekPd9cPkrxVuSQXVE/8Xi/QnvBfbBK67yZFGAGIlteruYBTU5w6/1W S99pkLn7F9RQO1J224scXWadm8tUI6K1/dK8BY3VksIg3gDbDknbNKMBzVoGKSXLoW u8OXgargc7ImYJbe2WTEJMMGA9PFXtQUezXf0+T9/OMMAjuU0RAB+fI3fMKyprPrBS JU/FTvru15AsQ== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/22] mm/damon/lru_sort: use stat generator Date: Tue, 13 Sep 2022 17:44:44 +0000 Message-Id: <20220913174449.50645-18-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit makes DAMON_LRU_SORT to generate the module parameters for DAMOS statistics using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 83 +++++++-------------------------------------- 1 file changed, 12 insertions(+), 71 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 20760b39b50a..13a752aed272 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -135,65 +135,15 @@ module_param(monitor_region_end, ulong, 0600); static int kdamond_pid __read_mostly =3D -1; module_param(kdamond_pid, int, 0400); =20 -/* - * Number of hot memory regions that tried to be LRU-sorted. - */ -static unsigned long nr_lru_sort_tried_hot_regions __read_mostly; -module_param(nr_lru_sort_tried_hot_regions, ulong, 0400); - -/* - * Total bytes of hot memory regions that tried to be LRU-sorted. - */ -static unsigned long bytes_lru_sort_tried_hot_regions __read_mostly; -module_param(bytes_lru_sort_tried_hot_regions, ulong, 0400); - -/* - * Number of hot memory regions that successfully be LRU-sorted. - */ -static unsigned long nr_lru_sorted_hot_regions __read_mostly; -module_param(nr_lru_sorted_hot_regions, ulong, 0400); - -/* - * Total bytes of hot memory regions that successfully be LRU-sorted. - */ -static unsigned long bytes_lru_sorted_hot_regions __read_mostly; -module_param(bytes_lru_sorted_hot_regions, ulong, 0400); - -/* - * Number of times that the time quota limit for hot regions have exceeded - */ -static unsigned long nr_hot_quota_exceeds __read_mostly; -module_param(nr_hot_quota_exceeds, ulong, 0400); +static struct damos_stat damon_lru_sort_hot_stat; +DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_lru_sort_hot_stat, + lru_sort_tried_hot_regions, lru_sorted_hot_regions, + hot_quota_exceeds); =20 -/* - * Number of cold memory regions that tried to be LRU-sorted. - */ -static unsigned long nr_lru_sort_tried_cold_regions __read_mostly; -module_param(nr_lru_sort_tried_cold_regions, ulong, 0400); - -/* - * Total bytes of cold memory regions that tried to be LRU-sorted. - */ -static unsigned long bytes_lru_sort_tried_cold_regions __read_mostly; -module_param(bytes_lru_sort_tried_cold_regions, ulong, 0400); - -/* - * Number of cold memory regions that successfully be LRU-sorted. - */ -static unsigned long nr_lru_sorted_cold_regions __read_mostly; -module_param(nr_lru_sorted_cold_regions, ulong, 0400); - -/* - * Total bytes of cold memory regions that successfully be LRU-sorted. - */ -static unsigned long bytes_lru_sorted_cold_regions __read_mostly; -module_param(bytes_lru_sorted_cold_regions, ulong, 0400); - -/* - * Number of times that the time quota limit for cold regions have exceeded - */ -static unsigned long nr_cold_quota_exceeds __read_mostly; -module_param(nr_cold_quota_exceeds, ulong, 0400); +static struct damos_stat damon_lru_sort_cold_stat; +DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_lru_sort_cold_stat, + lru_sort_tried_cold_regions, lru_sorted_cold_regions, + cold_quota_exceeds); =20 static struct damon_ctx *ctx; static struct damon_target *target; @@ -397,19 +347,10 @@ static int damon_lru_sort_after_aggregation(struct da= mon_ctx *c) =20 /* update the stats parameter */ damon_for_each_scheme(s, c) { - if (s->action =3D=3D DAMOS_LRU_PRIO) { - nr_lru_sort_tried_hot_regions =3D s->stat.nr_tried; - bytes_lru_sort_tried_hot_regions =3D s->stat.sz_tried; - nr_lru_sorted_hot_regions =3D s->stat.nr_applied; - bytes_lru_sorted_hot_regions =3D s->stat.sz_applied; - nr_hot_quota_exceeds =3D s->stat.qt_exceeds; - } else if (s->action =3D=3D DAMOS_LRU_DEPRIO) { - nr_lru_sort_tried_cold_regions =3D s->stat.nr_tried; - bytes_lru_sort_tried_cold_regions =3D s->stat.sz_tried; - nr_lru_sorted_cold_regions =3D s->stat.nr_applied; - bytes_lru_sorted_cold_regions =3D s->stat.sz_applied; - nr_cold_quota_exceeds =3D s->stat.qt_exceeds; - } + if (s->action =3D=3D DAMOS_LRU_PRIO) + damon_lru_sort_hot_stat =3D s->stat; + else if (s->action =3D=3D DAMOS_LRU_DEPRIO) + damon_lru_sort_cold_stat =3D s->stat; } =20 return damon_lru_sort_handle_commit_inputs(); --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 909F4ECAAD8 for ; Tue, 13 Sep 2022 18:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232660AbiIMS3U (ORCPT ); Tue, 13 Sep 2022 14:29:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232598AbiIMS1Q (ORCPT ); Tue, 13 Sep 2022 14:27:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C85B6BCFD for ; Tue, 13 Sep 2022 10:45:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ECA3661547 for ; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02E44C433D7; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091106; bh=9TcztpKUfo8rJO30rUXY908EwJFNjnWv9MscjxP6KRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mjrzuvWzKjr0o1tHWC3oa/x8CqWNP5PZKYZP/XDN92cM7jK70J4mKUV9vausd238e riryqkMtUWxyD/gX5tYUkxQ3P/3zszg9T3RTTLtE0phE7ILox45K92oYXyhMSPTCOk CUNOQPWXe34ewcWLx1MgGlrJyzyOtADspV8a+qY/3IG+E/X81uLk0fLip6jGYk58PE FkgLBer7nq3bHOUfHrrTi3o8B4uGR+XFGVk2qGgBqPc6twV724Olv2YWOMdKH8HKky vCgcKNxYMVV143k4OapjzmPrZd+gqTrVaC9FHYff8un/H22Cc6xjvgRvM0iApFhA0P HixvJiwLik+1A== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/22] mm/damon/modules-common: implement a damos quota params generator Date: Tue, 13 Sep 2022 17:44:45 +0000 Message-Id: <20220913174449.50645-19-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" DAMON_RECLAIM and DAMON_LRU_SORT have module parameters for DAMOS quotas that having same names. This commit implements a macro for generating such module parameters so that we can reuse later. Signed-off-by: SeongJae Park --- mm/damon/modules-common.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index ed973e0770ae..3e99810b4689 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -17,6 +17,12 @@ module_param_named(max_nr_regions, attrs.max_nr_regions, ulong, \ 0600); =20 +#define DEFINE_DAMON_MODULES_DAMOS_QUOTAS(quota) \ + module_param_named(quota_ms, quota.ms, ulong, 0600); \ + module_param_named(quota_sz, quota.sz, ulong, 0600); \ + module_param_named(quota_reset_interval_ms, \ + quota.reset_interval, ulong, 0600); + #define DEFINE_DAMON_MODULES_WMARKS_PARAMS(wmarks) \ module_param_named(wmarks_interval, wmarks.interval, ulong, \ 0600); \ @@ -33,5 +39,5 @@ 0400); \ module_param_named(bytes_##succ_name, stat.sz_applied, ulong, \ 0400); \ - module_param_named(qt_exceed_name, stat.qt_exceeds, ulong, \ + module_param_named(nr_##qt_exceed_name, stat.qt_exceeds, ulong, \ 0400); --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B7B7ECAAD8 for ; Tue, 13 Sep 2022 18:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232628AbiIMS3Q (ORCPT ); Tue, 13 Sep 2022 14:29:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230493AbiIMS1O (ORCPT ); Tue, 13 Sep 2022 14:27:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 944D76CD04 for ; Tue, 13 Sep 2022 10:45:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 49295B80DCB for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90BE6C433D6; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091106; bh=TpMHecuKvtdBhnIMulCBOg8dzHSBCxkP4seXXVnf3o4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jdCE6iWv9HhVPN7MDQ52uUfmE9OXzgOLz0P+fJP2LIXptahcOXvoBkHEsLBhTSNwj xrLhrofoeYdhxmr0yF7a9NMGGDXsSOljaMebIelpbFB5SJEFGCEXreNc8EtkI7kSdn r33Ic3xkizh+xPUXJkZ/yCPD+mWOBL4ziEy43+5GPf9xdeZC+m7ehB8eMXmCyQdqPl AWMHQKAJUvl3RTuI9Qf8lDnEWxDh20IBq6s3CQddOaQefJP/7BVsq3f5l0pR4NKxK8 bqS/45DdTR5fiyGxW4N3AFYecqAu2+uW3DvrNqhWmbaZOUBIpyE940+uN56FuVnODK ezKyQ6CsrnXmA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/22] mm/damon/modules-common: implement damos time quota params generator Date: Tue, 13 Sep 2022 17:44:46 +0000 Message-Id: <20220913174449.50645-20-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" DAMON_LRU_SORT have module parameters for DAMOS time quota only but size quota. This commit implements a macro for generating the module parameters so that we can reuse later. Signed-off-by: SeongJae Park --- mm/damon/modules-common.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index 3e99810b4689..5a4921851d32 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -17,12 +17,15 @@ module_param_named(max_nr_regions, attrs.max_nr_regions, ulong, \ 0600); =20 -#define DEFINE_DAMON_MODULES_DAMOS_QUOTAS(quota) \ +#define DEFINE_DAMON_MODULES_DAMOS_TIME_QUOTA(quota) \ module_param_named(quota_ms, quota.ms, ulong, 0600); \ - module_param_named(quota_sz, quota.sz, ulong, 0600); \ module_param_named(quota_reset_interval_ms, \ quota.reset_interval, ulong, 0600); =20 +#define DEFINE_DAMON_MODULES_DAMOS_QUOTAS(quota) \ + DEFINE_DAMON_MODULES_DAMOS_TIME_QUOTA(quota) \ + module_param_named(quota_sz, quota.sz, ulong, 0600); + #define DEFINE_DAMON_MODULES_WMARKS_PARAMS(wmarks) \ module_param_named(wmarks_interval, wmarks.interval, ulong, \ 0600); \ --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16D4DC54EE9 for ; Tue, 13 Sep 2022 18:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbiIMS3H (ORCPT ); Tue, 13 Sep 2022 14:29:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232632AbiIMS10 (ORCPT ); Tue, 13 Sep 2022 14:27:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8B536CD17 for ; Tue, 13 Sep 2022 10:45:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E261DB8109A for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EC0DC43141; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091107; bh=Rt+6znKPHySLjT8sirY/weqR0AkuV9kF+fJNNSJrSSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZwfAFpo76S/yeZ9tvwi0xEeO6SrP80OCSrdIOOm02Nyb8iiWg+JIPr2SCcG/sW80 gnBrwd1U3IPU9Liv+aDrK21/MXVScY/XaIh2yt4nsNeIY/HRe1UmNZKl7l7IZu8HaC BIfCeTAU9A3GYGQ+0NBz638hN7GosgelXDq71owqLS7N7JEbyYhIyZtOUun/3eEHIK XHgnLMeBinShgZ7zdH0SHzL6noiiB1AOHt2TNlGrk9bJXrPJ/foMZ9JdYG5omTjfV/ ZqccItcLesNgd1WLLZtIovibYzdtBdlIXcoC0qZsLGNzCymQ22DETnD6N50VQGByU0 6r5AP78PmqOkg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 20/22] mm/damon/reclaim: use the quota params generator macro Date: Tue, 13 Sep 2022 17:44:47 +0000 Message-Id: <20220913174449.50645-21-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit makes DAMON_RECLAIM to generate the module parameters for DAMOS quotas using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 64 +++++++++------------------------------------- 1 file changed, 12 insertions(+), 52 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 1ef8353ac15a..1acf808e1624 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -52,44 +52,17 @@ module_param(commit_inputs, bool, 0600); static unsigned long min_age __read_mostly =3D 120000000; module_param(min_age, ulong, 0600); =20 -/* - * Limit of time for trying the reclamation in milliseconds. - * - * DAMON_RECLAIM tries to use only up to this time within a time window - * (quota_reset_interval_ms) for trying reclamation of cold pages. This c= an be - * used for limiting CPU consumption of DAMON_RECLAIM. If the value is ze= ro, - * the limit is disabled. - * - * 10 ms by default. - */ -static unsigned long quota_ms __read_mostly =3D 10; -module_param(quota_ms, ulong, 0600); - -/* - * Limit of size of memory for the reclamation in bytes. - * - * DAMON_RECLAIM charges amount of memory which it tried to reclaim within= a - * time window (quota_reset_interval_ms) and makes no more than this limit= is - * tried. This can be used for limiting consumption of CPU and IO. If th= is - * value is zero, the limit is disabled. - * - * 128 MiB by default. - */ -static unsigned long quota_sz __read_mostly =3D 128 * 1024 * 1024; -module_param(quota_sz, ulong, 0600); - -/* - * The time/size quota charge reset interval in milliseconds. - * - * The charge reset interval for the quota of time (quota_ms) and size - * (quota_sz). That is, DAMON_RECLAIM does not try reclamation for more t= han - * quota_ms milliseconds or quota_sz bytes within quota_reset_interval_ms - * milliseconds. - * - * 1 second by default. - */ -static unsigned long quota_reset_interval_ms __read_mostly =3D 1000; -module_param(quota_reset_interval_ms, ulong, 0600); +static struct damos_quota damon_reclaim_quota =3D { + /* use up to 10 ms time, reclaim up to 128 MiB per 1 sec by default */ + .ms =3D 10, + .sz =3D 128 * 1024 * 1024, + .reset_interval =3D 1000, + /* Within the quota, page out older regions first. */ + .weight_sz =3D 0, + .weight_nr_accesses =3D 0, + .weight_age =3D 1 +}; +DEFINE_DAMON_MODULES_DAMOS_QUOTAS(damon_reclaim_quota); =20 struct damos_watermarks damon_reclaim_wmarks =3D { .metric =3D DAMOS_WMARK_FREE_MEM_RATE, @@ -157,26 +130,13 @@ static struct damos *damon_reclaim_new_scheme(void) damon_reclaim_mon_attrs.aggr_interval, .max_age_region =3D UINT_MAX, }; - struct damos_quota quota =3D { - /* - * Do not try reclamation for more than quota_ms milliseconds - * or quota_sz bytes within quota_reset_interval_ms. - */ - .ms =3D quota_ms, - .sz =3D quota_sz, - .reset_interval =3D quota_reset_interval_ms, - /* Within the quota, page out older regions first. */ - .weight_sz =3D 0, - .weight_nr_accesses =3D 0, - .weight_age =3D 1 - }; =20 return damon_new_scheme( &pattern, /* page out those, as soon as found */ DAMOS_PAGEOUT, /* under the quota. */ - "a, + &damon_reclaim_quota, /* (De)activate this according to the watermarks. */ &damon_reclaim_wmarks); } --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56BC7ECAAD8 for ; Tue, 13 Sep 2022 18:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231742AbiIMS2y (ORCPT ); Tue, 13 Sep 2022 14:28:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231546AbiIMS1U (ORCPT ); Tue, 13 Sep 2022 14:27:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 884056D54A for ; Tue, 13 Sep 2022 10:45:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 67D73B81095 for ; Tue, 13 Sep 2022 17:45:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF9C5C4347C; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091108; bh=vDKNHhOgxvXdmTbnCpBFmnMIFqpdFy3QEkyiK51v7wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e0yD8AsuLcJY/gdEyZtKUR8q1Ts7XNhquj3lx0IpkCYiMXfHclxM34eS35xvz5mGh fkuMV0nRyR0ro+vFojhppd4ac+A71wrZJNunIKAb5DtvrNoKoDnH6zOCHz6tmFkbmK 3QsXvf5zG2B6yuDePFY3HZ6FDO/KlfqqjANqTebR/1yB+9XeztxD5Hthie3KR0QJNX oR4tOs2/ML/GJ4AKnMgp+nZfnQBn0bDVsunxi2qkG5CHaItsMPVwFvj62tHHPZJhuz y/1ytxtrSdHS19LaXn3XYOkYz6YMzbI6S06WFBSegLR4f6HdEb2eqeVVQE9WXnjsfh 0qImovxL20cRA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/22] mm/damon/lru_sort: use quotas param generator Date: Tue, 13 Sep 2022 17:44:48 +0000 Message-Id: <20220913174449.50645-22-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit makes DAMON_LRU_SORT to generate the module parameters for DAMOS watermarks using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 70 ++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 51 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 13a752aed272..8d9c3d1fd6be 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -65,30 +65,17 @@ module_param(hot_thres_access_freq, ulong, 0600); static unsigned long cold_min_age __read_mostly =3D 120000000; module_param(cold_min_age, ulong, 0600); =20 -/* - * Limit of time for trying the LRU lists sorting in milliseconds. - * - * DAMON_LRU_SORT tries to use only up to this time within a time window - * (quota_reset_interval_ms) for trying LRU lists sorting. This can be us= ed - * for limiting CPU consumption of DAMON_LRU_SORT. If the value is zero, = the - * limit is disabled. - * - * 10 ms by default. - */ -static unsigned long quota_ms __read_mostly =3D 10; -module_param(quota_ms, ulong, 0600); - -/* - * The time quota charge reset interval in milliseconds. - * - * The charge reset interval for the quota of time (quota_ms). That is, - * DAMON_LRU_SORT does not try LRU-lists sorting for more than quota_ms - * milliseconds or quota_sz bytes within quota_reset_interval_ms milliseco= nds. - * - * 1 second by default. - */ -static unsigned long quota_reset_interval_ms __read_mostly =3D 1000; -module_param(quota_reset_interval_ms, ulong, 0600); +static struct damos_quota damon_lru_sort_quota =3D { + /* Use up to 10 ms per 1 sec, by default */ + .ms =3D 10, + .sz =3D 0, + .reset_interval =3D 1000, + /* Within the quota, mark hotter regions accessed first. */ + .weight_sz =3D 0, + .weight_nr_accesses =3D 1, + .weight_age =3D 0, +}; +DEFINE_DAMON_MODULES_DAMOS_TIME_QUOTA(damon_lru_sort_quota); =20 struct damos_watermarks damon_lru_sort_wmarks =3D { .metric =3D DAMOS_WMARK_FREE_MEM_RATE, @@ -162,19 +149,10 @@ static struct damos *damon_lru_sort_new_hot_scheme(un= signed int hot_thres) .min_age_region =3D 0, .max_age_region =3D UINT_MAX, }; - struct damos_quota quota =3D { - /* - * Do not try LRU-lists sorting of hot pages for more than half - * of quota_ms milliseconds within quota_reset_interval_ms. - */ - .ms =3D quota_ms / 2, - .sz =3D 0, - .reset_interval =3D quota_reset_interval_ms, - /* Within the quota, mark hotter regions accessed first. */ - .weight_sz =3D 0, - .weight_nr_accesses =3D 1, - .weight_age =3D 0, - }; + struct damos_quota quota =3D damon_lru_sort_quota; + + /* Use half of total quota for hot pages sorting */ + quota.ms =3D quota.ms / 2; =20 return damon_new_scheme( &pattern, @@ -200,20 +178,10 @@ static struct damos *damon_lru_sort_new_cold_scheme(u= nsigned int cold_thres) .min_age_region =3D cold_thres, .max_age_region =3D UINT_MAX, }; - struct damos_quota quota =3D { - /* - * Do not try LRU-lists sorting of cold pages for more than - * half of quota_ms milliseconds within - * quota_reset_interval_ms. - */ - .ms =3D quota_ms / 2, - .sz =3D 0, - .reset_interval =3D quota_reset_interval_ms, - /* Within the quota, mark colder regions not accessed first. */ - .weight_sz =3D 0, - .weight_nr_accesses =3D 0, - .weight_age =3D 1, - }; + struct damos_quota quota =3D damon_lru_sort_quota; + + /* Use half of total quota for cold pages sorting */ + quota.ms =3D quota.ms / 2; =20 return damon_new_scheme( &pattern, --=20 2.25.1 From nobody Sun Apr 5 22:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC529ECAAD8 for ; Tue, 13 Sep 2022 18:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbiIMS3C (ORCPT ); Tue, 13 Sep 2022 14:29:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232239AbiIMS1G (ORCPT ); Tue, 13 Sep 2022 14:27:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9446D6C77D for ; Tue, 13 Sep 2022 10:45:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 523F36153C for ; Tue, 13 Sep 2022 17:45:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D271C43470; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091108; bh=9ivYQelMNdPJnaUU9EF7chmzaREKfF8OhPMBITLg3Ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lMkprEXAQC24XJuiTGGjHyvCehrXWfCWngVdHpBZekHiCxDCwHZs0bOCXOeUCGKF8 NAWMZpAkMK5j5PUmvn9X13/I1Xx+Q3H3d8j6AH3HocE847FyXcbB6E0u2ImFA1+HiW XcP4TCbJSNnGyPtX5aBTXrfh8r6R56LOXK7Gx2fZgrTD4kVu1uEWKufBq3AF/YeWfU kFigvWxhkISGTBBEeedP/5RwKIBFKlDPHTlQk3gqZByQpGK9poN3cLcmo80BDROsnc Cjen7hGO3HLbS2379iozDv043UszchvmX+3WKTheH4+4Sw7BMZXvVAjUurep7BxVqc JnJE5k/ZtpKhQ== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 22/22] mm/damon/lru_sort: deduplicate hot/cold schemes generators Date: Tue, 13 Sep 2022 17:44:49 +0000 Message-Id: <20220913174449.50645-23-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" damon_lru_sort_new_{hot,cold}_scheme() have quite a lot of duplicates. This commit factors out the duplicate to a separate function and use it for reducing the duplicate. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 8d9c3d1fd6be..07a0908963fd 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -135,6 +135,25 @@ DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_lru_sort= _cold_stat, static struct damon_ctx *ctx; static struct damon_target *target; =20 +static struct damos *damon_lru_sort_new_scheme( + struct damos_access_pattern *pattern, enum damos_action action) +{ + struct damos_quota quota =3D damon_lru_sort_quota; + + /* Use half of total quota for hot/cold pages sorting */ + quota.ms =3D quota.ms / 2; + + return damon_new_scheme( + /* find the pattern, and */ + pattern, + /* (de)prioritize on LRU-lists */ + action, + /* under the quota. */ + "a, + /* (De)activate this according to the watermarks. */ + &damon_lru_sort_wmarks); +} + /* Create a DAMON-based operation scheme for hot memory regions */ static struct damos *damon_lru_sort_new_hot_scheme(unsigned int hot_thres) { @@ -149,19 +168,8 @@ static struct damos *damon_lru_sort_new_hot_scheme(uns= igned int hot_thres) .min_age_region =3D 0, .max_age_region =3D UINT_MAX, }; - struct damos_quota quota =3D damon_lru_sort_quota; - - /* Use half of total quota for hot pages sorting */ - quota.ms =3D quota.ms / 2; =20 - return damon_new_scheme( - &pattern, - /* prioritize those on LRU lists, as soon as found */ - DAMOS_LRU_PRIO, - /* under the quota. */ - "a, - /* (De)activate this according to the watermarks. */ - &damon_lru_sort_wmarks); + return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_PRIO); } =20 /* Create a DAMON-based operation scheme for cold memory regions */ @@ -178,19 +186,8 @@ static struct damos *damon_lru_sort_new_cold_scheme(un= signed int cold_thres) .min_age_region =3D cold_thres, .max_age_region =3D UINT_MAX, }; - struct damos_quota quota =3D damon_lru_sort_quota; =20 - /* Use half of total quota for cold pages sorting */ - quota.ms =3D quota.ms / 2; - - return damon_new_scheme( - &pattern, - /* mark those as not accessed, as soon as found */ - DAMOS_LRU_DEPRIO, - /* under the quota. */ - "a, - /* (De)activate this according to the watermarks. */ - &damon_lru_sort_wmarks); + return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO); } =20 static int damon_lru_sort_apply_parameters(void) --=20 2.25.1