From patchwork Mon Mar 3 22:17:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13999550 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 81EB8C282C6 for ; Mon, 3 Mar 2025 22:17:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 898F1280006; Mon, 3 Mar 2025 17:17:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 820D4280001; Mon, 3 Mar 2025 17:17:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BFE4280006; Mon, 3 Mar 2025 17:17:41 -0500 (EST) 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 4CFFA280001 for ; Mon, 3 Mar 2025 17:17:41 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E958A161104 for ; Mon, 3 Mar 2025 22:17:40 +0000 (UTC) X-FDA: 83181652680.14.5AD7AEC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id 5B930C0006 for ; Mon, 3 Mar 2025 22:17:39 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ew3153Bk; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf28.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=1741040259; a=rsa-sha256; cv=none; b=V+FmBc1xSTV+nGso6GiNeMNYhSjWFr3BdwRSwzW0gLijZiwQ35IMtc0b7myCNNLRan33FE PZaNP547ewDNQaThZkwvfzZX9jpkryO88QQj50tV0CRDmbmtPdiFM/Vkw+R2Ozg7H6RPsz sjMm+IpMPGt1fO1NdQXFAi+q5fprOKE= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ew3153Bk; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf28.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=1741040259; 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=7VM1I87EjBHmFIzgLKfZG8vmPAT9RdZThPyM9eE4A3g=; b=oRABhxFiRmEvy/yC3z0y7wsEoF8eG41aOVFiZf3+oH+U4gGfU2ovtmgx2BNJhxx5FrU3Z3 BltUK4+O2HDdrtmiQtcUz+Xw4YDfKCKP8EOq5igJOwNaZJ/e9KeLlDQ2hS6cE+eERRPoJQ PAM7TUWWDUcOXCFkpdxhW5XmfKMqhks= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 49A335C49BE; Mon, 3 Mar 2025 22:15:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9184C4CEE9; Mon, 3 Mar 2025 22:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741040258; bh=LMPGQQlkmlc7oVmDROz8XiqF7P/8GVFp76QyeCU2ENk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ew3153Bkz/qxViCicAwx/SFps15sAAj5PmKnsoDtHn315GlNdykMREPudSZZ6nR31 jJN/cH18UFfaV2Va1eipv8RD9qWjVteCcoNWZG5M/1X3WuTiSi6KEr8DBcQd65Qbhf XntXeBf/VKlAeHyWEGdP+DpTwTRoIhxBdGvQ03vo5P9YR9ic/6WcQVU8Da6jhTKEJU kbd1YWhn4+pkfgJdzDeDcbIG5Gbxs1cZ4mvIbgNThflnMbnrpEFXLoFk4PrlPXhV2A dAmYkbVWCrA2mpP/jVmQ0WLjWfYWbTkJzVZQwAUtlH8OyDHtwxEwhmO0TK8aelxnQL DH1jB4tIGO+nA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , 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: [PATCH 6/8] Docs/mm/damon/design: document for intervals auto-tuning Date: Mon, 3 Mar 2025 14:17:24 -0800 Message-Id: <20250303221726.484227-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250303221726.484227-1-sj@kernel.org> References: <20250303221726.484227-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5B930C0006 X-Stat-Signature: ti87qh9kdaf5xu1cyqs3ahry1skwrtfj X-HE-Tag: 1741040259-886124 X-HE-Meta: U2FsdGVkX1+uYOoK0vUlqyw/fTrSacbQ97An8nD6S5szde+PLOhQnQpbbVp6y5LXgrIHxbwk5smr6L0tVOkHBbv7U6khmEDYonQVcFn7MRv3URHU2zWrEecLUJrHLgH1j7dkCchyQKJ1mj7oYq0dksJrVTPjqtM57JCHQy/qR2Fp/y/r5P8cq/vUE8MLeaeNv0AoDPhSrY/7ovS7/CsWynEPZsAVnVKsOZYrimK8h73YqZk6+CmhTqllfw6a1qstzmjlN0A0s9gaGeAyld0GQRX9fiSIMSangDu+f/RIPxJKwoR1rMw4Gsd0pfBCxjvTDX2YK38JdTEy+/kvOaxqAbS3xuV1GxkyDGTlyYHijx71/ikzKtjYVfxYCEkBN4zfBDfKvv3R7SJGPU8/1upiPiehDbBq0LrKC5EiEDE1BWerLlzls1V42CgKRQKUt4TwaTA6Ioeg04IJjYNircWeZ+UtTymHt3QRlrkZjgPl7SZ35fps8l2xomKvUEzjadQ5KxcHCVVu/bh7B+GvsT9Xy6epaRdSNLs9cNcJ1YM1JEV90jO0ZETIm9JwKEerOJZA3zIcQ4Eb8oYjWccpkpBUS638obcI+zWcckMW+46huFZV5aW10sCrWbVAlrE9Sqpl4/VKrXRIJ3vTiDz0VloKMNrjWkbvI9ITsv9A3zCEJN5/C6JEVhgeCMC4BGFjRvD9d8uvIAi7dfFD7n2eIMUngJl+8MxCeDZLz623hb8Ae/3vvUT/bWxg1EItYVGz9Wbx8+EO6j6EZKSbpp+80VfcQrDPOI9mWjuCrQKqBreCfgCpz1gP5ChPO4/6eZT2e9h1g6jNVp7aX5BuP1YwO9vxdeo7n1BDraggbL6gmcnQwLYvH8XGiKd6fZecxceb/hwTc2/QnNU8k+jN1bELeJJ+kJAKjO+yc0BX8PbIzg7bDCe836MrKnXKjGNWYDxZNKDgEFhogKQuCFiSj0U6Le4 Ld/fir86 Qim1VFQnBpsSBibxt4ZqCoP0IEucBoCC8SYD/lQfXz463t3GXEI4cmyqriWIlYvAbc8phsRtilXzlb45Jc1o7wM1oDXCdLGuOCMjcdWwFRbK/phuOtXOQqe2hgHNrHb1tfgPAMj5rlUAFrsWBKsCYrbJBr+z2EU4fidYaaT1Ai1LsDV16gBw/AjpILkYSf4dqDzt+4QBMHwn6RznEWngrq/5BEJJxQ0doSshmofubfoZC1K08kgFOKPDMxX1iHRwMtAESbYcUoEHWudg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 5af991551a86..cb388d791ff7 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