From nobody Thu Dec 18 19:03:15 2025 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 A0731EEB582 for ; Sat, 9 Sep 2023 03:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239829AbjIIDha (ORCPT ); Fri, 8 Sep 2023 23:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237769AbjIIDh3 (ORCPT ); Fri, 8 Sep 2023 23:37:29 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1927E1FE9 for ; Fri, 8 Sep 2023 20:37:25 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55D1CC433C9; Sat, 9 Sep 2023 03:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694230644; bh=CWWNXIT/Dwd1+BhRyAHtcclmBn8xtMZ9uwzWWOesbz8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G4g9Ika5VasJRZpdNkehsQGg8kmNgm1qwLM5nZc1OQ3bp6R4DT1lFH3+zQDyEhyuv mefns1GVzCJtq+OvVa44z8SXvojBkwZ34RpBCIV1f5cCrtu/W7gTjDfqjXKyttEonk /4N1vy0njVJ9mulokK5u9jis8z2OUzLntqRp8t07GX2o24Kwfc2nr74r5yzPoYtRRp XHMGOcsoRuAex+MbtNun2Ggn/Y+i1aTbNVuNSbMvQjpAERbfaphUfeGRNyJ6Yd1iAj OuFS/cHAejFEM+RrL/gstTaIoFQXWfmO+6ELklli6wCU9/VV+c6IGRUfZJGWdtfprd faNCXU0uVKbnA== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC 1/8] mm/damon/core: define and use a dedicated function for region access rate update Date: Sat, 9 Sep 2023 03:37:04 +0000 Message-Id: <20230909033711.55794-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230909033711.55794-1-sj@kernel.org> References: <20230909033711.55794-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Each DAMON operarions set is updating nr_accesses field of each damon_region for each of their access check results, from the check_accesses() callback. Directly accessing the field could make things complex to manage and change in future. Define and use a dedicated function for the purpose. Signed-off-by: SeongJae Park --- include/linux/damon.h | 5 ++++- mm/damon/core.c | 16 ++++++++++++++++ mm/damon/paddr.c | 6 ++---- mm/damon/vaddr.c | 6 ++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 9a32b8fd0bd3..17c504d236b9 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -45,7 +45,9 @@ struct damon_addr_range { * * @nr_accesses is reset to zero for every &damon_attrs->aggr_interval and= be * increased for every &damon_attrs->sample_interval if an access to the r= egion - * during the last sampling interval is found. + * during the last sampling interval is found. The update of this field s= hould + * not be done with direct access but with the helper function, + * damon_update_region_access_rate(). * * @age is initially zero, increased for each aggregation interval, and re= set * to zero again if the access frequency is significantly changed. If two @@ -620,6 +622,7 @@ void damon_add_region(struct damon_region *r, struct da= mon_target *t); void damon_destroy_region(struct damon_region *r, struct damon_target *t); int damon_set_regions(struct damon_target *t, struct damon_addr_range *ran= ges, unsigned int nr_ranges); +void damon_update_region_access_rate(struct damon_region *r, bool accessed= ); =20 struct damos_filter *damos_new_filter(enum damos_filter_type type, bool matching); diff --git a/mm/damon/core.c b/mm/damon/core.c index 6f37997afc54..3d51a1dfe104 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1589,6 +1589,22 @@ int damon_set_region_biggest_system_ram_default(stru= ct damon_target *t, return damon_set_regions(t, &addr_range, 1); } =20 +/** + * damon_update_region_access_rate() - Update the access rate of a region. + * @r: The DAMON region to update for its access check result. + * @accessed: Whether the region has accessed during last sampling interva= l. + * + * Update the access rate of a region with the region's last sampling inte= rval + * access check result. + * + * Usually this will be called by &damon_operations->check_accesses callba= ck. + */ +void damon_update_region_access_rate(struct damon_region *r, bool accessed) +{ + if (accessed) + r->nr_accesses++; +} + static int __init damon_init(void) { damon_region_cache =3D KMEM_CACHE(damon_region, 0); diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 909db25efb35..44f21860b555 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -157,14 +157,12 @@ static void __damon_pa_check_access(struct damon_regi= on *r) /* If the region is in the last checked page, reuse the result */ if (ALIGN_DOWN(last_addr, last_folio_sz) =3D=3D ALIGN_DOWN(r->sampling_addr, last_folio_sz)) { - if (last_accessed) - r->nr_accesses++; + damon_update_region_access_rate(r, last_accessed); return; } =20 last_accessed =3D damon_pa_young(r->sampling_addr, &last_folio_sz); - if (last_accessed) - r->nr_accesses++; + damon_update_region_access_rate(r, last_accessed); =20 last_addr =3D r->sampling_addr; } diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 4c81a9dbd044..7fc0bda73b4c 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -566,14 +566,12 @@ static void __damon_va_check_access(struct mm_struct = *mm, /* If the region is in the last checked page, reuse the result */ if (same_target && (ALIGN_DOWN(last_addr, last_folio_sz) =3D=3D ALIGN_DOWN(r->sampling_addr, last_folio_sz))) { - if (last_accessed) - r->nr_accesses++; + damon_update_region_access_rate(r, last_accessed); return; } =20 last_accessed =3D damon_va_young(mm, r->sampling_addr, &last_folio_sz); - if (last_accessed) - r->nr_accesses++; + damon_update_region_access_rate(r, last_accessed); =20 last_addr =3D r->sampling_addr; } --=20 2.25.1 From nobody Thu Dec 18 19:03:15 2025 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 E3779EEB583 for ; Sat, 9 Sep 2023 03:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241049AbjIIDhd (ORCPT ); Fri, 8 Sep 2023 23:37:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238658AbjIIDha (ORCPT ); Fri, 8 Sep 2023 23:37:30 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A61381FE0 for ; Fri, 8 Sep 2023 20:37:25 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE9D3C433CA; Sat, 9 Sep 2023 03:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694230645; bh=i00VYLhoAf7cwF/8O1Xi88bbaOl2lSsV4k5ng0qJ0ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VD7vx44U9dFth1mw8DD6/tF3vY8dJrY4i0AbyDhCeIvUZ0PjoyjTr0uDrc4XE++6n GKp6zJxyQBZgrTBQa3ylYI1tcapLevgnxvqbFpynlo61t/XVs6nxWadFFQ7Lh6ptWr Fo0v4zlMnz571bTWOm/PJ9kouinp00CWg6XtI/LEvgRfidGdzVyDiYmXcHo71yevdR vrv79Lsj0MmfleOGdqLnGH9DolmAid835/T8ZIwLIUkzZY2si3odwvphQjQNLxTdzD TltpVKUxSogUHAUYT7Fa7Ds0wUbsk6PPBcwzRrlSeZUTuzdfWn8WTwYW4jz5Ye7nkZ 9A7wodJebTOzw== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC 2/8] mm/damon/vaddr: call damon_update_region_access_rate() always Date: Sat, 9 Sep 2023 03:37:05 +0000 Message-Id: <20230909033711.55794-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230909033711.55794-1-sj@kernel.org> References: <20230909033711.55794-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When getting mm_struct of the monitoring target process fails, there wil be no need to increase the access rate counter (nr_accesses) of the regions for the process. Hence, damon_va_check_accesses() skips calling damon_update_region_access_rate() in the case. This breaks the assumption that damon_update_region_access_rate() is called for every region, for every sampling interval. Call the function for every region even in the case. This might increase the overhead in some cases, but such case would not be frequent, so no significant impact is really expected. Signed-off-by: SeongJae Park --- mm/damon/vaddr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 7fc0bda73b4c..e36303271f9d 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -563,6 +563,11 @@ static void __damon_va_check_access(struct mm_struct *= mm, static unsigned long last_folio_sz =3D PAGE_SIZE; static bool last_accessed; =20 + if (!mm) { + damon_update_region_access_rate(r, false); + return; + } + /* If the region is in the last checked page, reuse the result */ if (same_target && (ALIGN_DOWN(last_addr, last_folio_sz) =3D=3D ALIGN_DOWN(r->sampling_addr, last_folio_sz))) { @@ -586,15 +591,14 @@ static unsigned int damon_va_check_accesses(struct da= mon_ctx *ctx) =20 damon_for_each_target(t, ctx) { mm =3D damon_get_mm(t); - if (!mm) - continue; same_target =3D false; damon_for_each_region(r, t) { __damon_va_check_access(mm, r, same_target); max_nr_accesses =3D max(r->nr_accesses, max_nr_accesses); same_target =3D true; } - mmput(mm); + if (mm) + mmput(mm); } =20 return max_nr_accesses; --=20 2.25.1 From nobody Thu Dec 18 19:03:15 2025 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 8461CEEB57F for ; Sat, 9 Sep 2023 03:37:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241479AbjIIDhf (ORCPT ); Fri, 8 Sep 2023 23:37:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236207AbjIIDha (ORCPT ); Fri, 8 Sep 2023 23:37:30 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 482BC1FE3 for ; Fri, 8 Sep 2023 20:37:26 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8618BC433CD; Sat, 9 Sep 2023 03:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694230645; bh=1JPnDKE1W//tJKT6oD5avrUOMToQr068Qq2WbN1Xk+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rusog3teG9hcnEOtFyrYq2Kl4tI6tcDkZHp8n1Y4H16VjWB/4DsOGZfuLTLsJm8nS /KC1kgaBiz/iwm9Mr+LOZkYK+jSgGPPIWvD+2zxifQDAR46fduvL1wLbxmfj2msgTQ pN/SHQdgeA2UmefHF2RbIODyciN8YusgRbTKifrDqmCndCNyUO66LeDAEmPihhRw9T 837t6pOuHXZ4rYjplr0cE5XHFi7BnwTZs4HC4CQl6RKBSfh3FuScz6o/+wAcle06Xz YZ1V1VZ2DLJma6bJ/qucOOstW6arYNziXh8dDPJl00i1FKQEKo70rgEhWHM1nRFZpX tjCjSSs1RtP5w== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC 3/8] mm/damon/core: implement a pseudo-moving sum function Date: Sat, 9 Sep 2023 03:37:06 +0000 Message-Id: <20230909033711.55794-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230909033711.55794-1-sj@kernel.org> References: <20230909033711.55794-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" For values that continuously change, moving average or sum are good ways to provide fast updates while handling temporal and errorneous variability of the value. For example, the access rate counter (nr_accesses) is calculated as a sum of the number of positive sampled access check results that collected during a discrete time window (aggregation interval), and hence it handles temporal and errorneous access check results, but provides the update only for every aggregation interval. Using a moving sum method for that could allow providing the value for every sampling interval. That could be useful for getting monitoring results snapshot or running DAMOS in fine-grained timing. However, supporting the moving sum for cases that number of samples in the time window is arbirary could impose high overhead, since the number of past values that it needs to keep could be too high. The nr_accesses would also be one of the cases. To mitigate the overhead, implement a pseudo-moving sum function that only provides an estimated pseudo-moving sum. It assumes there was no error in last discrete time window and subtract constant portion of last discrete time window sum. Note that the function is not strictly implementing the moving sum, but it keeps a property of moving sum, which makes the value same to the dsicrete-window based sum for each time window-aligned timing. Hence, people collecting the value in the old timings would show no difference. Signed-off-by: SeongJae Park --- include/linux/damon.h | 2 ++ mm/damon/core.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 17c504d236b9..487a545a11b4 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -622,6 +622,8 @@ void damon_add_region(struct damon_region *r, struct da= mon_target *t); void damon_destroy_region(struct damon_region *r, struct damon_target *t); int damon_set_regions(struct damon_target *t, struct damon_addr_range *ran= ges, unsigned int nr_ranges); +unsigned int damon_moving_sum(unsigned int mvsum, unsigned int nomvsum, + unsigned int len_window, unsigned int new_value); void damon_update_region_access_rate(struct damon_region *r, bool accessed= ); =20 struct damos_filter *damos_new_filter(enum damos_filter_type type, diff --git a/mm/damon/core.c b/mm/damon/core.c index 3d51a1dfe104..5bc0544b9f50 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1589,6 +1589,46 @@ int damon_set_region_biggest_system_ram_default(stru= ct damon_target *t, return damon_set_regions(t, &addr_range, 1); } =20 +/* + * damon_moving_sum() - Calculate an inferred moving sum value. + * @mvsum: Inferred sum of the last @len_window values. + * @nomvsum: Non-moving sum of the last discrete @len_window window values. + * @len_window: The number of last values to take care of. + * @new_value: New value that will be added to the pseudo moving sum. + * + * Moving sum (moving average * window size) is good for handling noise, b= ut + * the cost of keeping past values can be high for arbitrary window size. = This + * function implements a lightweight pseudo moving sum function that doesn= 't + * keep the past window values. + * + * It simply assumes there was no noise in the past, and get the no-noise + * assumed past value to drop from @nomvsum and @len_window. @nomvsum is a + * non-moving sum of the last window. For example, if @len_window is 10 a= nd we + * have 25 values, @nomvsum is the sum of the 11th to 20th values of the 25 + * values. Hence, this function simply drops @nomvsum / @len_window from + * given @mvsum and add @new_value. + * + * For example, if @len_window is 10 and @nomvsum is 50, the last 10 value= s for + * the last window could be vary, e.g., 0, 10, 0, 10, 0, 10, 0, 0, 0, 20. = For + * calculating next moving sum with a new value, we should drop 0 from 50 = and + * add the new value. However, this function assumes it got value 5 for e= ach + * of the last ten times. Based on the assumption, when the next value is + * measured, it drops the assumed past value, 5 from the current sum, and = add + * the new value to get the updated pseduo-moving average. + * + * This means the value could have errors, but the errors will be disappea= red + * for every @len_window aligned calls. For example, if @len_window is 10= , the + * pseudo moving sum with 11th value to 19th value would have an error. B= ut + * the sum with 20th value will not have the error. + * + * Return: Pseudo-moving average after getting the @new_value. + */ +unsigned int damon_moving_sum(unsigned int mvsum, unsigned int nomvsum, + unsigned int len_window, unsigned int new_value) +{ + return mvsum - nomvsum / len_window + new_value; +} + /** * damon_update_region_access_rate() - Update the access rate of a region. * @r: The DAMON region to update for its access check result. --=20 2.25.1 From nobody Thu Dec 18 19:03:15 2025 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 D145DEEB582 for ; Sat, 9 Sep 2023 03:37:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241642AbjIIDhi (ORCPT ); Fri, 8 Sep 2023 23:37:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239261AbjIIDha (ORCPT ); Fri, 8 Sep 2023 23:37:30 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 236861FE5; Fri, 8 Sep 2023 20:37:27 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AA87C433C8; Sat, 9 Sep 2023 03:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694230646; bh=xT8faQ/VQn4QsrSETrKl21TSbXbkbXRLNmsjtMslsE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6nGX0tPVQa7fCjabWv9V2jpJs1DiN5xW7gllO09XsezCUlzsXPYyvzHVicPumwDV lQnjQlf0l+hoeoKIWbMAHjjrxe9+3JDdv8MpG5M9yHTg23+or5jvfqib8eX3+JpL2y Tgl+amkWP0P6lRiUwZcxGAi/ZVz6ECjZVVZBqKKd/9sNED8QDpRKxGOAfgsV77P3sV RvEBOP5H8fZIhDl871XivTV6JqG8VefCQc56DqGs/IhVAYPgftaTalFZp8iP0Vfy9N WNu3+4BqDt7DOpVmHvOL6X8XAsYAqNm6XCbHkhz2n5C4kvbPJKktYT2qEQy54weRGP Ed5aJ0cXUmMYw== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , Brendan Higgins , damon@lists.linux.dev, linux-mm@kvack.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC 4/8] mm/damon/core-test: add a unit test for damon_moving_sum() Date: Sat, 9 Sep 2023 03:37:07 +0000 Message-Id: <20230909033711.55794-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230909033711.55794-1-sj@kernel.org> References: <20230909033711.55794-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a simple unit test for the pseudo moving-sum function (damon_moving_sum()). Signed-off-by: SeongJae Park --- mm/damon/core-test.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index 6cc8b245586d..c539f0e8377e 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -341,6 +341,21 @@ static void damon_test_set_attrs(struct kunit *test) KUNIT_EXPECT_EQ(test, damon_set_attrs(c, &invalid_attrs), -EINVAL); } =20 +static void damon_test_moving_sum(struct kunit *test) +{ + unsigned int mvsum =3D 50000, nomvsum =3D 50000, len_window =3D 10; + unsigned int new_values[] =3D {10000, 0, 10000, 0, 0, 0, 10000, 0, 0, 0}; + unsigned int expects[] =3D {55000, 50000, 55000, 50000, 45000, 40000, + 45000, 40000, 35000, 30000}; + int i; + + for (i =3D 0; i < ARRAY_SIZE(new_values); i++) { + mvsum =3D damon_moving_sum(mvsum, nomvsum, len_window, + new_values[i]); + KUNIT_EXPECT_EQ(test, mvsum, expects[i]); + } +} + static void damos_test_new_filter(struct kunit *test) { struct damos_filter *filter; @@ -425,6 +440,7 @@ static struct kunit_case damon_test_cases[] =3D { KUNIT_CASE(damon_test_set_regions), KUNIT_CASE(damon_test_update_monitoring_result), KUNIT_CASE(damon_test_set_attrs), + KUNIT_CASE(damon_test_moving_sum), KUNIT_CASE(damos_test_new_filter), KUNIT_CASE(damos_test_filter_out), {}, --=20 2.25.1 From nobody Thu Dec 18 19:03:15 2025 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 6BF2BEEB581 for ; Sat, 9 Sep 2023 03:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243198AbjIIDhk (ORCPT ); Fri, 8 Sep 2023 23:37:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237769AbjIIDhb (ORCPT ); Fri, 8 Sep 2023 23:37:31 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F7311FE0 for ; Fri, 8 Sep 2023 20:37:27 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3A86C4339A; Sat, 9 Sep 2023 03:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694230647; bh=mrmW1/+KNJqZoPin01nmYe0xzn8mqXbGYK0Xoycksvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ip76wGuy1kQclDid3O3Hr+H5aEqWsLxQ9VqlQGBqDbPNn4DIjYmx7dNVCCEDUXl6+ qSKTUGWoIiZ6CkGeDuD/wIu6qJzbPCAJdOpDMLb415uyHG6hCONMG0hJdxH0B/A2Tv zcBSITAi15CoDEkGyEkmGRB3Cr8zNVJHoTSnrjcWnmZH8pkLudRjKX5RInhXJj6EVd pydN8L02IK71T4nYiVFOGkkpWvbkqTwjrjVpXQ9vDASI17I89KJ90cOoWuM1vkrLtC mOVkysAoFWjhh2nZmHS0RF5ENIcMuJf2Vt70WNzYnDE0lMJKBSCtNUbzarm6e2VDzk 5klC4ikfyfMTQ== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC 5/8] mm/damon/core: introduce nr_accesses_bp Date: Sat, 9 Sep 2023 03:37:08 +0000 Message-Id: <20230909033711.55794-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230909033711.55794-1-sj@kernel.org> References: <20230909033711.55794-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add yet another representation of the access rate of each region, namely nr_accesses_bp. It is just same to the nr_accesses but represents the value in basis point (1 in 10,000), and updated at once in every aggregation interval. That is, moving_accesses_bp is just nr_accesses * 10000. This may seems useless at the moment. However, it will be useful for representing less than one nr_accesses value that will be needed to make moving sum-based nr_accesses. Signed-off-by: SeongJae Park --- include/linux/damon.h | 5 +++++ mm/damon/core-test.h | 5 +++++ mm/damon/core.c | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 487a545a11b4..15f24b23c9a0 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -40,6 +40,7 @@ struct damon_addr_range { * @ar: The address range of the region. * @sampling_addr: Address of the sample for the next access check. * @nr_accesses: Access frequency of this region. + * @nr_accesses_bp: @nr_accesses in basis point (0.01%). * @list: List head for siblings. * @age: Age of this region. * @@ -49,6 +50,9 @@ struct damon_addr_range { * not be done with direct access but with the helper function, * damon_update_region_access_rate(). * + * @nr_accesses_bp is another representation of @nr_accesses in basis point + * (1 in 10,000) that updated every aggregation interval. + * * @age is initially zero, increased for each aggregation interval, and re= set * to zero again if the access frequency is significantly changed. If two * regions are merged into a new region, both @nr_accesses and @age of the= new @@ -58,6 +62,7 @@ struct damon_region { struct damon_addr_range ar; unsigned long sampling_addr; unsigned int nr_accesses; + unsigned int nr_accesses_bp; struct list_head list; =20 unsigned int age; diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index c539f0e8377e..79f1f12e0dd5 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -94,6 +94,7 @@ static void damon_test_aggregate(struct kunit *test) for (ir =3D 0; ir < 3; ir++) { r =3D damon_new_region(saddr[it][ir], eaddr[it][ir]); r->nr_accesses =3D accesses[it][ir]; + r->nr_accesses_bp =3D accesses[it][ir] * 10000; damon_add_region(r, t); } it++; @@ -147,9 +148,11 @@ static void damon_test_merge_two(struct kunit *test) t =3D damon_new_target(); r =3D damon_new_region(0, 100); r->nr_accesses =3D 10; + r->nr_accesses_bp =3D 100000; damon_add_region(r, t); r2 =3D damon_new_region(100, 300); r2->nr_accesses =3D 20; + r2->nr_accesses_bp =3D 200000; damon_add_region(r2, t); =20 damon_merge_two_regions(t, r, r2); @@ -196,6 +199,7 @@ static void damon_test_merge_regions_of(struct kunit *t= est) for (i =3D 0; i < ARRAY_SIZE(sa); i++) { r =3D damon_new_region(sa[i], ea[i]); r->nr_accesses =3D nrs[i]; + r->nr_accesses_bp =3D nrs[i] * 10000; damon_add_region(r, t); } =20 @@ -297,6 +301,7 @@ static void damon_test_update_monitoring_result(struct = kunit *test) struct damon_region *r =3D damon_new_region(3, 7); =20 r->nr_accesses =3D 15; + r->nr_accesses_bp =3D 150000; r->age =3D 20; =20 new_attrs =3D (struct damon_attrs){ diff --git a/mm/damon/core.c b/mm/damon/core.c index 5bc0544b9f50..a97026489301 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -134,6 +134,7 @@ struct damon_region *damon_new_region(unsigned long sta= rt, unsigned long end) region->ar.start =3D start; region->ar.end =3D end; region->nr_accesses =3D 0; + region->nr_accesses_bp =3D 0; INIT_LIST_HEAD(®ion->list); =20 region->age =3D 0; @@ -537,6 +538,7 @@ static void damon_update_monitoring_result(struct damon= _region *r, { r->nr_accesses =3D damon_nr_accesses_for_new_attrs(r->nr_accesses, old_attrs, new_attrs); + r->nr_accesses_bp =3D r->nr_accesses * 10000; r->age =3D damon_age_for_new_attrs(r->age, old_attrs, new_attrs); } =20 @@ -1148,6 +1150,7 @@ static void damon_merge_two_regions(struct damon_targ= et *t, =20 l->nr_accesses =3D (l->nr_accesses * sz_l + r->nr_accesses * sz_r) / (sz_l + sz_r); + l->nr_accesses_bp =3D l->nr_accesses * 10000; l->age =3D (l->age * sz_l + r->age * sz_r) / (sz_l + sz_r); l->ar.end =3D r->ar.end; =20 @@ -1179,6 +1182,8 @@ static void damon_merge_regions_of(struct damon_targe= t *t, unsigned int thres, else r->age++; =20 + r->nr_accesses_bp =3D r->nr_accesses * 10000; + if (prev && prev->ar.end =3D=3D r->ar.start && abs(prev->nr_accesses - r->nr_accesses) <=3D thres && damon_sz_region(prev) + damon_sz_region(r) <=3D sz_limit) @@ -1233,6 +1238,7 @@ static void damon_split_region_at(struct damon_target= *t, =20 new->age =3D r->age; new->last_nr_accesses =3D r->last_nr_accesses; + new->nr_accesses_bp =3D r->nr_accesses_bp; =20 damon_insert_region(new, r, damon_next_region(r), t); } --=20 2.25.1 From nobody Thu Dec 18 19:03:15 2025 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 93A28EEB582 for ; Sat, 9 Sep 2023 03:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243954AbjIIDhm (ORCPT ); Fri, 8 Sep 2023 23:37:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239974AbjIIDhc (ORCPT ); Fri, 8 Sep 2023 23:37:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DE6F1FE5 for ; Fri, 8 Sep 2023 20:37:28 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 805D7C433C9; Sat, 9 Sep 2023 03:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694230647; bh=ugkHqkw7yl130d3cjNnQjhDRwZWu/ujQKtPoxpJY3zc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tVutAxv4NGTAsH9JU8KYYDMBIibZhveJyySt4YiREVpzBp4Kgnvnr6Lhff2Uvnkvv WnOpiFOHRBmjWqJ4pAAWXWiiNP1cm6M76idSJnmIcEPp1RID5/jgf0Ce6JMdbsr4et hxtMYclLYMlcSZRhLUtDVINrsCb3MS/i70CjffezmLzikjkNeehVjsoXQMR1ekndIb 00/hgnsL+Fbe6GfYHF8wncDZN582NEtDhPZyikUTOvaNaSmtnJ4GvUjJzjk+sFb6GF 7E2oJ8kxURwt9U1Mgw9kCCqLsnN6FtMRfRnzaO4May4NrAgppDWAETNS/jDDJG28+5 BSPmzIkC83nWw== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC 6/8] mm/damon/core: use pseudo-moving sum for nr_accesses_bp Date: Sat, 9 Sep 2023 03:37:09 +0000 Message-Id: <20230909033711.55794-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230909033711.55794-1-sj@kernel.org> References: <20230909033711.55794-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Let nr_accesses_bp be calculated as a pseudo-moving sum that updated for every sampling interval, using damon_moving_sum(). This is assumed to be useful for cases that the aggregation interval is set quite huge, but the monivoting results need to be collected earlier than next aggregation interval is passed. Signed-off-by: SeongJae Park --- include/linux/damon.h | 12 +++++++++--- mm/damon/core.c | 16 +++++++++++++++- mm/damon/paddr.c | 9 +++++---- mm/damon/vaddr.c | 12 +++++++----- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 15f24b23c9a0..0fe13482df63 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -40,7 +40,8 @@ struct damon_addr_range { * @ar: The address range of the region. * @sampling_addr: Address of the sample for the next access check. * @nr_accesses: Access frequency of this region. - * @nr_accesses_bp: @nr_accesses in basis point (0.01%). + * @nr_accesses_bp: @nr_accesses in basis point (0.01%) that updated for + * each sampling interval. * @list: List head for siblings. * @age: Age of this region. * @@ -51,7 +52,11 @@ struct damon_addr_range { * damon_update_region_access_rate(). * * @nr_accesses_bp is another representation of @nr_accesses in basis point - * (1 in 10,000) that updated every aggregation interval. + * (1 in 10,000) that updated for every &damon_attrs->sample_interval in a + * manner similar to moving sum. By the algorithm, this value becomes + * @nr_accesses * 10000 for every &struct damon_attrs->aggr_interval. Thi= s can + * be used when the aggregation interval is too huge and therefore cannot = wait + * for it before getting the access monitoring results. * * @age is initially zero, increased for each aggregation interval, and re= set * to zero again if the access frequency is significantly changed. If two @@ -629,7 +634,8 @@ int damon_set_regions(struct damon_target *t, struct da= mon_addr_range *ranges, unsigned int nr_ranges); unsigned int damon_moving_sum(unsigned int mvsum, unsigned int nomvsum, unsigned int len_window, unsigned int new_value); -void damon_update_region_access_rate(struct damon_region *r, bool accessed= ); +void damon_update_region_access_rate(struct damon_region *r, bool accessed, + struct damon_attrs *attrs); =20 struct damos_filter *damos_new_filter(enum damos_filter_type type, bool matching); diff --git a/mm/damon/core.c b/mm/damon/core.c index a97026489301..c813407c09b4 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1639,14 +1639,28 @@ unsigned int damon_moving_sum(unsigned int mvsum, u= nsigned int nomvsum, * damon_update_region_access_rate() - Update the access rate of a region. * @r: The DAMON region to update for its access check result. * @accessed: Whether the region has accessed during last sampling interva= l. + * @attrs: The damon_attrs of the DAMON context. * * Update the access rate of a region with the region's last sampling inte= rval * access check result. * * Usually this will be called by &damon_operations->check_accesses callba= ck. */ -void damon_update_region_access_rate(struct damon_region *r, bool accessed) +void damon_update_region_access_rate(struct damon_region *r, bool accessed, + struct damon_attrs *attrs) { + unsigned int len_window =3D 1; + + /* + * sample_interval can be zero, but cannot be larger than + * aggr_interval, owing to validation of damon_set_attrs(). + */ + if (attrs->sample_interval) + len_window =3D attrs->aggr_interval / attrs->sample_interval; + r->nr_accesses_bp =3D damon_moving_sum(r->nr_accesses_bp, + r->last_nr_accesses * 10000, len_window, + accessed ? 10000 : 0); + if (accessed) r->nr_accesses++; } diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 44f21860b555..081e2a325778 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -148,7 +148,8 @@ static bool damon_pa_young(unsigned long paddr, unsigne= d long *folio_sz) return accessed; } =20 -static void __damon_pa_check_access(struct damon_region *r) +static void __damon_pa_check_access(struct damon_region *r, + struct damon_attrs *attrs) { static unsigned long last_addr; static unsigned long last_folio_sz =3D PAGE_SIZE; @@ -157,12 +158,12 @@ static void __damon_pa_check_access(struct damon_regi= on *r) /* If the region is in the last checked page, reuse the result */ if (ALIGN_DOWN(last_addr, last_folio_sz) =3D=3D ALIGN_DOWN(r->sampling_addr, last_folio_sz)) { - damon_update_region_access_rate(r, last_accessed); + damon_update_region_access_rate(r, last_accessed, attrs); return; } =20 last_accessed =3D damon_pa_young(r->sampling_addr, &last_folio_sz); - damon_update_region_access_rate(r, last_accessed); + damon_update_region_access_rate(r, last_accessed, attrs); =20 last_addr =3D r->sampling_addr; } @@ -175,7 +176,7 @@ static unsigned int damon_pa_check_accesses(struct damo= n_ctx *ctx) =20 damon_for_each_target(t, ctx) { damon_for_each_region(r, t) { - __damon_pa_check_access(r); + __damon_pa_check_access(r, &ctx->attrs); max_nr_accesses =3D max(r->nr_accesses, max_nr_accesses); } } diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index e36303271f9d..af2cb82e1fad 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -557,26 +557,27 @@ static bool damon_va_young(struct mm_struct *mm, unsi= gned long addr, * r the region to be checked */ static void __damon_va_check_access(struct mm_struct *mm, - struct damon_region *r, bool same_target) + struct damon_region *r, bool same_target, + struct damon_attrs *attrs) { static unsigned long last_addr; static unsigned long last_folio_sz =3D PAGE_SIZE; static bool last_accessed; =20 if (!mm) { - damon_update_region_access_rate(r, false); + damon_update_region_access_rate(r, false, attrs); return; } =20 /* If the region is in the last checked page, reuse the result */ if (same_target && (ALIGN_DOWN(last_addr, last_folio_sz) =3D=3D ALIGN_DOWN(r->sampling_addr, last_folio_sz))) { - damon_update_region_access_rate(r, last_accessed); + damon_update_region_access_rate(r, last_accessed, attrs); return; } =20 last_accessed =3D damon_va_young(mm, r->sampling_addr, &last_folio_sz); - damon_update_region_access_rate(r, last_accessed); + damon_update_region_access_rate(r, last_accessed, attrs); =20 last_addr =3D r->sampling_addr; } @@ -593,7 +594,8 @@ static unsigned int damon_va_check_accesses(struct damo= n_ctx *ctx) mm =3D damon_get_mm(t); same_target =3D false; damon_for_each_region(r, t) { - __damon_va_check_access(mm, r, same_target); + __damon_va_check_access(mm, r, same_target, + &ctx->attrs); max_nr_accesses =3D max(r->nr_accesses, max_nr_accesses); same_target =3D true; } --=20 2.25.1 From nobody Thu Dec 18 19:03:15 2025 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 99224EEB57F for ; Sat, 9 Sep 2023 03:37:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243009AbjIIDhp (ORCPT ); Fri, 8 Sep 2023 23:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239970AbjIIDhc (ORCPT ); Fri, 8 Sep 2023 23:37:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 970491FE9 for ; Fri, 8 Sep 2023 20:37:28 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DD2AC433CC; Sat, 9 Sep 2023 03:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694230648; bh=T2wTbeMBvGg1oZ8nMQI/oEwy81mbG221hI8+18jJewo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M330diVcv9Kv8EFldGI7s8B5vCDzjiNiU4H2nlTH8r7+IiEwi5kUPhPW/GuRSKP5x v3IyZOtLRDLVfZ2WPK8Zkz9IrzCPN0ZTJ9nO4TsUmxF7xs9lVlqAAkfd8jXu6wYtVQ 91yY3g+LT32JKjm2Xx94XGmfyFt0XxQ+YkNTnDOHU8NosYA/liDzlDbrc+3MfWXejp IjwVRkebxbYSQ9sVjy87LpHF4LPtnNfK3UypHePRMR6wW33HnXGYmLjfFlhsTo67gU 8tbGUIUCWUodMZey4IKMSr8S4w70YMr164pmXvOXKWrnX1zKb/ZXBBK6k538Mu2WF8 ZZvnEWTpJZY6A== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC 7/8] mm/damon/core: skip updating nr_accesses_bp for each aggregation interval Date: Sat, 9 Sep 2023 03:37:10 +0000 Message-Id: <20230909033711.55794-8-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230909033711.55794-1-sj@kernel.org> References: <20230909033711.55794-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" damon_merge_regions_of(), which is called for each aggregation interval, updates nr_accesses_bp to nr_accesses * 10000. However, nr_accesses_bp is updated for each sampling interval via damon_moving_sum() using the aggregation interval as the moving time window. And by the definition of the algorithm, the value becomes same to discrete-window based sum for each time window-aligned time. Hence, nr_accesses_bp will be same to nr_accesses * 10000 for each aggregation interval without explicit update. Remove the unnecessary update of nr_accesses_bp in damon_merge_regions_of(). Signed-off-by: SeongJae Park --- mm/damon/core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index c813407c09b4..1ba7c4669263 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1182,8 +1182,6 @@ static void damon_merge_regions_of(struct damon_targe= t *t, unsigned int thres, else r->age++; =20 - r->nr_accesses_bp =3D r->nr_accesses * 10000; - if (prev && prev->ar.end =3D=3D r->ar.start && abs(prev->nr_accesses - r->nr_accesses) <=3D thres && damon_sz_region(prev) + damon_sz_region(r) <=3D sz_limit) --=20 2.25.1 From nobody Thu Dec 18 19:03:15 2025 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 75439EEB581 for ; Sat, 9 Sep 2023 03:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244725AbjIIDhr (ORCPT ); Fri, 8 Sep 2023 23:37:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240919AbjIIDhd (ORCPT ); Fri, 8 Sep 2023 23:37:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 314591FEA for ; Fri, 8 Sep 2023 20:37:29 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A803BC433CD; Sat, 9 Sep 2023 03:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694230649; bh=u4g+CGjCZbG2QHJKasID6b5E2s2G6qeOdsap6ruSGmY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Izsy8M9gmHRZoYcw3BIdjHqk4Bh4D39q8DOc/nlB1dcLYYvpMQGZxHev79ESz2uns WEu/9IXL70k9mccElhHgYBm8RqMZJk6rScKpW7vnlzL/IY3fsrVG5lAuul/mz7MdGn UJrGFRmo4XD9g1Q33/kCg0C+GCVOWZwGsjdlE5Q+MBBRu8xG/fnutSXgquG1SjGdnp b+iZW54q/5eZ9jpWecrLxzyz4UXNo3+AXEljpMjsI66zhNXb+aGUk22Q2BQx6qJJ/3 jT/ulxnTRocN/Vg5EAkvTeirS7OtTYYuLlQwTDc/RZrHcbr/aRpVaxBD2hrKfcwSJu Fp0dVQBatu+iw== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC 8/8] mm/damon/core: mark damon_moving_sum() as a static function Date: Sat, 9 Sep 2023 03:37:11 +0000 Message-Id: <20230909033711.55794-9-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230909033711.55794-1-sj@kernel.org> References: <20230909033711.55794-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The function is used by only mm/damon/core.c. Mark it as a static function. Signed-off-by: SeongJae Park --- include/linux/damon.h | 2 -- mm/damon/core.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 0fe13482df63..491fdd3e4c76 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -632,8 +632,6 @@ void damon_add_region(struct damon_region *r, struct da= mon_target *t); void damon_destroy_region(struct damon_region *r, struct damon_target *t); int damon_set_regions(struct damon_target *t, struct damon_addr_range *ran= ges, unsigned int nr_ranges); -unsigned int damon_moving_sum(unsigned int mvsum, unsigned int nomvsum, - unsigned int len_window, unsigned int new_value); void damon_update_region_access_rate(struct damon_region *r, bool accessed, struct damon_attrs *attrs); =20 diff --git a/mm/damon/core.c b/mm/damon/core.c index 1ba7c4669263..83b0cd329e84 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1627,7 +1627,7 @@ int damon_set_region_biggest_system_ram_default(struc= t damon_target *t, * * Return: Pseudo-moving average after getting the @new_value. */ -unsigned int damon_moving_sum(unsigned int mvsum, unsigned int nomvsum, +static unsigned int damon_moving_sum(unsigned int mvsum, unsigned int nomv= sum, unsigned int len_window, unsigned int new_value) { return mvsum - nomvsum / len_window + new_value; --=20 2.25.1