From patchwork Fri Sep 15 02:52:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 14020 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp765501vqi; Thu, 14 Sep 2023 19:53:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGskdd3oWsfHNWpYI95YyFUJywauIKabZUf0vCU3/cGfM8bUj3yRrFSBf/h6OVNbS/citKh X-Received: by 2002:a05:6a20:3952:b0:137:a3c9:aaa9 with SMTP id r18-20020a056a20395200b00137a3c9aaa9mr687261pzg.16.1694746395913; Thu, 14 Sep 2023 19:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694746395; cv=none; d=google.com; s=arc-20160816; b=msq3Sqj6W1lfbBYQQainUd01SsXua6ljEOqWy76V4qKjtTL/8rdZOcKPI1I2G2WoRn 4lNvWh65qumR9YfmEgeZsQZ8wWXdG4UPLSXDMDNC1agmfKWopDbemdG4MH/phqBoHZt2 fmO+rncbRxHimmu4WjBFmhrvb7GUaqq1nZKWsXkQVqkYb9gkXAHBaKDuzhTszCmWWeec lCjUDueJc2WuiN6R34iFRC6fbm+znZbG3vTGWKoKb3Vet+4bUb+1r+LpJMQGha6PdLEH DIg9OhWUAnMiaUSlEGMLNiWUK6qzOiz5T8fdFH7Z2XddhVqYdHIqBHSXWdKnLcc60cyR KBQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=543nhK1IPl9Jpo1hsmWEbS+0QfkL2YjCC2FfQLT+dqI=; fh=KYrqrUZLyrFtzsRGU6oAoSUmY0DAP9CMMvmnxe+fdzY=; b=qTWPwVkLQItf3fRgasn6n/IullaeUaB9C2dpNqptSL5Ip9P1f+NhQyUTN26Yw86S51 7H45WO9hyfKsV1VrOFWGmOT/1vOEBJH0mJIwHnLh0nITiGCH2U0QaCjHsEZFtyVG9rWr qwF+Zzisstcrr2dN5fAtQH/R7IjM/fxdb87R/AEjKrV7arvNvGiTu8CLG8mFjjkauuhd vWkYV7e+F8OQ+I0mEeSC6rN+vW0iEXoEFz24/R0CTM0/3iM96r7z6aQGHNO4Jul1dQQq ryEP8drbaThNOtoBRYf//oa2YxGUtrD8uj8hJvqoxUsemB1DXfnxFL77YFxEGTy21XaS gvAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cI0cRs6q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k3-20020a633d03000000b0057748a05fcfsi2564572pga.27.2023.09.14.19.53.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 19:53:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cI0cRs6q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 823998390001; Thu, 14 Sep 2023 19:53:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231519AbjIOCxF (ORCPT + 33 others); Thu, 14 Sep 2023 22:53:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbjIOCxE (ORCPT ); Thu, 14 Sep 2023 22:53:04 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F1B726AB; Thu, 14 Sep 2023 19:53:00 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 095D2C433C8; Fri, 15 Sep 2023 02:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694746379; bh=BMoIA/XytQAickyMtxvDt0cV0B7GH433aHBEMFeeRZA=; h=From:To:Cc:Subject:Date:From; b=cI0cRs6qX5hHpd59KhlA3hhK/Qql5/OjdtMEa3olBNhsnYd/e3op+jcl3KLu0BV8w RiEYfVAoYEvsFOzZvj27inW/LGydZnbhhHXGcPjfnz25pHn0jwDd1ILy8UKvbN9zB3 OK2C7gXEQnKz3Vr60XXbCjyF8tPWZE+++a5tVe21EWqxU++Ci5bCOlRqQBxQ4vju+w gJq25kZYHVM3a46zVBvfPUAT8vRgQy5n9GUlelf6ALlF6imhHL/rAQnc/UTJ3iv4tG +16xC6MX6g3x/v2SqaDqjBK3e9BuOsJedv6ba6keD2wIfOpwEeZAjRZzjMnjab2s+h 5uTX7Yzl3Svog== 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 0/8] mm/damon: provide pseudo-moving sum based access rate Date: Fri, 15 Sep 2023 02:52:43 +0000 Message-Id: <20230915025251.72816-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 14 Sep 2023 19:53:12 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777070397015107131 X-GMAIL-MSGID: 1777070397015107131 Changes from RFC (https://lore.kernel.org/damon/20230909033711.55794-1-sj@kernel.org/) - Rebase on latest mm-unstable - Minor wordsmithing of coverletter DAMON checks the access to each region for every sampling interval, increase the access rate counter of the region, namely nr_accesses, if the access was made. For every aggregation interval, the counter is reset. The counter is exposed to users to be used as a metric showing the relative access rate (frequency) of each region. In other words, DAMON provides access rate of each region in every aggregation interval. The aggregation avoids temporal access pattern changes making things confusing. However, this also makes a few DAMON-related operations to unnecessarily need to be aligned to the aggregation interval. This can restrict the flexibility of DAMON applications, especially when the aggregation interval is huge. To provide the monitoring results in finer-grained timing while keeping handling of temporal access pattern change, this patchset implements a pseudo-moving sum based access rate metric. It is pseudo-moving sum because strict moving sum implementation would need to keep all values for last time window, and that could incur high overhead of there could be arbitrary number of values in a time window. Especially in case of the nr_accesses, since the sampling interval and aggregation interval can arbitrarily set and the past values should be maintained for every region, it could be risky. The pseudo-moving sum assumes there were no temporal access pattern change in last discrete time window to remove the needs for keeping the list of the last time window values. As a result, it beocmes not strict moving sum implementation, but provides a reasonable accuracy. Also, it keeps an important property of the moving sum. That is, the moving sum becomes same to discrete-window based sum at the time that aligns to the time window. This means using the pseudo moving sum based nr_accesses makes no change to users who shows the value for every aggregation interval. Patches Sequence ---------------- The sequence of the patches is as follows. The first four patches are for preparation of the change. The first two (patches 1 and 2) implements a helper function for nr_accesses update and eliminate corner case that skips use of the function, respectively. Following two (patches 3 and 4) respectively implement the pseudo-moving sum function and its simple unit test case. Two patches for making DAMON to use the pseudo-moving sum follow. The fifthe one (patch 5) introduces a new field for representing the pseudo-moving sum-based access rate of each region, and the sixth one makes the new representation to actually updated with the pseudo-moving sum function. Last two patches (patches 7 and 8) makes followup fixes for skipping unnecessary updates and marking the moving sum function as static, respectively. SeongJae Park (8): mm/damon/core: define and use a dedicated function for region access rate update mm/damon/vaddr: call damon_update_region_access_rate() always mm/damon/core: implement a pseudo-moving sum function mm/damon/core-test: add a unit test for damon_moving_sum() mm/damon/core: introduce nr_accesses_bp mm/damon/core: use pseudo-moving sum for nr_accesses_bp mm/damon/core: skip updating nr_accesses_bp for each aggregation interval mm/damon/core: mark damon_moving_sum() as a static function include/linux/damon.h | 16 +++++++++- mm/damon/core-test.h | 21 ++++++++++++ mm/damon/core.c | 74 +++++++++++++++++++++++++++++++++++++++++++ mm/damon/paddr.c | 11 +++---- mm/damon/vaddr.c | 22 +++++++------ 5 files changed, 128 insertions(+), 16 deletions(-) base-commit: a5b7405a0eaa74d23547ede9c3820f01ee0a2c13