From patchwork Fri Feb 28 22:03:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13997211 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 BD873C282C5 for ; Fri, 28 Feb 2025 22:03:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DFBF280008; Fri, 28 Feb 2025 17:03:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 88251280001; Fri, 28 Feb 2025 17:03:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FB61280008; Fri, 28 Feb 2025 17:03:41 -0500 (EST) 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 490AE280001 for ; Fri, 28 Feb 2025 17:03:41 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C8BCDC1398 for ; Fri, 28 Feb 2025 22:03:40 +0000 (UTC) X-FDA: 83170731000.05.067FD59 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf29.hostedemail.com (Postfix) with ESMTP id 3BCAA120007 for ; Fri, 28 Feb 2025 22:03:39 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ajQa2jtK; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740780219; 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=SaLnG8F9so66bZwrCQn2mXwK3Qz8oyckNSgefMuW9WE=; b=TXyq+kYpVPCS3RIrMuzt6ppH/0tFl2Da1ZLbw3EYe4/HpidFhCvR1/1q2m2SiN4EML9gzH szmSkMO0DWlCZMgOObHZKaj3di3i3L4l1gVGxIhTA2w2La1RxY+v/mHHjN9JCjQhy2ixz0 jLTrZKX+uLyVUseT2CedZVQJSggR6zs= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ajQa2jtK; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740780219; a=rsa-sha256; cv=none; b=iSjihXj+zkK6KlkJwI7Hh5+E38ZX5hIrhIvXLQ7h9DY/qvQppicU6FxCoQy3M1usfbtDE2 6dxpo1TOvEGifHDnGu4miXSVBA/Mxw3QRVnkACviHrzVTNBLtTfO8KpoKaKPltfW6SMaUp 9yyKSaPNedm4CXL79lePrIlCQi3Cfrk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 243AA61160; Fri, 28 Feb 2025 22:03:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B641C4CEE9; Fri, 28 Feb 2025 22:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740780218; bh=lz38ZfaiLRvrAxvubSW+sgoHg1CnZkQRWxBUnqzdWlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ajQa2jtKMbyi6nxzW5Lc6EVqDsUDtcxOIO2hfWYywHFkfkP4rbp5RZAMPZNmG715S UCM+wPFTFQPTDm/5EebwAntpeZuspJtiJg3R0GIstymjrCq/0YiyKgkqa8t5mtloPf yWMUNq/SIWdWFIeunONR3vARkdI03fGWwnyBf3PftIGIvaH5ZDm6iHeH62oJQc3MPe k41CHY3GqcGlVpqcMzvu34bAin6xmou7DwaWGJSOlvagKbejFCNrVGb3UKuH8gHjJU RsgiZzZm7vJg6aVneFZD4mAccNKMnXuSN1VaocW4xg6nl48Vcp38nBo6oZA8cpED5i g6VUMB9GkbSfA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Jonathan Corbet , damon@lists.linux.dev, kernel-team@meta.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v2 6/8] Docs/mm/damon/design: document for intervals auto-tuning Date: Fri, 28 Feb 2025 14:03:26 -0800 Message-Id: <20250228220328.49438-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250228220328.49438-1-sj@kernel.org> References: <20250228220328.49438-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 3BCAA120007 X-Rspamd-Server: rspam09 X-Stat-Signature: heyzujruaczz5fh19if8u5wpkwfs6yh3 X-HE-Tag: 1740780219-755137 X-HE-Meta: U2FsdGVkX1/Gb8y1rQyZvrOMhQ2FRFeGg6jIYhKD0VFZgtK/gFsrcgdWhcgh6mVUnLaS13Elvbg9j4RRFskPfT98FOjgPN82u53gJyxY0SOIHNhk/bazr5hje4cWNKpvSW+B7KX+fobl3t8+/Kae/70GcXJpaEPYqcch+g//O9KFDlnUshrAQWgbsv22do07SfbM3bjXYe+Nku4IH4mHAmPWA5hQZNy+M+ZARRMmQXiKPoX0ByC/obToe53GnfyLkN/JL2LTpYMHlKQtu/dyeYs0tEPBoThMRqZeDUJhL+R4VyVgHwo3kvWorDKeED52U6E+VFCy8aodGz4hMvnV4F0zVHBh434Ltxv0j7xiYU7ifQNZ1YAvnEN94MdSbRj5CpZKAhMUHWI68Wre6OYkwm0wDcmNYA7GB1FraxLDCFfZFKdMuFOYejCra+Mp6vfcUebF3TEn8eUeaaDu0sIg2/oq91qNeBmoMssZhxSmXQwOw0oR94xd0qSjNWZ5muvb4ArYPxBwWJW58nGrkapUizVOk8vtqsfklojN3+c2ieniOquvq3iFNYfX7bmhZuSl6/QCL2qvo/ZVLXh0sJcMo59vBTl3UMYJjWn0L1Qz0vnqdh74+Scfm/7VtTtWCDRcq8Xc92H5HjdncBq32LvOia4aOJClWZaGUbzqqCr9cAELwJ7Q8EzO3oVm3cvW8y6QSGKqhKLCxW3Boj00bd+e08Gfwn83ibOdNm+z/d8WaK4DQY2BFF+UjBo4DhXvDDomHrEX87BBQaQVZpyWbAWnCZHs8nSdwfxLseFmx/Dok/mu9jn4+gXE5w1hm9qb7njmJEtx4CwXDiPUOqGAu/ZdDNLfjwJkissREPTakng60a3F+6iMJ3J6HOzaoL6wKyEpzLtEy3MtlnJlhxuuwSUAM8TGJRKgTK56ZZaD3BCanLWm1u099KVzUdgzGSAko0UmBUZ9rfiz27OC7yy5I2B Tm1GCm0W NRRYLNGma+lh4tygnVwH+Gy4/VauzgPYsfQYx9emal81V40ytbue/eLXtOnkRqqD6rDT7kh6cZtpaTPzx1aMLoqM16Js/7HwbpYIyynPWPrYnCZMPFixSWXWdRG/ryAIbQtjk9hhZG7VjSP8GKJT5CRpqG7MATgLvEZ+EFY46z77MCy0Em6IX92+aPu9cw/MjdpFfnEt7iJApagWzM3UrsaCA5Hayo0vbZDTc99bfOriYZgXl4WXIJ5xlpgNoDZ0LSpv73QGQQRoRmlQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000206, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Document the design of DAMON sampling and aggregation intervals auto-tuning. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst index ffea744e4889..0cc9f6441354 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -313,6 +313,10 @@ sufficient for the given purpose, it shouldn't be unnecessarily further lowered. It is recommended to be set proportional to ``aggregation interval``. By default, the ratio is set as ``1/20``, and it is still recommended. +Based on the manual tuning guide, DAMON provides more intuitive knob-based +intervals auto tuning mechanism. Please refer to :ref:`the design document of +the feature ` for detail. + Refer to below documents for an example tuning based on the above guide. .. toctree:: @@ -321,6 +325,48 @@ Refer to below documents for an example tuning based on the above guide. monitoring_intervals_tuning_example +.. _damon_design_monitoring_intervals_autotuning: + +Monitoring Intervals Auto-tuning +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +DAMON provides automatic tuning of the ``sampling interval`` and ``aggregation +interval`` based on the :ref:`the tuning guide idea +`. The tuning mechanism allows +users to set the aimed amount of access events to observe via DAMON within +given time interval. The target can be specified by the user as a ratio of +DAMON-observed access events to the theoretical maximum amount of the events +(``access_bp``) that measured within a given number of aggregations +(``aggrs``). + +The DAMON-observed access events are calculated in byte granularity based on +DAMON :ref:`region assumption `. For +example, if a region of size ``X`` bytes of ``Y`` ``nr_accesses`` is found, it +means ``X * Y`` access events are observed by DAMON. Theoretical maximum +access events for the region is calculated in same way, but replacing ``Y`` +with theoretical maximum ``nr_accesses``, which can be calculated as +``aggregation interval / sampling interval``. + +The mechanism calculates the ratio of access events for ``aggrs`` aggregations, +and increases or decrease the ``sampleing interval`` and ``aggregation +interval`` in same ratio, if the observed access ratio is lower or higher than +the target, respectively. The ratio of the intervals change is decided in +proportion to the distance between current samples ratio and the target ratio. + +The user can further set the minimum and maximum ``sampling interval`` that can +be set by the tuning mechanism using two parameters (``min_sample_us`` and +``max_sample_us``). Because the tuning mechanism changes ``sampling interval`` +and ``aggregation interval`` in same ratio always, the minimum and maximum +``aggregation interval`` after each of the tuning changes can automatically set +together. + +The tuning is turned off by default, and need to be set explicitly by the user. +As a rule of thumbs and the Parreto principle, 4% access samples ratio target +is recommended. Note that Parreto principle (80/20 rule) has applied twice. +That is, assumes 4% (20% of 20%) DAMON-observed access events ratio (source) +to capture 64% (80% multipled by 80%) real access events (outcomes). + + .. _damon_design_damos: Operation Schemes