From mboxrd@z Thu Jan 1 00:00:00 1970 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 CB3DCC433EF for ; Wed, 23 Feb 2022 16:07:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BD288D0023; Wed, 23 Feb 2022 11:07:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 36CAD8D0011; Wed, 23 Feb 2022 11:07:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20D9A8D0023; Wed, 23 Feb 2022 11:07:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EA9308D0011 for ; Wed, 23 Feb 2022 11:07:27 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 791A6181E4363 for ; Wed, 23 Feb 2022 16:07:27 +0000 (UTC) X-FDA: 79174524534.27.8C93174 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf28.hostedemail.com (Postfix) with ESMTP id 8D23CC0011 for ; Wed, 23 Feb 2022 16:07:26 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DE8E3B81FB2; Wed, 23 Feb 2022 16:07:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2564BC340E7; Wed, 23 Feb 2022 16:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645632443; bh=Z34PCtXMMsF3CAqfeAJGNk1FOL8QxYRwGsxHBin6cUQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SBQId/o0oYtkOWz3frKGtl9gGu+5eSCVVPDH/2mihwFhxIqZtvNqC6Ua/gknPlXCC 6SUeq4kggreTtuMHRtYXcCULyv5O4jnl7IkrqgaL5cz3JNpUtKDLX3EOGIH8KK1Xj6 h/rTbu1lze8+A+ZQQbjPSZMd+LVVJh4JviM0Afl8= Date: Wed, 23 Feb 2022 17:07:20 +0100 From: Greg KH To: SeongJae Park Cc: akpm@linux-foundation.org, corbet@lwn.net, skhan@linuxfoundation.org, rientjes@google.com, xhao@linux.alibaba.com, linux-damon@amazon.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 00/12] Introduce DAMON sysfs interface Message-ID: References: <20220223152051.22936-1-sj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220223152051.22936-1-sj@kernel.org> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8D23CC0011 X-Stat-Signature: g8g3gybpkrix6bdgpb9sxqqr1c4r9g5r Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b="SBQId/o0"; spf=pass (imf28.hostedemail.com: domain of gregkh@linuxfoundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org X-HE-Tag: 1645632446-133612 Content-Transfer-Encoding: quoted-printable 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: On Wed, Feb 23, 2022 at 03:20:39PM +0000, SeongJae Park wrote: > Chages from Previous Version (RFC) > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > Compared to the RFC version of this patchset > (https://lore.kernel.org/linux-mm/20220217161938.8874-1-sj@kernel.org/)= , this > version contains below changes. >=20 > - Implement all DAMON debugfs interface providing features > - Writeup documents > - Add more selftests >=20 > Introduction > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > DAMON's debugfs-based user interface (DAMON_DBGFS) served very well, so= far. > However, it unnecessarily depends on debugfs, while DAMON is not aimed = to be > used for only debugging. Also, the interface receives multiple values = via one > file. For example, schemes file receives 18 values. As a result, it i= s > inefficient, hard to be used, and difficult to be extended. Especially= , > keeping backward compatibility of user space tools is getting only chal= lenging. > It would be better to implement another reliable and flexible interface= and > deprecate DAMON_DBGFS in long term. >=20 > For the reason, this patchset introduces a sysfs-based new user interfa= ce of > DAMON. The idea of the new interface is, using directory hierarchies a= nd > having one dedicated file for each value. For a short example, users c= an do > the virtual address monitoring via the interface as below: >=20 > # cd /sys/kernel/mm/damon/admin/ > # echo 1 > kdamonds/nr > # echo 1 > kdamonds/0/contexts/nr > # echo vaddr > kdamonds/0/contexts/0/operations > # echo 1 > kdamonds/0/contexts/0/targets/nr > # echo $(pidof ) > kdamonds/0/contexts/0/targets/0/pid > # echo on > kdamonds/0/state >=20 > A brief representation of the files hierarchy of DAMON sysfs interface = is as > below. Childs are represented with indentation, directories are having= '/' > suffix, and files in each directory are separated by comma. >=20 > /sys/kernel/mm/damon/admin > =E2=94=82 kdamonds/nr > =E2=94=82 =E2=94=82 0/state,pid > =E2=94=82 =E2=94=82 =E2=94=82 contexts/nr > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 0/operations > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 monitoring_attrs/ > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 interva= ls/sample_us,aggr_us,update_us > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 nr_regi= ons/min,max > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 targets/nr > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 0/pid > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82= regions/nr > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82= =E2=94=82 0/start,end > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82= =E2=94=82 ... > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 ... > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 schemes/nr > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 0/action > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 access_= pattern/ > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82= sz/min,max > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82= nr_accesses/min,max > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82= age/min,max > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 quotas/= ms,sz,reset_interval_ms > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82= weights/sz,nr_accesses,age > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 waterma= rks/metric,interval_us,high,mid,low > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 stats/n= r_tried,sz_tried,nr_applied,sz_applied,qt_exceeds > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 ... > =E2=94=82 =E2=94=82 ... >=20 > Detailed usage of the files will be described in the final Documentatio= n patch > of this patchset. >=20 > Main Difference Between DAMON_DBGFS and DAMON_SYSFS > --------------------------------------------------- >=20 > At the moment, DAMON_DBGFS and DAMON_SYSFS provides same features. One > important difference between them is their exclusiveness. DAMON_DBGFS = works in > an exclusive manner, so that no DAMON worker thread (kdamond) in the sy= stem can > run concurrently and interfere somehow. For the reason, DAMON_DBGFS as= ks users > to construct all monitoring contexts and start them at once. It's not = a big > problem but makes the operation a little bit complex and unflexible. >=20 > For more flexible usage, DAMON_SYSFS moves the responsibility of preven= ting any > possible interference to the admins and work in a non-exclusive manner.= That > is, users can configure and start contexts one by one. Note that DAMON > respects both exclusive groups and non-exclusive groups of contexts, in= a > manner similar to that of reader-writer locks. That is, if any exclusi= ve > monitoring contexts (e.g., contexts that started via DAMON_DBGFS) are r= unning, > DAMON_SYSFS does not start new contexts, and vice versa. >=20 > Future Plan of DAMON_DBGFS Deprecation > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > Once this patchset is merged, DAMON_DBGFS development will be frozen. = That is, > we will maintain it to work as is now so that no users will be break. = But, it > will not be extended to provide any new feature of DAMON. The support = will be > continued only until next LTS release. After that, we will drop DAMON_= DBGFS. >=20 > User-space Tooling Compatibility > -------------------------------- >=20 > As DAMON_SYSFS provides all features of DAMON_DBGFS, all user space too= ling can > move to DAMON_SYSFS. As we will continue supporting DAMON_DBGFS until = next LTS > kernel release, user space tools would have enough time to move to DAMO= N_SYSFS. >=20 > The official user space tool, damo[1], is already supporting both DAMON= _SYSFS > and DAMON_DBGFS. Both correctness tests[2] and performance tests[3] of= DAMON > using DAMON_SYSFS also passed. >=20 > [1] https://github.com/awslabs/damo > [2] https://github.com/awslabs/damon-tests/tree/master/corr > [3] https://github.com/awslabs/damon-tests/tree/master/perf >=20 > Complete Git Tree > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > You can get the complete git tree from > https://git.kernel.org/sj/h/damon/sysfs/patches/v1. >=20 > Sequence of Patches > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > First two patches (patches 1-2) make core changes for DAMON_SYSFS. The= first > one (patch 1) allows non-exclusive DAMON contexts so that DAMON_SYSFS c= an work > in non-exclusive mode, while the second one (patch 2) adds size of DAMO= N enum > types so that DAMON API users can safely iterate the enums. >=20 > Third patch (patch 3) implements basic sysfs stub for virtual address s= paces > monitoring. Note that this implements only sysfs files and DAMON is no= t > linked. Fourth patch (patch 4) links the DAMON_SYSFS to DAMON so that = users > can control DAMON using the sysfs files. >=20 > Following six patches (patches 5-10) implements other DAMON features th= at > DAMON_DBGFS supports one by one (physical address space monitoring, DAM= ON-based > operation schemes, schemes quotas, schemes prioritization weights, sche= mes > watermarks, and schemes stats). >=20 > Following patch (patch 11) adds a simple selftest for DAMON_SYSFS, and = the > final one (patch 12) documents DAMON_SYSFS. >=20 > SeongJae Park (12): > mm/damon/core: Allow non-exclusive DAMON start/stop > mm/damon/core: Add number of each enum type values > mm/damon: Implement a minimal stub for sysfs-based DAMON interface > mm/damon/sysfs: Link DAMON for virtual address spaces monitoring > mm/damon/sysfs: Support physical address space monitoring > mm/damon/sysfs: Support DAMON-based Operation Schemes > mm/damon/sysfs: Support DAMOS quotas > mm/damon/sysfs: Support schemes prioritization weights > mm/damon/sysfs: Support DAMOS watermarks > mm/damon/sysfs: Support DAMOS stats > selftests/damon: Add a test for DAMON sysfs interface > Docs/admin-guide/mm/damon/usage: Document DAMON sysfs interface >=20 > Documentation/admin-guide/mm/damon/usage.rst | 349 ++- > include/linux/damon.h | 6 +- > mm/damon/Kconfig | 7 + > mm/damon/Makefile | 1 + > mm/damon/core.c | 23 +- > mm/damon/dbgfs.c | 2 +- > mm/damon/reclaim.c | 2 +- > mm/damon/sysfs.c | 2684 ++++++++++++++++++ > tools/testing/selftests/damon/Makefile | 1 + > tools/testing/selftests/damon/sysfs.sh | 306 ++ > 10 files changed, 3364 insertions(+), 17 deletions(-) > create mode 100644 mm/damon/sysfs.c > create mode 100755 tools/testing/selftests/damon/sysfs.sh sysfs files need to be documented in Documentation/ABI/ which is where our tools look for them (have you run scripts/get_abi.pl with your code in the kernel?) Please fix this up to use that format so we can then verify that you are using sysfs correctly. thanks, greg k-h