From patchwork Thu Dec 19 04:03:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13914441 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 E38D9E77184 for ; Thu, 19 Dec 2024 04:03:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7541F6B0082; Wed, 18 Dec 2024 23:03:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7032C6B0083; Wed, 18 Dec 2024 23:03:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F26C6B0085; Wed, 18 Dec 2024 23:03:42 -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 42C2E6B0082 for ; Wed, 18 Dec 2024 23:03:42 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B130812109B for ; Thu, 19 Dec 2024 04:03:41 +0000 (UTC) X-FDA: 82910363088.03.270808C Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf05.hostedemail.com (Postfix) with ESMTP id D40C310000F for ; Thu, 19 Dec 2024 04:02:37 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oLOgUS5M; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1734581005; 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:references:dkim-signature; bh=eZiOCihHCel8zsWLJ8j5aj6I+FbCl1YwbszkmtADzk4=; b=fJx5t++w1z0pos3JSwyY7ZEOzA5b3bcJSnFCBhi493A7GNieNjMsGjZyKnSPz4TOXXSPxk a6xeAhDxKHOhDFw/8YnyuKlUr31H4yLI79HHUmtR5V2l2Mk531KuNNXlAbnLhRYL9+BqOr +rOatcQ6IlFZPM1cVAwKElRa/l5n4x8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734581005; a=rsa-sha256; cv=none; b=bEq/afJvrntMU7Ir2BlUOlgOGaOEDqBsSmEpQKcj459msxXITT0QUnic8A9AVyDOG4o6ZO ukO9gqymyEcjOPyjJFMRYe8wlKs4L2yu4RbQpeOLDp2zzfWAgM7j85hpcM2txF+1PYgeKO AxSkbPtZQXMMbQr53zt4glcLVrhCHEY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oLOgUS5M; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id CD82DA40FEA; Thu, 19 Dec 2024 04:01:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF55BC4CED4; Thu, 19 Dec 2024 04:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734581019; bh=yTFAxcbPoCTrpJqmhdVdqAR+kuxXaJ5DPD927bcaAic=; h=From:To:Cc:Subject:Date:From; b=oLOgUS5MLJDjWezERfK3zz8SRJGJeVreDsOUGZIu8QcUqmHN1MZAH9XFVufoVBr6E adcIthkyM3Ie7eHWFvmjln9GE+lRS2UreOPCWllHFTbqzWhvBbM2M3ARYlIY91f/kw /51nGgOdFC7VE7Ll44co43jfji1A2zKiWWTkYjnJXNIZ2JNQ7WBWW+DPPq16tmRddr lDSFsNAKsC6T6OaiZJErlvK609Xrdb8mK8C6VtnNJ0DNa9EudQ6MGy8RLs6qeqp8bH YWfFMPy6q6d4Gon12yHDN9qNVaCb/zx9DXOMSytp3zdXI5guOv+M3ZV1FFPzPw14mG cF1CVmZ153Tmg== From: SeongJae Park To: Cc: kernel-team@meta.com, SeongJae Park , Andrew Morton , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 00/18] mm/damon: enable page level properties based access pattern monitoring Date: Wed, 18 Dec 2024 20:03:09 -0800 Message-Id: <20241219040327.61902-1-sj@kernel.org> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-Stat-Signature: a98az3cbghn4ct35gszinwxth88rrmy5 X-Rspamd-Queue-Id: D40C310000F X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734580957-624420 X-HE-Meta: U2FsdGVkX19lwENZ5nVMRjq7n//5R3bTESRSCShOQiZRsK07rySs4pSX9RSyVoHErs56vWUjaDyMBWF0sE9wapidvYXjEDBznH62TFDxqpnB9wHJT1qze3xZmx6ikQfX27KvtxeiIPp33L6ZlQ9rskZjNRSmvUcnNeVavEf8lEWt+jSWFN4ozpBokx5u9+9XW6Hb62l6BcUScTitU/80p/w1+L04PxE1MkCy/YgeLtItEWJcRbS+WhHzZYqmg2UjHcowZa+1QdyHnawxFk2A2JhIlrlTXRzLRhBrcZAmXtbqkKlgRwuLmb8/rhiDqtkHylbuk8zH8KCcj+vC5s05Dz38bqX1FTNoF7Rr6F7vjVRD0efGfOCXc0486WCVPFT1tRN+Y8NbhghUBVm3SRNTPPE+VetHeuDCk9QEbl/cMdyEXWI1QkemqNl3odSq+LaonKiKaRYl1d+jOHPwoKqAUfQH9QNLYUJH+lSn5b1IznFnV/KPhJ9W/IseKMRKw/aDRKK8LL8DXZV5hdCRGnUNC9JfZSNmEYL8ZmJLQvCOPM01Kf5/pmxH1FfV5WxnurJEARZqei0WbXinLDFqPkcJUWAg4cWJQRJ7jXL4FdGgDzCCzsxbfsp500kGeSPcFx5px2vjCDYh2bwVWMEHyp/1xQwk3vZzSxmis0pOq/6JRdK42++061Ytzz12YTbxAAclUlLoQFImnsRt9LKOJkb8/sF/+bwllPCl8UwOIF7TnqMKlhPrX61N0yGcpTuh3dwNNA7y+3cmYsZ/POoJxlmcOQYYBWRi3P8n7cfCOqKwk8K3A8dvgWwnFuY1UZpW878ENIXxoht+YnSzUNuQtNldu8Xyp3l6ml8dyOTwTclofGFENCiePfVgZHyglWEC3CKg6k9fzADPiNigCI+VOj3PKAu2aArsh5ec7DGpXT9/T7ZBwsv1kcQNKlALyeGKRmKUBwROmWG6FHTZEBlnQSo D28qDYW4 OigXJTMxISEBvpV+2AiMukFEuYbvmeiJ2gNwHyZGyWng8yGwLox3kK2+msziAS4X2v2ZkeiO8OfImEx/P+t8R/KZ7H4ZyXGqXFTR1vrJhvJayvLonmDsLukrkcfKRBXHPwvDtHHbn/OlbqBWPIDFx9L8DNS8EQyA+A8MY//Y3E8CUK4kLHI7Z3ZEeehK+Y7fkC75Cj4EctpL93GKWF27xkhDB1oO4Egs/c++cbwdSwUUl1Po= 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: List-Subscribe: List-Unsubscribe: TL; DR ====== This patch series eanble access monitoring based on page level properties including their anonymousness, belonging cgroups and pg-young-ness, by extending DAMOS stats and regions walk features with region-internal DAMOS filters. Background ========== DAMON fundametally provides only access pattern information in region granularity. For some use cases, fixed and fine granularity information based on non access pattern properties can be useful, though. For example, on systems having fast swap devices and slow storage devices, DAMOS-based proactive reclaim need to be applied differently for anonymous pages and file-backed pages. DAMOS makes it possible via DAMOS filters that work in page level properties including anonymousness, belonging cgroups, and pg-young-ness. Having only the fine-grained inforamtion without making system operation behavior changes can be useful for tuning or monitoring purposes. But currently DAMON provides no way for that. Idea ==== DAMOS has initially developed for only access-aware system operations. But, efficient acces monitoring results querying is yet another major usage of today's DAMOS. DAMOS stats and regions walk, which exposes accumulated counts and per-region monitoring results that filtered by DAMOS parameters including target access pattern and quotas, are the key features for that usage. Special DAMOS action, DAMOS_STAT, was also introduced to support doing only monitoring without making any system operation behavioral changes. Hence, the fine-grained information that already available for access-aware system operation can be passed to users by connecting the region-internal DAMOS filters with stats and regions walk features. Design ====== Update the interface of DAMON operations set layer, which contains region-internal DAMOS filters implementation, to report back the amount of memory that passed the region-internal DAMOS filters to the core layer. On the core layer, account the operations set layer reported stat with a per-scheme accumulated stat. Also, pass the stat to regions walk. In this way, DAMON API users can efficiently get the fine-grained information. For the user-space, make DAMON sysfs interface collects the information using DAMON core API, and expose those to new per-scheme stats file and per-DAMOS-tried region properties file. Practical Usages ================ With this patch series, DAMON users can query how many bytes of regions of specific access temperature is backed by pages of specific type. The type can be any of DAMOS filter-supporting one, including anonymousness, belonging cgroups, and pg-young-ness. For example, users can visualize access hotness-based page granulairty histogram for different cgroups, backing content type, or youngness. In future, it could be extended to more types such as whether it is THP, position on LRU lists, etc. This can be useful for estimating benefits of a new or an existing access-aware system optimizations without really committing the changes. Patches Sequence ================ The patches are separated in four sequences. First four patches add adding documentation of background knowledge. Following three patches change the operations set layer interface to report back the region-internal filter passed memory size, and make the operations set implementations support the changed symantic. Following five patches implement per-scheme accumulated stat for region-internal filter-passed memory size on core API, DAMON sysfs interface. First two patches of those are for code change, and following three patches are for documentation. Finally, six patches implementing per-region region-internal filter-passed memory size follows. First three patches of these are for code change of preparation, API, and DAMON sysfs interface parts. The final three patches are for documentation. Misc Notes ========== This patch series depend on another RFC patch series[1] that introduced damos_call(). Some of patches here, particularly the one that adds Documentation for damos_call() and changing damos_call_control->walk_fn() invocation sequence, may be moved and folded into the patch series when it drops RFC tag. [1] https://lore.kernel.org/20241213215306.54778-1-sj@kernel.org SeongJae Park (18): mm/damon: clarify trying vs applying on damos_stat kernel-doc comment Docs/mm/damon/design: document DAMOS regions walking Docs/mm/damon/design: add 'statistics' section Docs/admin-guide/mm/damon/usage: link damos stat design doc mm/damon: ask apply_scheme() to report filter-passed region-internal bytes mm/damon/paddr: report filter-passed bytes back for normal actions mm/damon/paddr: report filter-passed bytes back for DAMOS_STAT action mm/damon/core: implement per-scheme filter-passed bytes stat mm/damon/syfs-schemes: implement per-scheme filter-passed bytes stat Docs/mm/damon/design: document sz_ops_filter_passed Docs/admin-guide/mm/damon/usage: document sz_ops_filter_passed Docs/ABI/damon: document per-scheme filter-passed bytes stat file mm/damon/core: invoke damos_walk_control->walk_fn() after applying action mm/damon/core: pass per-region filter-passed bytes to damos_walk_control->walk_fn() mm/damon/sysfs-schemes: expose per-region filter-passed bytes Docs/mm/damon/design: document per-region sz_filter_passed stat Docs/admin-guide/mm/damon/usage: document sz_filtered_out of scheme tried region directories Docs/ABI/damon: document per-region DAMOS filter-passed bytes stat file .../ABI/testing/sysfs-kernel-mm-damon | 13 ++++ Documentation/admin-guide/mm/damon/usage.rst | 29 ++++---- Documentation/mm/damon/design.rst | 53 ++++++++++++++ include/linux/damon.h | 27 ++++++- mm/damon/core.c | 31 ++++---- mm/damon/paddr.c | 70 +++++++++++++++---- mm/damon/sysfs-common.h | 2 +- mm/damon/sysfs-schemes.c | 34 ++++++++- mm/damon/sysfs.c | 5 +- mm/damon/vaddr.c | 2 +- 10 files changed, 216 insertions(+), 50 deletions(-) base-commit: af113b0c56e321562fb85ef5da57f323c34b616b