From patchwork Fri Sep 15 02:52:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13386316 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 E10F1EDE989 for ; Fri, 15 Sep 2023 02:53:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B677B6B030E; Thu, 14 Sep 2023 22:53:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1A546B030F; Thu, 14 Sep 2023 22:53:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 98F6C6B0311; Thu, 14 Sep 2023 22:53:10 -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 4289A6B030F for ; Thu, 14 Sep 2023 22:53:10 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3BE5FC073E for ; Fri, 15 Sep 2023 02:53:06 +0000 (UTC) X-FDA: 81237309972.27.F90ED8E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 81EB080007 for ; Fri, 15 Sep 2023 02:53:03 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Ntf/iecF"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1694746384; 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=SFT1RvfBesgWan9n0zdO5A0vFQzl8kYATAnJYbXppOU=; b=omTmyMR2MPOsVv/xTM202Z80h9fHL+JNxapDZq5glbVEUZ40iKjwFrQkowceloDHZpy7d/ xeFjO6t8U02RjJ7Jhab1sFlk0UtU4XWaPJpSVoM+ocuZLijAVDrcD5LNub7tDSGc2w8LyV S4vW2NCxCNxVB25V+Mz7JJaJqRJ0Ock= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Ntf/iecF"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694746384; a=rsa-sha256; cv=none; b=kz9D7AMSSIqN94mJN8IRvKK3cpyud73ABBtHWV8CHrTOZ3U5GbrKUFsvJWUck9T87/MlHM jPcpefSDsXUw6Bx1/RZ5r51KA5QKCA+gXkESRtU+XayiYX2rh8AjGHz78sL8k/WgVW1mpn Tb9ChK3aRq9dbTYcXQTB1TVHX5YCM1c= 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 dfw.source.kernel.org (Postfix) with ESMTPS id 72B9761EF1; Fri, 15 Sep 2023 02:53:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0D1BC433C9; Fri, 15 Sep 2023 02:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746382; bh=zCDEsnRSxn3q8lrPgI2u2ZG1f3Dh76TJLw6d3uQsNjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ntf/iecFSdd3DqQwgfLRXzHl/czWjON3PowvUDhFaFyZaByn8EF15Fwy+Baodq8g+ T3UWUH/geUbs9IOLQVJYRq0S8CBgSo4GgagPuJ8w6urJT7ThOqf23T6XPZn1nCvmmA /fFveCT57SDIgI7SE2h4z9zxsTlTLoi/TsBBxgaBOU6/ORSdPSV4k/zDhOVrqDvmex LK3zQ8xnLrH5yMnM2cfOF65ovLvphaX+SoNR/uigrIopOng3jzRjsCAWmJcMYDW4u7 446GqrWFI4ki83YgevvKhpiMya0lXnUqLfCMS5ETOm1sWgXKjyk07Xu86nXLNrzVU/ xvjn5jhsklxHQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] mm/damon/core: define and use a dedicated function for region access rate update Date: Fri, 15 Sep 2023 02:52:44 +0000 Message-Id: <20230915025251.72816-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915025251.72816-1-sj@kernel.org> References: <20230915025251.72816-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 81EB080007 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: h4jhkcb13a1h1p4k15g744u3647igcti X-HE-Tag: 1694746383-427933 X-HE-Meta: U2FsdGVkX1/vZW7mn4Vr+cPV4H7fW1k6qSDAKafWFvGYdBtOUJ/nWLoS8IWSLX1KUUdntWvlMyfqHOtyq0DAbdpfkWTjd8/LUuKXxdbSungNKVdaH1dM3obzJPRsJ+wUPeZb7BnYI1jS/RGMKuXf/bX3bzs2A54IrUdyrdt4KtYvTdcGvj/fePlIusvC+PIb/gzmUMBCfIDaZiFO+ezUcOkaMOWGD95LCg18DWS8JV9moxQByLPXKj2csZH5dJDwEvHE1ckjbnCPLSBUlPkSSyJdh4QF08lsjXtgswSE33vBD4qN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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 c5b7296c69a0..10532159323a 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1549,6 +1549,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 Fri Sep 15 02:52:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13386323 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 538D8EDE989 for ; Fri, 15 Sep 2023 03:01:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACD246B031A; Thu, 14 Sep 2023 23:01:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7D2B6B031C; Thu, 14 Sep 2023 23:01:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96B916B031D; Thu, 14 Sep 2023 23:01:15 -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 87B3C6B031A for ; Thu, 14 Sep 2023 23:01:15 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 58B9C4079A for ; Fri, 15 Sep 2023 03:01:15 +0000 (UTC) X-FDA: 81237330510.17.0368158 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id B4DE740018 for ; Fri, 15 Sep 2023 03:01:13 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EyWd6QeH; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1694746873; 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=MhvejbR3IcS/yn7qRlzZxGxWdZh30SG0xCJkMKOQwSq47gaHYjoz+MKJDdklc2NgSZK17K 7TqqIcpfQoTXF/Fu5kJfiL4E7EDns7IRPNVFWjOUMPeicbtXlkpQAcClfBSiDOAv+uAMxY LKJiFUX1iobPRNFEfOLl4JmkIcKbrJE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EyWd6QeH; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694746873; a=rsa-sha256; cv=none; b=CFh3h5Mi5D/FE7M6pd1Qm10A68pnPOfkN7DvxH1hc3Q3vDp4qZTeIgWYfhPamUPBSsr8lm RCM6tr3/WhROoupSUd1D4qDw/EKANZFmRCG+fL7LSebIqMJujOKxG3y0zKOBKgAEIK3CZW rR7/diS/G47G8Q6Q24wLemXW7hFTHms= 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 dfw.source.kernel.org (Postfix) with ESMTPS id 0B61161EF8; Fri, 15 Sep 2023 02:53:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68B15C433CA; Fri, 15 Sep 2023 02:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746383; bh=i00VYLhoAf7cwF/8O1Xi88bbaOl2lSsV4k5ng0qJ0ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EyWd6QeH+I+otwhxDe5iLd5XAOviRv5NU62+pG7wOYSt1RxJd562R/9kRGV/14S6k wqwgK3S/aoyzhC6ERZqSSiw7JvU7BAbifNwCKIe6Ic1N++Fm4YodPXqekKh7wy5E4c frf4PtL+Dv7zzGaMntbeugmrQFPZnEwcCuwZ6MVTdQMvr7clAKApk58dlqzx4D9XB7 gFmgUFdVfZXcHnVsiUAYX4nj2eQscAJwIuXzXjzAOvHwZF0ZRQvEYWdpSJfowFNMuu CkJENgkBPYUg94GulS9lebSqQJdp3mZ2b0vLC1KWqzgCeo/tyq22w10Ies9ncnlHit 8JGVkX6Fe/OWA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] mm/damon/vaddr: call damon_update_region_access_rate() always Date: Fri, 15 Sep 2023 02:52:45 +0000 Message-Id: <20230915025251.72816-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915025251.72816-1-sj@kernel.org> References: <20230915025251.72816-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: B4DE740018 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: w7sifzc9sboz5aecuitpyh7rqm9ggm7x X-HE-Tag: 1694746873-203814 X-HE-Meta: U2FsdGVkX1/rPbBBkKdtCTCdmtJ3TMkPwregMEH33F6t7dxngNFaMTv+IiaIzB1De16NSMJHosfneIdDaK+49C3MHGVKYBx6EWCYHrz7lyibo+DkCC5yx9AyrvLzqds09O+h3xh8a+xgxMFxiO6cnMcJN06w7FHWdKjAMZ9zMVtJVKzj7FTc9IiFYqGUvsj2oAoYX52dYq3UMJpxHY3ujgRMyUX87jHHmIMgLWYeji6Z9v/kGnqRdl1R4rvnAXLeDWLrYwO4IH73FWXrduqQkcYReCvbcYRB1KjdXVcCfRXizRrFQCM/jGdA0VPI5lt6y+a1orY6VZgljPiqYa5hBYXrQMCugNsagtVH50bPAKLtcaVT9haIA+mo8tLhIXIZLbvbWyCvTlzriW1hlxE0GPdCtNRwARxj8RAyfA4s0hRDS7YD9NaCq34ZAft5d+Nm/NquAqH8RJjYaqd047y6E7jP2YzmP9ok+DLQayaX3zGQv9ZNG/ZpmfFF9rvLdOTdAEdQaypcDtUCIgQq7PDgeqTNyjGKOokBcXP7IFFXll93XdL2ZdmANzlbyGuR8Q6R/q8qyC6GcTj9wdB0XrJIfTPOFEtvRjXVJJbviNh+R5CHnfmFlBQhpgXYrUiNO2X2fEr80hcixXYEIjrt3BQO6mr/ETElsLmJRSrQH+PlNR4hyd+tiGXn6VolA0RywVxpcvCeyfAwWqTIgE6tbGIAxMQJz6XO38zRJpvcrvD5ljqsvyRcs98mpbEC9MSCMBiY0MAPCHx6tJ+MVqP4DNseBGhGFPyVF03cJZtClHnYe+FJ8v/JGjTvWmIOfZTWJXZWoXqaYajqdgyH9YsFhAYtXNoVrEAqzYUJjP+0I+v8gIolEufU1ZuosFlx/ZIlZoFZWMM4liA/XyYeXISWjM0vk9dNykM/8cDT55eXM7PTJ2YyjQtyXgZDqAAnXr5LeLV2zs9RhanDTGAOV6Ha1+J glEcnU4S /uBAIi0194BV3pLCLkzOO6TRbOv/PBmjnjnRYdcn9WqBl0PAiu10qrMtGyEOuv+G9868VyW4//+teUQ6n8YBPe8qUvULeQilGLeQaSLyjiU32UJZWJtq4gNswJqg2QGefq1Y8YjvWdwRO0dvRFk5vuFtTDebfPZT5/uxAOdXCXRMg8T+ge4Qvgv7w0oysW3z5wUDbxuyH0tR2g+SCZYJrMdsISs8C2+J/vT2r9wqpCAtA2BHcJjjSxjWBW1fLDztF1gvY8za68gJXVHssdGt2Wbcas23FC3EQPd8J7sloffqTjQ82q0Fu8Czz6NWeaj6IlkDislxqP8NhqeT59GRYDDHHTMAuE+ddgh8vTCpf2jcxxdidjK+HUd+559CweRi/9Ejm 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 Fri Sep 15 02:52:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13386314 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 072B2EE0205 for ; Fri, 15 Sep 2023 02:53:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 747F76B02F2; Thu, 14 Sep 2023 22:53:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F7566B030C; Thu, 14 Sep 2023 22:53:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 597F66B030D; Thu, 14 Sep 2023 22:53:08 -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 457266B02F2 for ; Thu, 14 Sep 2023 22:53:08 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0E333B42B0 for ; Fri, 15 Sep 2023 02:53:08 +0000 (UTC) X-FDA: 81237310056.18.B8EE4F2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 52D3F1C000F for ; Fri, 15 Sep 2023 02:53:06 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pq35bGOV; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1694746386; 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=TR+0ywkwjASKLQUKEDWUDGl5u35ACwoap9KEj50pecQ=; b=hkafpnxNxoj3F+B6dQ/isCle1oFyDtKDYY3YTlAtOfCFyiWBvjX9aO6sJGbPY9OZb8U/H/ uv7YyoGYWqk058Id5umGkwhwkkjE+5x2KK03Am6Ni15OVunIolCSgcrgiCzIqgT/lSMky6 ulK2rW5tqdBCRwSzq8h0Zykc0cVQW+s= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pq35bGOV; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694746386; a=rsa-sha256; cv=none; b=MtaAx2GoYKzKrOUP8VMvduWj3sFUs9INiDBEdFWJiqL4eOQ+Ju5RXLJOXdszkjSeLTwoR/ LlDsAOzlGok/1Cvp1LEL1tbZZ3IFVHd0zW8rycztIyiWa+UimziqpT3AUvSrluf8T+IpUF OUh76SI3ovDAP7z9f+vyyfhNwAxBRsY= 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 dfw.source.kernel.org (Postfix) with ESMTPS id 9102061EE5; Fri, 15 Sep 2023 02:53:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF5EEC433C9; Fri, 15 Sep 2023 02:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746385; bh=1bmqeGHeOEZ2+59SSNfs3s06RBUS+Jm7Zbyglu1mAv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pq35bGOVZLCqwdN44XaOtHhtXWKjJs4HFDnB6LU85Y8bqJGxt1jDLEDCJU2EyKY+O YX5rUFZ2j1WYGzXpnC7MZBLFG2mDmvZeEfZdKl41qov99fPrnnqoh+cNnRDJkUYL3p rFdgb+uAr4opnrxmKSWOZexjjdsFRCkMkgrfNixVpJCRtruxa93AEdCyE1NRTx291T ro0iKYQKhKzXv3roZ+Ja5LGJ073h+DG/Vps8OkaCtQV1TNatAvCkVTNcX7c/2nEbsz hABBbXn7jgj5tI+nARlpwXKPSnM88OeQJWahUNlym4aIYY5r7PefSlPgceGMj0AeCt I0BpGP+LqEcKA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] mm/damon/core: implement a pseudo-moving sum function Date: Fri, 15 Sep 2023 02:52:46 +0000 Message-Id: <20230915025251.72816-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915025251.72816-1-sj@kernel.org> References: <20230915025251.72816-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 52D3F1C000F X-Stat-Signature: 78prb8b4w4eewcmc4c5qmwi3zdfg97ts X-HE-Tag: 1694746386-815605 X-HE-Meta: U2FsdGVkX1+KvjefMS+0AevalqYYjUp52yZLqWms7QeHTIu5lef8yuzXhPGDAExySjl/eCYQYMadzXGkJI3o+f+1x+KK5Mdv5BEA00+09h1SWQq6yDNJKU8yU3GSBlHzMe1FyziHSCogurfVwj12EG5jC2MBz5hac+8QSmWzItSYP5QAy5X4xVAQq879ekemtiqiGqlpkhp/j2B9J/p7tb5dOS7rmEJ3aPMEibtu+A5hT8RRriM80+EsVPqCDnt17fqHVvXvwNsD3hX6WOEeWWS6kgbfc3bRLDQwdM9OcDuuMvDYBaW+ReQdxviabzg+VSOL/ObKYqtdKVRSMTdIz7rOdJ9bE6jVfZRAwHuZnt9KaTr5YZtqM+JBn1RO8U8uS3rsZS0Ue93ooyoTUtRZmoV66F7Yif4iiVzP7q4IYUNO2oEzlPXepSQcPyC0g6G6ItGAU+tHsvIbmieGfVK8Ntnxs1pIDcOwLSZe42Dx2nREAB9k7pNNdAIctfM0TS1VKfTwy8+aioyS1ZuXVRVWGfhBjf0cbGaW/6XQHSfFN0U0TbX30MXsqONyhGc0zcYEbMpEMOznWW/wYQMhlj5WfdELGCR9zTApCojDZiovhEuYZi64b2/u/Xz6ZsJWxwUOj79knrLvJHaMkmvpSFCCtffxx3Gg69f/zAbWN/FslmLIGVsQW884fZ1MJiTORju2nwNLf7R62anNWxtwhU6qy0fzOZaGVFwYI6PiNS3IspN1DkyH+kS/1suROsHctWsoPgBP7zY7uyi+0vxoo+8g0LXwWlajoLgTELmfFZ/nBD1tNvvYug/k2KPl+8qEe98phf7GoURuVBV7cNFvYXNLRBTmvbY5GkTnvMyT5S2uG5+b/1MVfhV8EYpX3sPG3Jsp8VXA4KY2PEjgf7fE/DIX5caufr1uNIuJjVPMYL11fVEtVuS/41Y91AV7yABTNN8aDACG0D//eGcY36J0tf6 Y2g/UxG+ IwBXSSjUJFGMLt878+Pz3mzy3Y2DbM8Vhj+hPEAI/5AXIvRu2htyGoVDx5Qep875Bnortx4scGwrC3l3KkSWSBCMjOaznd83wwvWmo59lGyBglmGDnfDTfQvLYX3YO2abgWUg5zhFG+FvuPRS/uVV1y5KNK91tlY9QzjAet80YfGKwp68kwd4OGpD/Ria29YrbtAaW12JlSG8cHLrvumit88g4YD8OFEdQLeAkiySRpHl8Sy2D/Udcd2Cr8nZKKzvCWubygyAPYx+xFgUokRk374J08PDYr7RbkmsbniwASZFqbxh2rzb8U/7seLuH8Sy5lP2Bgwv/gH/Dz8TdsrJlWNNqQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000018, 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 10532159323a..b005dc15009f 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1549,6 +1549,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 Fri Sep 15 02:52:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13386315 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 20F9FEEAA42 for ; Fri, 15 Sep 2023 02:53:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48AAE6B030C; Thu, 14 Sep 2023 22:53:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4115C6B030E; Thu, 14 Sep 2023 22:53:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A1696B030F; Thu, 14 Sep 2023 22:53:10 -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 07EB26B030C for ; Thu, 14 Sep 2023 22:53:10 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D06B1C0746 for ; Fri, 15 Sep 2023 02:53:09 +0000 (UTC) X-FDA: 81237310098.08.6DD9ED6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 4C8A7160011 for ; Fri, 15 Sep 2023 02:53:08 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=vE+6+K2v; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1694746388; 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=cXngYQLFDpKEBBs3xnllZHROi9ANqhjhQE5WbV711jUVGijrUnaqklZEXbYgAoWTu413Ol 8iARH7yNkF9OjJ6qZlksKEyEvjBvM3NM5BdKQWl9rixqnfNDKWrvYVs2/6bMh1wIeFKfSR TRLEhJNnN65jzlmq9HVzkTAt9DSFZUU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=vE+6+K2v; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694746388; a=rsa-sha256; cv=none; b=h+q42X1ZQ8OSVqfRRz6A5EEBSWiQ5LNdo15K10b/JcTFhf1EM0iyqQLLjeMOOTFlsw7DMC UBha9zrKU/xT7O/HD56UuBsvbAgbFxSvy61bDkARXTb2GsLoN+HDAGBfGsa7u/UpZHpx2b LQzSR+2oL7xUSjgoMybHun51tKnGvoI= 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 dfw.source.kernel.org (Postfix) with ESMTPS id 7CB9D61ED2; Fri, 15 Sep 2023 02:53:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44B9DC433C8; Fri, 15 Sep 2023 02:53:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746386; bh=xT8faQ/VQn4QsrSETrKl21TSbXbkbXRLNmsjtMslsE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vE+6+K2v8eFHCuG2uMpBuFLYWDxqqOXd+irJE2hgT8Kzn2qCdWCy1yLXm/zxJGcle 766beCUyr429m9vHPiYbpBIH1ir4Ac1FU1pAssUxZCd0fxPupJtIfjmwwqCV1CizFh urwwnI45LhwWV3A+6CX6il2CrZWabaG/fK1UIvPJW4QNgmq7jiOh7NATX2Jh8W9xyx sboRSLtK7W/n1muo988SNeyulnEUWTL/ZqrG2xmmHhw+zkZA3YEHyXowMDaMr2B5hD XGukIVihyc7OyD/VMQU5eVcRYGaRVI6Xe4hn3oV8PWGyIPnbyMw5YD+9QK8yLIrpZk HOBb+tcLjtjgQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , 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: [PATCH 4/8] mm/damon/core-test: add a unit test for damon_moving_sum() Date: Fri, 15 Sep 2023 02:52:47 +0000 Message-Id: <20230915025251.72816-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915025251.72816-1-sj@kernel.org> References: <20230915025251.72816-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4C8A7160011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: unwdncbcfoagoatpwinxwxjkdojep6zy X-HE-Tag: 1694746388-416848 X-HE-Meta: U2FsdGVkX19WLsP4OzjiLonCkqyW5/QjUza/Un4+KqMtqbl/gzO/A6fv2L1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DXlFldSsiMtck4sEwbaNpTkJrN2oQF14sQpE24YJKLw+0F20xtT+CBLMWzLp5tBTi+qm36RZTlnt4aJXePyHyIvjP8XKjRVA8StEDF/9HH+rJXX+YVd8ZuJI3kqlb+qY8YlgEKC5wcW5POrr9DzRzkMnctcD7E9PLWow5aiUUjHoDJnq8AXGyWFdQTpn18h4yOHl4DZBFyhCqyIlZtIXEsInklpzW8nYJoisS1hiE+FFkCLMLp 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 Fri Sep 15 02:52:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13386318 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 024F1EE0205 for ; Fri, 15 Sep 2023 02:53:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AC396B0312; Thu, 14 Sep 2023 22:53:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65BDE6B0314; Thu, 14 Sep 2023 22:53:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FCB56B0315; Thu, 14 Sep 2023 22:53:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 387446B0312 for ; Thu, 14 Sep 2023 22:53:15 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0235FC0746 for ; Fri, 15 Sep 2023 02:53:15 +0000 (UTC) X-FDA: 81237310350.19.41BA1F3 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id CCAAF40004 for ; Fri, 15 Sep 2023 02:53:12 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UNlsCXn2; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.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=1694746393; 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=kq5huNrcaXucw0j7mRG+Q0tHkEUy8BekbmYeCC7zaEU=; b=kLOePgfjifGMN5ldU82AWzdW8ZBEKvF/1kYOVT7b+n4tRc8uhG7dr+nybz33rkiHsHw9KM IEN1n9jCE+wy8WEBrvNukUOnTkKJCVBHsUK9GaEf9zXo0HdwPThgLc1ry2ZhQfz8/zJfT8 T06/GgU7fj1ONV7SmYy4QNpg+ypxVa4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UNlsCXn2; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.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=1694746393; a=rsa-sha256; cv=none; b=YDUllWVyJhrrU60ILTHWvLtBMUdAe/xj6dLwZngui4OxvG9Qs3+3oA86LgoPDBV7Y4/PqC nNvciOuqdAmCzFlqCz9cP3OKCILyGeO1fuyccLRWd6wp5VSouRHTd/x/OL2+MDPBEEHUWb jXp6y8exYUptT5d6yHSZKKWXNgr+x3k= 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 DC5B9CE297B; Fri, 15 Sep 2023 02:53:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAF88C433C7; Fri, 15 Sep 2023 02:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746388; bh=wBwPsUGsJdUgsPRGuDP3t7LM9PStyxdXiFRE+6KpN8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UNlsCXn2IBMaifeZPCzuHLGLs2hxZKyJo15KTVgqw2yb4GmWro5TL/tfPUSK6bwAq QSOAsTa0LGtwiKWKcmD1j92KgS8dR/UlLaruT1InEnnlxtuvkE5wIM8GnH2+tyScCR HMt5/hYyduUJntyRBoJPQoWIIz97O2i1IEi621u4wpsk80vovp6HWkUWxkTJjc6RjB MZymM9MTewhbrj7bf1/KSdeYXkLuE/8doyfioVpzF8G9iUZWTtpW9qXiCvu+xpL69h an2xvGCqhontwiXgJKZVeoJGDGf/60hYDKC+MCOd7c9xjhhgMRJAHQNtxTeZMy/dlP HM07jOkZBw0Cw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/8] mm/damon/core: introduce nr_accesses_bp Date: Fri, 15 Sep 2023 02:52:48 +0000 Message-Id: <20230915025251.72816-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915025251.72816-1-sj@kernel.org> References: <20230915025251.72816-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: pohxoe3ioxysppwjotxft7k83t1gy78m X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CCAAF40004 X-HE-Tag: 1694746392-518567 X-HE-Meta: U2FsdGVkX1/VWGVCeF/RTsKk49sHAiweuJDYzDuL9VbDcv3HL2tGzBSyPoZ0WD0LObxCMOmD6jKhKWTVQlN6xUhPscnG69+457KI2vxK8CsZhdDnJwsircGBvSdiJrr1FnhVqOs+6Md3xXHFKeyGbR9Z5JEgynCSmZau5Mnig70ohkrdINArePjWCoQeEopW3iBQqVEwjuKOrYPRIjVavn1d64XLDulhbiK9AyfLaQ8gOVEtgPGSU4knOsVVUv47HafbPUsdNjrKPrCXVtBQnF17Rt5FUyO65SC2f5TQmfIZ5JmRHWOjP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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 b005dc15009f..ce85c00b0a4c 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -128,6 +128,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; @@ -508,6 +509,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); } @@ -1115,6 +1117,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; damon_destroy_region(r, t); @@ -1138,6 +1141,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) @@ -1186,6 +1191,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 Fri Sep 15 02:52:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13386317 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 50187EDE989 for ; Fri, 15 Sep 2023 02:53:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8CE326B030F; Thu, 14 Sep 2023 22:53:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 888566B0312; Thu, 14 Sep 2023 22:53:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7044C6B0313; Thu, 14 Sep 2023 22:53:14 -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 59F096B030F for ; Thu, 14 Sep 2023 22:53:14 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 345701CA1BC for ; Fri, 15 Sep 2023 02:53:14 +0000 (UTC) X-FDA: 81237310308.24.5A78434 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf09.hostedemail.com (Postfix) with ESMTP id 621D0140003 for ; Fri, 15 Sep 2023 02:53:12 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="gKRZh/eQ"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.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=1694746392; a=rsa-sha256; cv=none; b=R8BzTlGIL/07gdZO8q7uRUL/hpwkGHQ68lpv7RdToqKD4d5EKCyAcKCGftcxDtnuhQx9ct T+WcYOATcav/tHh+TgGvByM5RQZSu48HbgzCJOAcq7vd3crWbVFZdeNuDbXpf4X2qhPeZk FsPCWiYRT8db+JOmggLAuPnu3cKuYcg= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="gKRZh/eQ"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.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=1694746392; 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=yas1krmMytP5jdv3DOjnLBNiWh5GBRJ7GxfCNOjPUeE=; b=ha1wGdckD3GHC5UBxLYheLcp5RvwpwcaIXiagdgJ7wsbDguJntRL+ru+IL5IRDu12k0WS2 9faC9aD/qwk9yRM+SMDkUKcfHc0exxc6lTpS/4LRRrywBQ14oC9XEA5kIzJRhkbUXTUzE2 rf5uwmAM07Z9w62BdKqmJg5UcARfewM= 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 B6100B82B79; Fri, 15 Sep 2023 02:53:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22D18C433CA; Fri, 15 Sep 2023 02:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746389; bh=Nt+EQkpN6g4pK9W8aFPRK0//Zoaw9gTVad64o5lt3eA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gKRZh/eQUciGBq4zsaSk5NtoLQsupXcxMJ/a50/LGY+nOoGWuUjC6y2orIQp3obtI kXAhaTSvmkPcLcIBo83U43YcT5/rR5+67cCeNTXQlVjlTdinObZwE9rv8twhhAoFQ+ hfODNrii+3froco6CXwiwvl/To4vC87JSvSxXDv/eJWIQZELjCY1rxBMVpzzcvLU93 LKH7YRnIV2jtSEIA2qyPFoj0BJ7KiovZ49aLLrfHP/SjF8OE2hm2oY/XWCe7owdqgw /nEekEFdyI15efQdNOybauZ+1SdgCXF10FOBqA+Hs0IMEHvkEUrNqT1fUkNKZoBVdj COaVPLwQxu3zw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/8] mm/damon/core: use pseudo-moving sum for nr_accesses_bp Date: Fri, 15 Sep 2023 02:52:49 +0000 Message-Id: <20230915025251.72816-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915025251.72816-1-sj@kernel.org> References: <20230915025251.72816-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 621D0140003 X-Stat-Signature: 76tix3yb1zzj3yy7a64bk889bfijsstm X-HE-Tag: 1694746392-923240 X-HE-Meta: U2FsdGVkX1813wIAYKmKDp+IZtOdhd2OSuZGd3N9x/eqhHFWtnf/yE8Cjuwyi4eU1A8KlDTdgop3kvTZkEYgqZ7W5ThgwpJF/aeWTafCOC9KJiFMR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GgCKwuePQ2qebdc2ZzyxBBo21uxzKWqAI+exE7rEOTn8YFjZe8H/zZuoIdKz37+5j9WmEZxpnBcRVhE4S8ovZOXpu31oJepaV3ure/baEZbldA8V6Ra4buvBoVE/7uiQnPsTLwpMLUJDy7KrDien0EG8VCKCiz+j+lbRj/IHquR0cYf/haoDBKl50ZAfbm3nfVM 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 ce85c00b0a4c..29ee1fc18393 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1599,14 +1599,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 Fri Sep 15 02:52:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13386320 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 44D20EE0215 for ; Fri, 15 Sep 2023 02:53:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 661116B0316; Thu, 14 Sep 2023 22:53:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60D716B0318; Thu, 14 Sep 2023 22:53:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AFE46B0319; Thu, 14 Sep 2023 22:53:17 -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 C57456B0316 for ; Thu, 14 Sep 2023 22:53:16 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9F9C5160164 for ; Fri, 15 Sep 2023 02:53:16 +0000 (UTC) X-FDA: 81237310392.13.345E4EA Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf07.hostedemail.com (Postfix) with ESMTP id A03764000B for ; Fri, 15 Sep 2023 02:53:14 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eSK3bW5S; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.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=1694746395; 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=35ICP7tkeKkUG2m8I3W+MDZQL7PDEnmFeI1sDSKJbJU=; b=c2oAk9l0PPNr2pNGl9o3nK6AEYboNxx9q5S/pFQYMR/l7VzifQF+6UXrmgbC7WL6c4LiUn xjzjkDzuYGhjxM5drpxoLEE9lxCNZF+wj0U4yt7w+jvMetsBvi52dAgexxGLJ97PfDAKmF KipNU0RKUACFB5kIrlTXExePfM8fQVw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eSK3bW5S; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.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=1694746395; a=rsa-sha256; cv=none; b=VQQDUPXkkEQ3oz1xkDn77wqeE2DAyyIK42ZblJOGj156TbTlKyWjPcWb6GbBXuezMvcq3Q ajbpKXWwrqOhgVsWcd+dAY6JgRtFtkzaRcnTk0d1+QxiOgWeSuonwcYuZExkTTDXztgW2E gQz1GcsjaeH1HozPQrWy8KvCKlLB8CU= 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 97AA0CE298D; Fri, 15 Sep 2023 02:53:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 755C8C433C9; Fri, 15 Sep 2023 02:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746390; bh=54IK7cTm7KTNNX3XLRdWLVNJIup7inyJ/KiBfKYDcxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eSK3bW5SwDXeS5zPCPPJiBwfd5vAIC7cx1I5DGDc3g1gvuXMCm8OZyYZaFTizCXr6 IGsoW8btGA90xigquM8091rNDyfmkhLNZwW7AIw8V9/opp1tvo1+424tjJaU6cby3j I/vcCzrwXGjBievjJ4k0LmkDlgt7Vpsff/hAU6iCuuvjFBQdjenQIAcfFr6mVvqAxE lvVQoEfYtTh4DFK+Os4lxuxXzBf8ovK+gvvU36ZpNYmDj0Q6OOWQtg+hcgCSutY3O4 y0w09Gspx4AymqefNtFvvOVgLXTTfoD0VfrvZtP6/fxVMSrz1FavT9eJGsqjrrSzLS oT47TwypudG+g== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] mm/damon/core: skip updating nr_accesses_bp for each aggregation interval Date: Fri, 15 Sep 2023 02:52:50 +0000 Message-Id: <20230915025251.72816-8-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915025251.72816-1-sj@kernel.org> References: <20230915025251.72816-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: x9gqrxd5bin88myqbka13hwghtc17pjp X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A03764000B X-HE-Tag: 1694746394-812398 X-HE-Meta: U2FsdGVkX18n5Z4lMSlPkH8dvamfrZtAGn8Y3UVT3HMYxAruV/dcR1WyjMjPJ6p7cRzilD3buETY1agLe8lJp9m+VsnBYYl1RtbpwtcuqOT5RgIkI/gXr2zPOE38Ho7oFnZ1OOzxwc8wWI0LBASTWhCHGUbwmvzhaDg0tX8Umc0gfervpiExHWZUsq8+Jy6bzjD6wIZEA+WxIzPt0h3U0dKmVlDHMoWrZDPo7whauFMVJGdWbG3Y31e1QmO8YXVktNX9aqStG3ApqtVAMo/OSVLKfnCxAtXdRDVJ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yHkwR/IbP 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 29ee1fc18393..45cc108c0fe1 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1141,8 +1141,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 Fri Sep 15 02:52:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13386319 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 42B8FEDE989 for ; Fri, 15 Sep 2023 02:53:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E01BE6B0314; Thu, 14 Sep 2023 22:53:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB1C96B0316; Thu, 14 Sep 2023 22:53:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4FA36B0317; Thu, 14 Sep 2023 22:53:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AD7B46B0314 for ; Thu, 14 Sep 2023 22:53:15 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 817A516070F for ; Fri, 15 Sep 2023 02:53:15 +0000 (UTC) X-FDA: 81237310350.18.E5CA252 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf13.hostedemail.com (Postfix) with ESMTP id BF10120024 for ; Fri, 15 Sep 2023 02:53:13 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="GgK6DIT/"; spf=pass (imf13.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=1694746393; 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=5nv6ta+5+IPL0DQgGt4qp4kHWCSK8jkn9EGeLE0STJY=; b=6hbnw4kia3WwsOZK4uUHQNl6c3wHdpg9Dz5yikNGvQ8umy0GkBHMIFBtwp1GJG/W5BGsSg axSaOLElgeASIWFK1V1Tugc/xMzzFRSoBNnn2mIU7L3XY9TMPtSAMYX125mHS6oYzG+w8O 2icS8gXv3u6ZNad234VuuGoiDO5amSE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694746393; a=rsa-sha256; cv=none; b=4WRUbQ4qrljLtzR8qyw6sH1MDTf7Nk4SfXOzFChwqFPytsXH64bdjsViiwezOB6eyhQxI7 LeKgk3Wz7IMAqx8OpEYor0pLkeTu04vypV8JUMgxfL1m3i5ilrzsPbtKIs28LeCJX4ZXhL kpQ73SoymSxsJ9YMCrtHqBIgLD2cdOg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="GgK6DIT/"; spf=pass (imf13.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 893DFB82B87; Fri, 15 Sep 2023 02:53:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBC4AC43391; Fri, 15 Sep 2023 02:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746392; bh=RYtjac5KN7rdOK43JC6LnDJ12z7FKzya3dCtCsi8Y0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GgK6DIT/rJEDrFaud01fxNb9X9ulgXc+DHEZpEYNHpQBHaq6gCDhkm5CNvhTtn3nY UbHvgHF8XfDy9iIQIOfKt9G99WrG6wz1rwaSpybz3ut17/5oFJLGNwPwq1dcXrWKXw 07Q++0DI8CyHA7uWn8iE/iur/xjP7LIoSyXDJG46430Bw910FuSgyA45Gs5G4frZcV Ta3OJrD342CslwNXGEcjPCByNlfc4PH3dXgyopGgHEaLztbBRCa9GDKaRR+CsuB4V7 OzStFx2T2Mv1/CPjbye7T09snFeyN6HXv+p2/gZ5lgLUNFJItBRAK+qhQ0xw8XEGD0 hlGk0P+/2eBlQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/8] mm/damon/core: mark damon_moving_sum() as a static function Date: Fri, 15 Sep 2023 02:52:51 +0000 Message-Id: <20230915025251.72816-9-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915025251.72816-1-sj@kernel.org> References: <20230915025251.72816-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: BF10120024 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: o1acy8eij5wus9hi4chnpoxy1w4dkk6x X-HE-Tag: 1694746393-29745 X-HE-Meta: U2FsdGVkX1+TyeteQ5Ys7+wKurFnYfWpyWPJ1p1QOwT7TPvtNgHUkZY9aXQXDc6ET2ziOUsFPexeEIuwqTamZwuilQHgdVd1neE4mz8/gSzWl6dPTl9RPq2WIDTqFcn9hXZOZE81U96Pa36SFLuYWFeTMOxsqfPbZ46Bgj0AAl5G6XJcFjB9Nrh8DO4AnkxRpmtO+g1XCFpZKrA0J8RL/mpm97THqJZ6KfxE8aptnjAD3wTtDqRA6HRjaWOq8iauPSTP+FvcZzFreSnQoqYatYH2G23aGDyzvtRpAzty7S6IvtieoG3zplbtQI5PaYqv3g364Orr9A91AZ2v9dzeNjRuBizc20f6nHfjXujPV7E0Ktfe/ph1P2/7J8eHFbjPyqgSD7QC/WIXDsCsvbfkaURnD9nnnN/UItfP/qPZe9hFdqMrP+SirSkx/jyQgycmFgie6SYenvs4zi4Gz89gC3yZBuvQxhAVZIW1RP7CZOvg/ekQoQj0uxWU3Tvqk9PlAe6igXdifYT7ZQfw79p/7uSgCwQ6K7pNnmdrfhj6NvT5fO7H+kIAqROtxOZfnTZaiNC4IjxtF5TW2bgVljK+3uODbcg6PAIe/ympGzDQu5OWSUogmzHT4v3Cdpwy3K8pMbkiRcnkD9JzmJwPQS5YF8pcx5SDfL5GLCixoPrOjNC9RWa4xK8NQ8XiRHapKLX6HSK0Ft/VvBmkiJPzzXNX4hFebt6KOEWcKXoaW7qzIoy2vtMP/AdMBGm4PJ2Xp/WfTzYe8JAlb/7voH8vQ8MgfPNRxflZJruzTfBzjztPQHimNdXQ2f6bok5UA5vdn4RB2YqG0L1vgyJr9IfAfY6ATIxJUk/ycpkCpYvEMj6KT8YCfXB5ZHPcxCszWhCDDGS6f9hcLm8tVrj36agyh1GS02fDBM91rj1iEIAqQULl0DJCpXf+343sSlFvLcNkf6SlF3+F8V+7GBjCyxK4sBr 3qFzBt2g F4VU59i4l0kakl5cGQsvZHLsx0OI76EumKC4dBgG/keetVjjE8UyMgUesLPiIp5I0pzj1b6TAvJeVtjyb0S0Xgl/guTNiWKqM3ZWclB0AC+tT62TAQ3fEUhxR/C9/536NJeLjJ0UhAKnWVUwTou30WIVNXQPgAebKMtIaQAUzYs5Fn8J0LVFr6AlhE0SEm3jrxqKJbGyDkV3154TIa4pBUqtGnrdHulRAYRyJgYHWSsXcIUeEIcWW2VQVj3juA1dbQyIZOSR39PSoFoOwgTHi+CKaXVCEw9dq4tw7MqGTXP9msCo1L8bDJH0ydYz84d6koGKHqkRQkWprQXDGVnUouACt+MXNLZu6Eo5rHHDfFzAj6noTMFWt0VUt6JmgSKI5mroM 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 45cc108c0fe1..b15cf47d2d29 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1587,7 +1587,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;