From patchwork Sat Sep 9 03:37:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13377946 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA53AEEB580 for ; Sat, 9 Sep 2023 03:37:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 003266B00F8; Fri, 8 Sep 2023 23:37:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA6746B00FE; Fri, 8 Sep 2023 23:37:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6E666B0102; Fri, 8 Sep 2023 23:37:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C6FFF6B00F8 for ; Fri, 8 Sep 2023 23:37:29 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 876FB40527 for ; Sat, 9 Sep 2023 03:37:29 +0000 (UTC) X-FDA: 81215649018.22.D0AE9C5 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf04.hostedemail.com (Postfix) with ESMTP id B52BD40004 for ; Sat, 9 Sep 2023 03:37:27 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=G4g9Ika5; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694230648; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xlq3E3DVQjLA3U4TLTkT3nYNLUiEsTpudJTXACXcv8w=; b=ay22P6VXyRyE40KEaaBFtd4Y7LprcCKmfcVIpoBGLakhwZVKBmvwD5e+70KHfR3oOjtAnF xeoVySvpO2ccM4j7K6Rc5BGRetOOPUBuYPjLtZ7mkI2sM8Lqnbo3+BVkdTI9acBMOcLLqi VeiQi11VPAvxGeJfmKfE/k28hyDNdB0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694230648; a=rsa-sha256; cv=none; b=c2s7sHAy+QgHRCXaLNJSihgu0Y9PnH1pW5v1zp0L4jbxcy7Yk2+85nM+zxyvNeZytd48M7 MEsIe26HMcFi5SgJ7uZBxG4rw7RJTULPoHV6FIBT6ETKMl5fFI5j7U+2V7tmyBFdFfktlJ b5LIRCGg8tIRa93aJmC04Ulc6jcrhm0= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=G4g9Ika5; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EF8FDB821D3; Sat, 9 Sep 2023 03:37:25 +0000 (UTC) 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 To: 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 X-Rspamd-Queue-Id: B52BD40004 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: x8ya7ni3xaspiqbg63qg5no5waj8nmd5 X-HE-Tag: 1694230647-676649 X-HE-Meta: U2FsdGVkX19ChyEmap+F2N7hHZP5lkwBbUdrB9RMKq27tC/m1Sc6k5C6iHPwrEYq+Q0XO21Yo7fKUtDKn3buBoeJb/GMNR6+9jweUsyDb854AINNDFAhlmjq8tzGkGPy0T0H3OHayGm/7EQkr5o8IWIRLnFu+z9Ys5DhnmXj6D+qK23wZrfOZoKT0iY52Pbp/98bS63+pNDF9i55J+nGKxto6aZ0w6vBbvaEav7WuVts0hjNqmUZNBU6MHrtSP7Ej0fxbMmH7VIrvViBPC0Kcz1jNnB3dVK0j4qQBvP30vIPrh/pNAoFg8WjQjJw4XHnPRXhsIuHDTrNo+O5wnptzAuGXF3QxSF2oJ6gZxg0MmMnXKb/4qEDiHbnBrVUWL46kQcgFVuXsWBDCaN1sIVzz36Q/2RpjWBhEvfo4U04l1MRDgm/Ruia7Q4VJQutYTgMbTO3D5knF19vuYNLSyLNsXReiQioOCK6IIo+fxVjQReIqyIGn6JPTONv48Nh8tpsoPvYF9kv2OMq47HnDpkIM2tuGq7Vj++2KZMQKT2DMqozKpKUF21aDrR1H5R/20cwXgirQnqZdQESbKYFENm1h9C72ztJFmx/eW9PysCYHaI1VJjglCXuuzXmBKdU+V4X9GixkCxlQgEEr5+O2FNPD6si7mQqeUNX+8QyBgX/qxAcRr/d2Ai44SmeQrh3TfITM8C144AoFnoct4KtTXYav+no/fFvblc3ObK6E57Hv1IAIp0lgFmAHpY20QTq5AmCkQ0h9lsBgrOAqhrlmsI23B+p/XVFgs9lbXqUN6JthA1LCcM+zP58EJzE1ybKJiuZcZMtlHHDn3TMl7MGajAdEpuAe7ODD38ijs8XnVtYWEohOuWQk5HAIreWkRBeYR968gcwby19U+Geq3oajsGjJxibnwUfTiHQMnALSwqXyxvRzpSqCpxXQrSW7Msw/i9W6l2zGmoKsJOPsCECBes qqFJktZd fruvsTx+KT2rj9UZIf84IBgWwNMBaDOVbkS1AG/7geZKrdxHkL0mAdp2sBQ64dGyHiRWQVGqaALIfDN/+K6OlSFVduLrZO7nuBxZW2Ir3k++LwKxxqOYmMh6WMqsHEM17nqH1vCi3+/aQ6BvuVxBs16OddglD0Ovv3akh6SVCxxAYVlJL7FSOIg0k0Zd3NtJ585mSlDP+d/1xBdsMlQOv9kR1n9Vc3nhDpftKZYviL1AQvatKo2DW2HzCAJW2jcW6XmO5FTn7Smbeyh0H/LSOX0fWMo5yJLrEd6La6LM11fqfQYlD+UZODDwFotPDibH8txZccFfy7RkDxjkbLnBWuiNQqA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 region - * during the last sampling interval is found. + * during the last sampling interval is found. The update of this field should + * 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 reset * 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 damon_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 *ranges, unsigned int nr_ranges); +void damon_update_region_access_rate(struct damon_region *r, bool accessed); 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(struct damon_target *t, return damon_set_regions(t, &addr_range, 1); } +/** + * 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 interval. + * + * Update the access rate of a region with the region's last sampling interval + * access check result. + * + * Usually this will be called by &damon_operations->check_accesses callback. + */ +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 = 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_region *r) /* If the region is in the last checked page, reuse the result */ if (ALIGN_DOWN(last_addr, last_folio_sz) == ALIGN_DOWN(r->sampling_addr, last_folio_sz)) { - if (last_accessed) - r->nr_accesses++; + damon_update_region_access_rate(r, last_accessed); return; } last_accessed = damon_pa_young(r->sampling_addr, &last_folio_sz); - if (last_accessed) - r->nr_accesses++; + damon_update_region_access_rate(r, last_accessed); last_addr = 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) == ALIGN_DOWN(r->sampling_addr, last_folio_sz))) { - if (last_accessed) - r->nr_accesses++; + damon_update_region_access_rate(r, last_accessed); return; } last_accessed = damon_va_young(mm, r->sampling_addr, &last_folio_sz); - if (last_accessed) - r->nr_accesses++; + damon_update_region_access_rate(r, last_accessed); last_addr = r->sampling_addr; } From patchwork Sat Sep 9 03:37:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13377951 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40E56EEB580 for ; Sat, 9 Sep 2023 03:37:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C9356B010B; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92B046B010A; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 789AD6B0106; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 648676B0106 for ; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 391C2404FB for ; Sat, 9 Sep 2023 03:37:33 +0000 (UTC) X-FDA: 81215649186.13.92E46B8 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf16.hostedemail.com (Postfix) with ESMTP id 3C40918000B for ; Sat, 9 Sep 2023 03:37:30 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VD7vx44U; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694230651; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=s9CCrAW2k5JfZmWyxspFJIvVkuWytxqxD9bxjnqhVns=; b=ymCXWVcOGmA83USBg45N/qVNYjwiBUVRLqgx0UauUi77nwhfRIhy0iNy2B6L27ilToaPtm ZYvInvfjK46avMTbsUud0oQzgQXppDEAhZeTwAJbtjTmgGj092IqbkpKeYaG6o+JWbQ7MG mZfakX6hOtFl89fc/Q4/KnfIUQfFGQw= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VD7vx44U; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694230651; a=rsa-sha256; cv=none; b=JN+Kon3BjZ/BDzwNvmysxN5YT1P5LtnPUgRZoaerYcAlcjudh1iZTlO3p5VoRv/LB3oDRc RIQApc1tlWUt4CR/LJiDxW7APaj30IycHPUeDIjZQDGIqtckdYR634KazPayqkRiogfFcX +CMtLobXxF3oIduoGr05HpuHsZAFaJ8= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 08B2DCE179F; Sat, 9 Sep 2023 03:37:27 +0000 (UTC) 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 To: 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 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3C40918000B X-Stat-Signature: 9weg7rrku3bt9qmgh8wpe6o7u1dozwjg X-HE-Tag: 1694230650-248639 X-HE-Meta: U2FsdGVkX1/dxygF95iG8tU75/fQ96XmMWsNnTim+1Sg97Ub7Mmv6siDst7GaQJYVKcX7uXQKDYWxuIERXo2Hj+9zcIj0Cv4KfYDgzZuj9Vk1mqBf2LvakFWl6xgypwn/3ctnZNAJa7l7q5OCuYDonuZeLSLnK35vVrRCO+/KZ+6Jy7E8m5diOQgeGU4elX78fg4IHHwb6WHAp4JlTEkKtrAWWcTHu0BWjrr5qokuThJTofvewxDSMEhnErzXqFibpad/4cWNY/ejouqPctWJsmrFaiGCug3qPdnz6B9qKsrK1gUqLAaACdDUzHmK0qBOxKrWb6TbLbPWpPXIub61llRL5O/vKdSCMEW1Kl15BcaPnfVHXmhNibVqydkdX/uACrZKoGITaGothHa93uw50JHPqKk+YN1lea/hAv0124IyW3DS2fbXAhEZ3kIdhD98H/deehKiwTDffXKXyT4ISojd5ctEs1zeL50VTgQ2XqKFP32ptOAozVVBOeE5I8GXpa5EHjA67NOS4mp119jkf8G9rTudB5EC5ce3kCPzoCsBxp8KGPtfFy7DBq9kz+yjkLXwNpNI+igaGInraztb9vLPkpGwYV+CrE/Zaxf6moknke9OONoq3FknLoIR7ZzPfLAM5hOutAF8KE5kK+fLJSqXlwox8GHZN1UEvg5pr/i9Eye0VsMSjMnSzAdvKyw7HURPqmbNpt0ENKOoC015kQtGHtV7RASmd9gd9oRoQ7pa/ndvX8u++xUDN5TkdgOZfn8D/XJJhJ446QnLBACy43EbgskTz1s+hdOhZUI635MTTT5IFxn76U0wkp55PuMAv0/EEwkEFrG0qFWpkSyjmipU5l7wK2jPhn981bKQGEIHCY+oiYBtEig9zxiy/ORH8hlQdr6O0LDjM7dRhdEK0kpTCpFIlidL7LwNVA/H9LZe6ST9hIcD8zXK8dXINAV5Jw9TtlWhSSOPwMfqBG rmWpfqS7 f23xmce3iMjzFhHR4+sDtwhKSlp2Bq6BimHpiiKymBwz/DxAgte5Pyjd/76rrORmEcdvJehkiJay1bPuvm9zQYd5BVrM7oY5+YhcqN1SC6MtkVQDVylgqzjL/6nod5LxCkhoA2wCBJhCgIBwTB9/LHG94aVt7ecz2MnvtQqhYMXc/OFluevDsnNPKFG9WkhNs+XG5KFJv5zapN1igVwMpPOOrB2JuMOhMXgbMGjmZ8EInSy7Vl7qvxvf6gdkEwQiGKcpAhWeMG5lzVc6uC+IBHqsNGYMbH1tGgbXuNubOMixVW8Fb9qMaYu6k5Ya+/u5XT9edJFjzlBGwWskH8ZQ1ceZoXOGn1cC3lv34HQPTN2ohDjqLX+nxoOzzrR8bXPPDoDdL X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 = PAGE_SIZE; static bool last_accessed; + 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) == ALIGN_DOWN(r->sampling_addr, last_folio_sz))) { @@ -586,15 +591,14 @@ static unsigned int damon_va_check_accesses(struct damon_ctx *ctx) damon_for_each_target(t, ctx) { mm = damon_get_mm(t); - if (!mm) - continue; same_target = false; damon_for_each_region(r, t) { __damon_va_check_access(mm, r, same_target); max_nr_accesses = max(r->nr_accesses, max_nr_accesses); same_target = true; } - mmput(mm); + if (mm) + mmput(mm); } return max_nr_accesses; From patchwork Sat Sep 9 03:37:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13377952 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9C5CEEB582 for ; Sat, 9 Sep 2023 03:37:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C73426B0106; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BEEDC6B0108; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C51F6B0109; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 819636B0108 for ; Fri, 8 Sep 2023 23:37:33 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5C5E6803C4 for ; Sat, 9 Sep 2023 03:37:33 +0000 (UTC) X-FDA: 81215649186.12.31D68BB Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf19.hostedemail.com (Postfix) with ESMTP id 2BB0A1A000B for ; Sat, 9 Sep 2023 03:37:30 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rusog3te; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694230651; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ah0N2wcnfsJahuzxk5G28ObKAJFHz+yeGpKpeyogRrc=; b=PSHecNo4sSdpLd/DvpitwbPXu2eyVAdzrAmIyf9R1itM7DUnmGcvMfJouoNUuQtesvFK9M KQSVtAs1PKgOxpLKKF7oSjPJhEm7S0ozM1T3vGz+WRw/mlEQTANthE1ofuq5ghOevN7pQU DqQ6KztrTyoa9TPHVKktQqPOl3wWkrI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rusog3te; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694230651; a=rsa-sha256; cv=none; b=6AGLKNNk2l5A/ZvVN+qynBc4kMBfytO7ALYcsMP2suYjPuEgKF8Ep9nd6Goy6zmOUBCByr DB+P+wlengnYmlCuROWzw57MKQah21qW7XCMY+bnzdnblsDCKqOtnhLXP15X+8T1n2Z5F1 DyU2sEMyz5UZRCh2fACsMB3S7Zig04U= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 2BFAFCE1D55; Sat, 9 Sep 2023 03:37:28 +0000 (UTC) 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 To: 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 X-Rspamd-Queue-Id: 2BB0A1A000B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ekgpnmmyjabz8j1pxg3cis8k4nay589i X-HE-Tag: 1694230650-317709 X-HE-Meta: U2FsdGVkX1/R3TWqS6qrmGm6KJtMFTOrl0OxI55kKh+89ZHc+0sGRYUokcSCbJyq7nP1bINxvKbgkKBV+iGeyJM8Txl6Ak9ClpVmPE5myJsi014l7awAin9Oa4UKVgHPpHhAtXgvz1BRao7y114nIKZpMYfuRlksZvqMXFF6Ks3FvJNCDnOYpEamuXkovlvFio6IEGjCHTF/EB47Wugf49hvyrUoVAwiC2WgWI1ypTn7g9QgtPrY8e2S+ZUkPdPLfic8rU81kszjhMaxOJR5sRUl2kWx/0Lf3HwNSonA1QLdL98nhP6b5Ai13XUfBXebGiCfJCFSXp7IKRhxooE7BvDjMfhe7fMI71qdDXqUSVa4Hm2meNQ7AV5IcE5+DSKPaQ8wO7ZIyTcSqv4Pd04ZboPR23srMdwLvihud7olL6gnspRyvJUbp3FdsCkIvFD2pN1259wI3gruUyjultaAAH40E5wLa89mws6TvrZ1+X3FTeM91ZbwwSacj+0OA7fTyL22Lzydy1x8MB6elYr0jDtlDFf4XI+OTIk4zmZHssV5s6jv59Q4C9YR5fUvtW2I7YQN+Ib73cWTE8vVMqbzdEB5FGrphiiW5z6eVTaNZBb4hYy/sctheJ74MnpGGp+mvV45rdPcPIOHB9s7P1mF6sae4TILQ6d+jAP1eSvylKfTuGINIKfBw9iGGdrPgpAEjN6YnnqNlaMiinl7/0GalnR2Ri86HrrcZ/yAsB/spvJwb4jvULkvUOxImUnzWsGXzBJ6eKMdUTrDGgbsfVF2xDrtahPHdkZ6kzBfVw/4pWfW8C8LNj4MoSA2cVyMm/ux+DZ3uIDh/Vv7V6M8DajkDavPlTzMV15wpX4zo/03qaPXc9vALzGf7Rlq4mXR92t79CrDSnrepwigWpnbCjxqcU4Qvy92d62M1XxR7UlIlz/dOsWZlh20aOvp5qARLhJaINMOqKAjI9Jr51Ak0tx JLT8f07U ARDC+8KkUWMKq2KHr+malSk1jdmjC0MtwzVecCH60lkYpopC6Yi+2rongHt00wpbgeLW3L9CIwSjlNjkDVShjtFjyf9jZLz2afjlLB7pk67j+drQf6EuzOY9RZRp//JtOfK2K1DpsbuRDk8bInDi38IFDZmYLtoRriexGLiit1HQV52M+kCbNkyO4VXdmc74EX3EYdWlqxIAKskuybmb/FqylxC4F4sXuiA2k1FTdtR1Fmf28Z0bepqCnv34Z/PqcgEA40UMIB222pSHPpQMCgYp/CThXaJzlgWNQI+4tNeq5jXH9/brL++CPPkXYp4+RKxiNd5ZBH83if0rQIq/nHcTmTg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001083, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 damon_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 *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); 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(struct damon_target *t, return damon_set_regions(t, &addr_range, 1); } +/* + * 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, but + * 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 and 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 values 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 each + * 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 disappeared + * 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. But + * 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. From patchwork Sat Sep 9 03:37:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13377948 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF3ADEEB581 for ; Sat, 9 Sep 2023 03:37:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 891F06B0105; Fri, 8 Sep 2023 23:37:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 823EE6B0106; Fri, 8 Sep 2023 23:37:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B9946B0105; Fri, 8 Sep 2023 23:37:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4ACC36B0103 for ; Fri, 8 Sep 2023 23:37:31 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0F5F51A04E1 for ; Sat, 9 Sep 2023 03:37:31 +0000 (UTC) X-FDA: 81215649102.16.7B973BD Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf06.hostedemail.com (Postfix) with ESMTP id 59D8C180003 for ; Sat, 9 Sep 2023 03:37:29 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q6nGX0tP; spf=pass (imf06.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694230649; a=rsa-sha256; cv=none; b=nVqKFy/YEaA1+DRyj113a+/m67nOKjoSe9+ZKu+vc0duqBGtV1lKMmArLY992tacgozt7s 5FQOvaQuZZoD2gMS6KpmuLWOGft0+sd/iWIsfUSF+K+49vVr91d5WJMMPkOYeAEUN8I35e QNzPYDI9iX0/jfAUTYUelHYfM/6/vy4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q6nGX0tP; spf=pass (imf06.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694230649; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=u9TmyMjuPTNAblor8OwPK1A1ey4pwH8Hdhs6lWbOca8=; b=O3DIEBn4MNntneGMWPPuHBIKHiCuBMm2lSALAnY/+YatfFLX9SigkrEVreWKcU4Fqz6gHW B+ieVzr6+qM4krfySYwhgYv12lSiGV+ZNSdwPhKWJ9w+7oTiV4dP/Pz0kWgiujKY/bgCW/ p/WAJr9VoKgfTMIYRf19wyVrs2Ma/sQ= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0B5FDB82335; Sat, 9 Sep 2023 03:37:28 +0000 (UTC) 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 To: 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 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 59D8C180003 X-Stat-Signature: wrmrc4f5rfaojcompxnep4ak9fk7q6yt X-Rspam-User: X-HE-Tag: 1694230649-880850 X-HE-Meta: U2FsdGVkX18sisTVsjxEfTR4vBgtR54fpEtR11GgpM0iksl8dwSNLciA1ltWH0/CMftcIbu2sWuIjNHtFH0a4ETSNbqwZVjoxVuHN+h4erYWGfI6KOH87YzDb0hyg3lwJQp3CBjVu2n2IgLVDkBj4LT630/NGzN/WpyaYkVEkf7g5BWF1h4iKaaBi+XI76dBtGu9EYVXRBiQVHEaTlcg2w7Nx3Qg0vJF/kRiVSjQaV7Z7Pf2qaH6JvYftcLt9Azg2SPI8NV1U7FWH5F24aNRre7OTkYkWQQAdUjk/38vY8eKFYBg2uipzrFxz9/LJQNepTAfOK+rXJ/Hojv/kfU0NhsNq4O6rF+0eecjtnA4g0ys48Wyeu0vNmFes93K9CRBvlNdu0kSQx6AicK71KVt0Yze+JopqPGcXmfHCE0ISIA0V2qONvSEArjf/yyScRgclqhgZDfQFHpWET85NdwRMVflTrfh8c++uAcnvMVgRE/g8VTOLco2RxuQUwm2gPckr3b4Dyz8/3DAI8sRSgj2WI+jCTsxlv1ENpyeCVZCjbcjUpOhYaSw6iwsRHsKPr3SupMBOlFrcX86biHOeTKejhHKOJKJLlvwQcvluZnfsCKeGbUkGNj4ijysVU/iJrCTKGCTcyfLAqvoyr+fKW6z/Wh1EO+MwVk5Xe6cRtdflqXPTiFJgus9JyeUFsBWSUutLvsIPKKtvEgZl+v90UxnflmbUsxXZgIm07pblihj2LPoGNj/ZxKNNc0mbnq7HBNnpaqLo16bYxUeFMg/r5UFiSdoXUSiN1ceJbuwSImlgx1YZ+zWCrG5MGDELWzMEBRtUPG+vKMDlt7+TuM02Qe6cNf3mrHn+0yMuhW71vspV5r5Qb9Gq7VbfnOkwcxzGI+eyRz0/0ip9S6TDrZA/0Cqvc7pyaawtkiacfmzJfgQqxSdXJX6fPBxHG6iDJ+z85Lk4Cma7dl7sLN5xb6Lkrk pMmGOr0Q 7xZAwKtT0OBF9K5eEkxL3bCOOovtrKC/Y4BRNQNreouKHsegMvM6h8oGpxojHqACL5Zv7D3WYTVPaPjZnhr6QLq6vgnYvTvQkZlq3oU1wzHXyAoZPLloGFcNsajSuIIzZhtWOePvW50+MWjSyjdc+gpBGOUV7HcOSBzPLW31wR71U3i68yKc1Tv8/vv7Gb5LWvr/uSFUGXF1cKTZzsF/T0mpHnGd8cjN/5GHLaxoZ9zug+DjX8fwTACOHDDLpgbvA77J2+IozqaCmStRzKaqmIQwK52JOBLE2pGkGF3WkLy7hEuQtuXaDsFYCDZeG+feKunpILncgHOs0AccYq4v5x1oRTzmU0rKvVhKTdemNIsU9U39WNKyNuhhrHQ8YZUcQgqNO X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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); } +static void damon_test_moving_sum(struct kunit *test) +{ + unsigned int mvsum = 50000, nomvsum = 50000, len_window = 10; + unsigned int new_values[] = {10000, 0, 10000, 0, 0, 0, 10000, 0, 0, 0}; + unsigned int expects[] = {55000, 50000, 55000, 50000, 45000, 40000, + 45000, 40000, 35000, 30000}; + int i; + + for (i = 0; i < ARRAY_SIZE(new_values); i++) { + mvsum = 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[] = { 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), {}, From patchwork Sat Sep 9 03:37:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13377947 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 708E3EEB584 for ; Sat, 9 Sep 2023 03:37:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B0F46B0102; Fri, 8 Sep 2023 23:37:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 160976B0103; Fri, 8 Sep 2023 23:37:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1C1A6B0104; Fri, 8 Sep 2023 23:37:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DE5526B0102 for ; Fri, 8 Sep 2023 23:37:30 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C580116027F for ; Sat, 9 Sep 2023 03:37:30 +0000 (UTC) X-FDA: 81215649060.21.F3F2B1B Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf22.hostedemail.com (Postfix) with ESMTP id 002BEC0002 for ; Sat, 9 Sep 2023 03:37:28 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ip76wGuy; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694230649; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SaXC8O4arGdhiJ1dzbeNeChkubxREk2+pcfb1cTA5D8=; b=QoDl9VkqbmJoczrWfynTxhc56RW1CM4XkokAhjN2k8EGcx9X0z25BPxRF8eeNQcmEPHKwI sTkPXJWGA4dbgO8DBG96wUW6E+snr5KKMRxN5aPOdB5KsMok9JfzY7YENu9HyHfCSzxget nvo+tAuwSBAf2K8pZQv/Xypv3BDwzVU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ip76wGuy; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694230649; a=rsa-sha256; cv=none; b=2YQjYGGPa/aQmm4HootUQES/JJYwavyGMokEvgzrR8Eg6JKQFGNFA3KQVzHT/A5/uU/d+V pSzIuLGT678/h1ALk93r9Iih0mf0bar4GKMxNeU1v2fVKjuhr6dKN4TYHLPUvhw5KeV/Pu i8y8vPyZ3sbdVcl0bZCFJgydGteo6nQ= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 97FB0B82334; Sat, 9 Sep 2023 03:37:27 +0000 (UTC) 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 To: 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 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 002BEC0002 X-Stat-Signature: tcxzworeatygh1s1p5j7cexhthedk8ib X-Rspam-User: X-HE-Tag: 1694230648-347017 X-HE-Meta: U2FsdGVkX18r+CZsa6O12bOMJfnoZrW+AxIlQi8EYaHs9Ye2PAbwLIkdozlWZj0bmSMYazEGwC2Rh573da9r5co4lVdnje7KQUQINwJ3WnjSV8J9zEFjXfEOPzYet0vdTAdPHun5NeyqJAAbRLUxXtQ/Pew82WXp5HKuZgql/BBUI3wnd8LFs13ok+zfBp2J5+cB7YqhiR8aFa46VKJzKEzoVrjRngbWasY07yZvhB2AOZxif+lsiE1S5mKr+cXsZioKo05i1uyUHCcwsGQcM5I3j8dAw+CsKlEkzvzWbmJY0gWppnmeCkXO54J6lIChC/SvIeQQfWGQVqiOlWcZ3Q+E1B4Z8NBbza97XCUkJ6vG6li+KM+A5uLcXw1IGGDpZMRII7NUzh6SFGJPXL+z3v9hirM2bRkNeKF8Wu0zSvml6BHkolUbRB+hfnVrNC/RMVgPQyyyveEJ9W0NdKyd5dYeHnSVukN4X//E32bPVCnN9ITVvzyuGPF8ItwZ+WBR/0jftbKSolX2vjlFsBp/Gik9a5B5MnP+LNJjZGk+AI22R1WIsh2IhqnYQ8XX3nPTd0SCTy67vvlyJ3BmZnAEk4YUmYkAoMVgRdbj41OgyXthorvPTVqQqsK5CM5FJxnIkeMtw2qknknB7YlBsx08RZPkBE6/DLbGoGP66WmsYDxuMHiKGRGJBuss8uaIdrx5R5Xe35YxXoOTis4clXrrFdLeuzRCZe8j++Pdk4lM3qGMWk1JtahXD6HRQO9Um9Xl9QYBNgvcQev2CZ5rh00EqZtJjKPA8xt3++Sqt8Tol4pY+59iIbSM12EdOUqEwj0JkJjfQiiQMZ8kY4bGacJhCFdWxOkfUjqRhjapFoqdaKM4hnympsKs4Iv+mG5zHcdzT7eF6OSz0SOpVhm45GGQCiT73rUleIA++6z8LAYxQ3sicqYU0/DEYn6a9ipC4VNvqMFjU2vlI2DC1WE/c0C kp7HtLIl NPvLYbAzyP1rBf0ebjt8Cn2OtREDi3qAHV4XczWYx3TBUK0pEkZCm8nf2hVQ0WNoD8zcDO2pvJAn5UgIzKF8eq8vqPBkYERjg5oV3jCDNbIur0nSqFgCkzBkP0r1tcfboLXaW3g8uA2ixLNjrhWSiRbS5+4oT1pRiC/yLmT0HBzfHlkno/k+x2h5iEPdeYcrhzGDcssshWzq7oj7kou4AupLLha+OQioLpo23kUAQuvV2ONmlEru/Jlcn/yZPyTROE91etzVd3Iy8GEd8A1rMfSsaikoPJPnsSrL5RzAguACdyGXJIR/sRjtr59HPw6LmPNuMADO0FmfulBDf5DFl3DMFQRqP6/XNV+hxboShjN1G967lwRoO55WU7r+p1iUqLWUd X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 reset * 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; 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 = 0; ir < 3; ir++) { r = damon_new_region(saddr[it][ir], eaddr[it][ir]); r->nr_accesses = accesses[it][ir]; + r->nr_accesses_bp = accesses[it][ir] * 10000; damon_add_region(r, t); } it++; @@ -147,9 +148,11 @@ static void damon_test_merge_two(struct kunit *test) t = damon_new_target(); r = damon_new_region(0, 100); r->nr_accesses = 10; + r->nr_accesses_bp = 100000; damon_add_region(r, t); r2 = damon_new_region(100, 300); r2->nr_accesses = 20; + r2->nr_accesses_bp = 200000; damon_add_region(r2, t); damon_merge_two_regions(t, r, r2); @@ -196,6 +199,7 @@ static void damon_test_merge_regions_of(struct kunit *test) for (i = 0; i < ARRAY_SIZE(sa); i++) { r = damon_new_region(sa[i], ea[i]); r->nr_accesses = nrs[i]; + r->nr_accesses_bp = nrs[i] * 10000; damon_add_region(r, t); } @@ -297,6 +301,7 @@ static void damon_test_update_monitoring_result(struct kunit *test) struct damon_region *r = damon_new_region(3, 7); r->nr_accesses = 15; + r->nr_accesses_bp = 150000; r->age = 20; new_attrs = (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 start, unsigned long end) region->ar.start = start; region->ar.end = end; region->nr_accesses = 0; + region->nr_accesses_bp = 0; INIT_LIST_HEAD(®ion->list); region->age = 0; @@ -537,6 +538,7 @@ static void damon_update_monitoring_result(struct damon_region *r, { r->nr_accesses = damon_nr_accesses_for_new_attrs(r->nr_accesses, old_attrs, new_attrs); + r->nr_accesses_bp = r->nr_accesses * 10000; r->age = damon_age_for_new_attrs(r->age, old_attrs, new_attrs); } @@ -1148,6 +1150,7 @@ static void damon_merge_two_regions(struct damon_target *t, l->nr_accesses = (l->nr_accesses * sz_l + r->nr_accesses * sz_r) / (sz_l + sz_r); + l->nr_accesses_bp = l->nr_accesses * 10000; l->age = (l->age * sz_l + r->age * sz_r) / (sz_l + sz_r); l->ar.end = r->ar.end; @@ -1179,6 +1182,8 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres, else r->age++; + r->nr_accesses_bp = r->nr_accesses * 10000; + if (prev && prev->ar.end == r->ar.start && abs(prev->nr_accesses - r->nr_accesses) <= thres && damon_sz_region(prev) + damon_sz_region(r) <= sz_limit) @@ -1233,6 +1238,7 @@ static void damon_split_region_at(struct damon_target *t, new->age = r->age; new->last_nr_accesses = r->last_nr_accesses; + new->nr_accesses_bp = r->nr_accesses_bp; damon_insert_region(new, r, damon_next_region(r), t); } From patchwork Sat Sep 9 03:37:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13377949 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DA70EEB57F for ; Sat, 9 Sep 2023 03:37:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5FFE6B0103; Fri, 8 Sep 2023 23:37:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0F1E6B0104; Fri, 8 Sep 2023 23:37:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92C186B0107; Fri, 8 Sep 2023 23:37:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7E1576B0103 for ; Fri, 8 Sep 2023 23:37:31 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5A1471A11B6 for ; Sat, 9 Sep 2023 03:37:31 +0000 (UTC) X-FDA: 81215649102.22.EC3606B Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf17.hostedemail.com (Postfix) with ESMTP id 857884000D for ; Sat, 9 Sep 2023 03:37:29 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tVutAxv4; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694230649; a=rsa-sha256; cv=none; b=6HBPMeMq7VWqLSm6vzxihyVIaVsOp6IVUOZIEm+G5OSjIu9SvVDmbrnDsTuC39xijJIOz4 2azHINSa1LyerGM6aimPQ71znIt7QaMPWSkvHIF5sbWcISIOplrOJhBRKgbu2OEsNpm4fW L59PcsKRNhY535TLrY7fTYDWaJBhl0o= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tVutAxv4; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694230649; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=k3COegnpRC19JcbUcYxuzktOO63xpTUqnEuucER9Yc8=; b=Pe1anRh5KISqCzKOdj3sNTbyalhXUxqjYc+JEkvi5xmhtNMRYKghxKE2IG4JKoQP8eKkBF DRZ/pGAT8UVzoEonO/xsTEVobiayhxDjtR/QYMKRDPk5obNKcj+ezf5Rb+IdCN4tfDjr9H hhGwNjm0oapXzBbRvyzenxdHfn+NxOs= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 34B27B82336; Sat, 9 Sep 2023 03:37:28 +0000 (UTC) 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 To: 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 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 857884000D X-Stat-Signature: zkxng9du6icqs58pzn7xzh8s1wud8ngw X-Rspam-User: X-HE-Tag: 1694230649-216476 X-HE-Meta: U2FsdGVkX18xdTIRmmCuBZMmTd3l3WGJeZtOn0A1P6k8j4NxSvQFi2zaQ9AX9HqBbDkFwQ/oZ1CG0fytCx+3E+tFOLNYbYMqnkeQ44A5bqCl4a1pWyvScX1XRO/tzGKw6it2me8QuWdyx5fcse9Nh/hHxcin/vl2OsNyV8kAJWte6VrXrrASk6eTKJYV16sPwaDffUe1tjlz3IMc0lFQaz6AFmkXBESMFSJUgTt6bWtsYdDgh3epq7+RqPF5WmVaIt+FuWGQdzF1Sqv13vR8sOcUgxcfIOq/gvXda8P4S1M1iUrsSCYqvFSjEWc+cWXLAFU86O4iNKL4rwXA4cG20LiZtErAfvXGVLfnyoAg9+nopmn0bl73cKaTNkqF5HwRkT8uz+Q+q2ArD8Sws1IqUKgie1QS1fuSh3emKhTcHUp0KBIo2Imb00o8DfjSAffBpuVQiE2kog/Wf8UHcAawLHYFl0wyu8v/HW3oLWrqSqJNDBbEwpo8SJEWc0JgSfaXUgxAuXhaJQCOjR01Cti2effBGgJlx+0jvoM33gPWqtG6EKPtoikAWLmuNsiY/+2h7e9QP7Q0Mapk0UUaulnBL2mEJyZuiGYCRJgXe9fmSN4W6oszlw0BU30nITE6RHD/siOHqsHe2QA8iZg+etF0DBOOjXxm9cq3/pecqxVRJm8JvhNxpq0dMyoLIOiU59ZNDzRnJh+nzdaGD6ad2G/+0QqTJfPBM+Qrj0Twp+UdcDs9uRML46ntz/DK/tYD4vONLv8ZnkEeUyPV6uE5RZS//crAPY7QzZ7+Y8wyRXmFKXo9Yl02Mgt6oqOTYLdtJAtWkGzVnJN+y88Fi/m+ucAk9b5JelSnpnZsvkcBwigpKSgmA/skY62g966xRNhXPvaxgzBFmOXXCRG1H4TPS7rt/1pcuNGURw/bVMsYOwHqZiXmVgNYQ2esFaDAPNGGLdpJWiO4zp6JO2+fldP/wGr xhEBInB8 eoCuhkvOnZwcX64MJiePxF2RHfGS61ZGPTuc4EJ85nVT7WJO5WrDrzwGQuifvckt56lCUZ2+3+SdX84OdPibJWIAR4ocPolxuu8P+hBBJtSHqauuIAb1lMLNfleHJmOwwL8iArI0ivGd3lG56OJoVk1+RMN3YkwNLJXw1lQUBr62ArZikmA1J2UHs6sR9DUd27JGg3J31K3Xyp47v6FHTiHpoMORUX7YM57jdO+SGmyDuUJD+WmXGI+qLKdUd8w8C9jTjVWE9aBv/MYHrD+exnRlp5uR58iMoEEtMBT5Y3yWHTwpcy0oOvbp/jA/lC1cblZ/lZo1wL+h3BUPh260dlO1QFchecZroB9Cvs9UeZr98z7OPpWWSDRd6e2JiwkImL0U2 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. This 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 reset * 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 damon_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); 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, unsigned 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 interval. + * @attrs: The damon_attrs of the DAMON context. * * Update the access rate of a region with the region's last sampling interval * access check result. * * Usually this will be called by &damon_operations->check_accesses callback. */ -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 = 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 = attrs->aggr_interval / attrs->sample_interval; + r->nr_accesses_bp = 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, unsigned long *folio_sz) return accessed; } -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 = PAGE_SIZE; @@ -157,12 +158,12 @@ static void __damon_pa_check_access(struct damon_region *r) /* If the region is in the last checked page, reuse the result */ if (ALIGN_DOWN(last_addr, last_folio_sz) == 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; } last_accessed = 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); last_addr = r->sampling_addr; } @@ -175,7 +176,7 @@ static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx) 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 = 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, unsigned 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 = PAGE_SIZE; static bool last_accessed; if (!mm) { - damon_update_region_access_rate(r, false); + damon_update_region_access_rate(r, false, attrs); return; } /* If the region is in the last checked page, reuse the result */ if (same_target && (ALIGN_DOWN(last_addr, last_folio_sz) == 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; } last_accessed = 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); last_addr = r->sampling_addr; } @@ -593,7 +594,8 @@ static unsigned int damon_va_check_accesses(struct damon_ctx *ctx) mm = damon_get_mm(t); same_target = 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 = max(r->nr_accesses, max_nr_accesses); same_target = true; } From patchwork Sat Sep 9 03:37:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13377950 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62F7EEEB57F for ; Sat, 9 Sep 2023 03:37:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FD026B0104; Fri, 8 Sep 2023 23:37:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3ABE86B0106; Fri, 8 Sep 2023 23:37:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 226566B0107; Fri, 8 Sep 2023 23:37:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0E2496B0104 for ; Fri, 8 Sep 2023 23:37:32 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E06AB16027F for ; Sat, 9 Sep 2023 03:37:31 +0000 (UTC) X-FDA: 81215649102.17.F3C7AD7 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf23.hostedemail.com (Postfix) with ESMTP id 38501140003 for ; Sat, 9 Sep 2023 03:37:29 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=M330diVc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694230650; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=t0/NgnLtC+2FcxnOrp3sy4dMgy71ergshlIM2wzPpzk=; b=Tp0tSZhys14UfZFJbEf6UgytdntTYxlGtu1/Bd8gX34NJ2+tCPDORxYCJM+a4SwtKqouqO h7NLa8zU//zBHurPKxsHHwnNIS8CtuV6+v4Pzm01mkTDCCiA0KL2gyA0jKpnEfK+fhsv/h BmfPrWZ6/DeepBBBfGlqCBXCcTaGU1E= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=M330diVc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694230650; a=rsa-sha256; cv=none; b=EwstwZNhrTIHUMsxdZsffX5dP1kGtwbjYWvUIgDU5XngPQ37ymCq14Nk0ptCdff6Z50uW/ WlMYRJpdBr28dvAPuPHuHnNmjVu4JsJlk9PQjJeBsrZPuMCRW39kt0QJlsQ34sh/udX6Wl 5v+x/Cs+g5hg+hFkBWaMBd+7OGlYgmQ= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C0D20B8231E; Sat, 9 Sep 2023 03:37:28 +0000 (UTC) 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 To: 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 X-Rspamd-Queue-Id: 38501140003 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: th9mdwoz9gmruq54b9upu3tw3g7dzx7u X-HE-Tag: 1694230649-117909 X-HE-Meta: U2FsdGVkX1+xfaJlx9N9vZ6ZCRa299p8eGnu/0UqKY2IxH6etfbufKW/FrfK46l8injN3kLMcWH2P/ZMvQoxHCe9lIA4cH2z8P4U1hXHy7juuv6p3pCdswrfgqq2v6DnZRNWYNWuikzMyy1wGoGvnnNiRB9n6m2Lw73WaNWzT7aRi099N3J8nJHGct0YGayxGwzQngZmZB4bo4OfNe/dGaDn5W2RdiPSVAppFB49L+th5IOSUfNeTZS4JawF5ecY3nrLIwRqNiBKDYX0CMR3DARIadEAntyeUR7/aFM49eLEnBn7QLDSB0jrchjno/Tp68YnZGqhPgxiaADEng1sEpJ4fWw4pq5p/YsdhLIF2zW7EYT1Ec9pwqkPnkegGmuel4GTcBO2JUmnjmQmFTgoQIlF4PlmJd1MkMAft48d5rYCNoQl3gQecp8lYAvwCNaoYMPtyR8YxPQdQ6atwcbJUgwNk639KJMtTdgrkky8821499NWGL1N38KMPvZGQvXusaYr4SEdlAi/jLPnwquf9So/Vf/CM/3Kgh40vPvX+ZO88QF1b+USKuu951i/vI2NP4upK09Ao9Emqu/38pEXk0tzLMf8oIoLVUXHr/ODDY63q3+n9C5W++moZTpGUO0Tn2l04DW4tuPrn8kf8GtuUxfPus2gAL5xaMsYo4O6aS2as8makXXBnVa8B9HElGplXYcXlmHwN9XOYqHV1WlYZIz0xjQx6u5BlE7HRZvtODLyRFrKGP8n+u8OyybRmiu1223eqztgooxuxSI4o8tsbtx5Q9eK5m0m1KoL+O8H46JMX4JvYJqD8qc6yXKbXJRzCXQvnn5eHv5fQzvdp3tdqLOMbosvyPmSrZA7QRJ6Wb1DgiAJ42nZt6lZ4AZ911ULe8knAidB5fhzWJPcubCNvU9Z6vdYpaTjY64WU2HBNLdEI8QcXrcIK4QV0TiJSW/3RLeXPM/I9Pgm/gjt31g jysY9jAX OrHRd0xYKYryEWMcJcCJjVR9eF6bbRlggu7QXwgEtQW4SQDOb4/5vHON2plERHk9J7TNC0TsLE6fKRfxSYxALgfW1cU3qVVz4brmf8LQMl5o0PFgjD/T/da0qJnmV3osEmqvkdHTO8q92JTC3N92nIhmnA/Gm53spA+JFRa5i6HUm4upDJU5Fjpg7doUmYSsQYUtCQGUn/bPuQifgtxkIGT1rXv928NISKOmWFOXS35YNG6srg4WMTKl3mJQJzia67nHHNcr4wJlQiuq23IDGA9UAXxFbeE/I+Qb0/Yt8bM0SVuHxHaj6Drrw8qR3ACq4HY79RiXGK1of3ooqaVzmm7DuzZUkmlrKWsJLoJuq2pCsbrS4OJsar2jA4uBmpQlsXF9N X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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_target *t, unsigned int thres, else r->age++; - r->nr_accesses_bp = r->nr_accesses * 10000; - if (prev && prev->ar.end == r->ar.start && abs(prev->nr_accesses - r->nr_accesses) <= thres && damon_sz_region(prev) + damon_sz_region(r) <= sz_limit) From patchwork Sat Sep 9 03:37:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13377953 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D019BEEB57F for ; Sat, 9 Sep 2023 03:37:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EAA236B0109; Fri, 8 Sep 2023 23:37:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E59336B010A; Fri, 8 Sep 2023 23:37:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD40A6B010C; Fri, 8 Sep 2023 23:37:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BAD9B6B0109 for ; Fri, 8 Sep 2023 23:37:35 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 94AD7C04D6 for ; Sat, 9 Sep 2023 03:37:35 +0000 (UTC) X-FDA: 81215649270.02.B5058C1 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id 7E36414000A for ; Sat, 9 Sep 2023 03:37:33 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Izsy8M9g; spf=pass (imf23.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694230654; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=I15fcCiftstjDJhtda4bP9yIA9qbFxpP8S+UhQRu3rE=; b=H6xzkZFstTpqwHT1nGaP5rwxCttvU/2TriIxwNNN0RHr7BKoqxT0iBArQ2QhOTHZi6xoZO GXlrZ6yvbRbdlgDd6GxEdE9sKf/bq4luHP8seClWN2ly1qq0fJlh0oDB0koX3TbW0I0ZJ2 XEOqgjZx4fIF7UFsf4nCTUoMswtNypA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694230654; a=rsa-sha256; cv=none; b=Mbx2ajck9+tUEwFRT7gckEj0kr3fqRQ2MU4BpMnXzVqKNrY0Y30lN+aWs2fJDem7GLIsEH wU6UdouwKB1zmwoubptO1RGM9VruXT5sSRzkPD4O+OB7GZ4sCPLF5V3ELorUdDRK1xrsoT McBvo2nyDhBR7dHHLpXMmEo87Hi15Gg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Izsy8M9g; spf=pass (imf23.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id AB27ACE1D52; Sat, 9 Sep 2023 03:37:30 +0000 (UTC) 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 To: 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 X-Rspamd-Queue-Id: 7E36414000A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: zi1cgn6jxhmjj5d5pupt6e9qr574p8do X-HE-Tag: 1694230653-758802 X-HE-Meta: U2FsdGVkX1+9XDLSsx5bqhlKj0yWTOOYPFYL1vDBniB9WX7rlWvGqAjR4mIIiBAFW8liIBqBHoUvUGlQuEDIGVqzNTG1zARBSdrXLIP52dXnSzWlRqlhr2S0eX1BqiRhXZhoPxfXCVrQQqI8SAk0uWwgFxeKW2Vhp0RMxfhDs0ztiatMFFijTsgSUZJrryNYSX7lSTtBZ3ik/Se37cMW2mqFtw96cIctyxGrCLdgc3Ogh41zZxt5I4jIVrNnHawHLtonCfgCOfKyu0ib8v0opFCw+UZKCJyluY8VwpyyTlnz+fUtEYtkz2srx5IwU+Eii8c3I/jMiMkYYN/fhFWoRjBDn882rJ6FYfi4/IhcQtKa2ryVJD1VvzWTdzixcARlc/72e5i7p9LXAj8WcV+RtnXUMpUMmJjKzCqbyJpNkHtO4BMW5fWZtz6ZC7ebgrku3TD4tZQP60p5jJfUYMtOVSD26hzdquArYw665oZw9TGBakRlOGf0aJVJ73r4CW+bIIwK20notL2XUV32XMOXgpkOX9hZIGPxdvcAWKPMHz/5X42jve6FbnAQQIv/ItJ2LoCcHIbhX7ME79URSKyJLKPluAxEejGu/R26YOlII9iR//x9CKyqnm6Eon0KWeWWYkz/C0kCjlbCOHavNnox/HBGV0tcGNC6t/BTtkJ4duKWUIIogNCntR5EsWx17M2mzImDga19EIa69lsdtf8JMIT+qD23GbX6yfWMeAdaP0YtQdPWZ/zTEUgFhhf2Z9Oar3sD4w975hLv+SpLtWMcNf2FB9cHXuXxgcZEiSC+HrNYPMDz5lEaKwiNqQObiw77+vdHhoHIwyvp559r9ZHuujqBDin8Zo/MuWoZn2Lv4VP7tS72R84A+J3qBYl+MQ4lxBGg8flyt5dXiYU2GHMyoB3ohBomGrNEZEPiY07zGFQph5RNinlAN6HNKlaBTwsKSoIM8RvESVBTBuzcyA3 y3Zim+u/ WDuJ2ZkkconyvF7/298brsG1PsSIL8uK4BKVvn483ptGlX8hV1iR2mtRdMsetIi+jMZe/OwhkhNhox6nW8+1y270dkBFrEogECeOEjWVJLeinNg71PjvlmyWpw4ONgK+orhZUxGLT78meAvx834O1A7X9JTGuxNN1+72gFdSNoj7TgcEiWn11WYf0od4KE93o3Qk5pCoWPe/NbM+eZ7U9V1VM8mqa31zar0NP+1gQgN+aFxQ17oIHlDzIfST0LXfm4ZAv2dYwEgjPKR0vEUvjtR/n7rbM5+Sr7QUVwkH7K6HFHOPl2Nnmy15UxAwfdkSalaSOqIE4uLzROky4EC3ckeZDIk6Mkw661ctCAZIG6ydR38oxoS+MyvTwIs/OvsnvT05r X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 damon_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 *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, struct damon_attrs *attrs); 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(struct 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 nomvsum, unsigned int len_window, unsigned int new_value) { return mvsum - nomvsum / len_window + new_value;