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 1A883C433F5 for ; Fri, 25 Feb 2022 08:05:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B58A8D0002; Fri, 25 Feb 2022 03:05:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7650D8D0001; Fri, 25 Feb 2022 03:05:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65EDC8D0002; Fri, 25 Feb 2022 03:05:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id 533428D0001 for ; Fri, 25 Feb 2022 03:05:21 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F34549F32A for ; Fri, 25 Feb 2022 08:05:20 +0000 (UTC) X-FDA: 79180567242.30.3BBFE62 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 5DAB01A000B for ; Fri, 25 Feb 2022 08:05:20 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 8BD5261BE3; Fri, 25 Feb 2022 08:05:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 156CBC340E7; Fri, 25 Feb 2022 08:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645776318; bh=R8Z4PS4bqFbVj1m0cBD53CKo7jMpJ9THvKAGLBQf9oM=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=SPkRrLaOLKMIxxH9f9JcRA6CW6sx836DiPSgqMMrnYIvCE/O5XlpRLSzNRyKOCgFR khzLwdIlspdVyx9yDgJwzbLTpXRqEcsrOYbKPCXz2VvPsj+ga4/HZEiGa8SIdcPso/ VCdGejyWK5f2jPvWuq7vNh8gtCGjBdS9Qa8VrGq27sZqrP6wBKx2cHxXGswpu/NjDV XUL5Aml+wxOZuOQyf2/NA/XvOt6TJPdwKZDxQkACB+O6GlFuYLtGnP3HdpQPp5SRUT XLHcrVXLQxD6CVPevUf0oWCafdt0LwLKo1xU3jbkrhmLIyHRYSuQHJHm1oR2c81jmc m4Jy9WNn8uSmg== From: SeongJae Park To: xhao@linux.alibaba.com Cc: SeongJae Park , akpm@linux-foundation.org, corbet@lwn.net, skhan@linuxfoundation.org, rientjes@google.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 Date: Fri, 25 Feb 2022 08:05:13 +0000 Message-Id: <20220225080513.1908-1-sj@kernel.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 In-Reply-To: <1dbf6a7e-0805-bc44-ec4b-379405d619d1@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 X-Rspamd-Queue-Id: 5DAB01A000B X-Stat-Signature: m11c3nrpfgncsu3h7rtes9skhu1s1h75 Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SPkRrLaO; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1645776320-737350 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: Hi Xin, On Fri, 25 Feb 2022 15:32:47 +0800 xhao@linux.alibaba.com wrote: > Hi SeongJae: >=20 > On 2/23/22 11:20 PM, SeongJae Park wrote: [...] > > Introduction > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > DAMON's debugfs-based user interface (DAMON_DBGFS) served very well, = so far. > > However, it unnecessarily depends on debugfs, while DAMON is not aime= d to be > > used for only debugging. Also, the interface receives multiple value= s via one > > file. For example, schemes file receives 18 values. As a result, it= is > > inefficient, hard to be used, and difficult to be extended. Especial= ly, > > keeping backward compatibility of user space tools is getting only ch= allenging. > > It would be better to implement another reliable and flexible interfa= ce and > > deprecate DAMON_DBGFS in long term. > > > > For the reason, this patchset introduces a sysfs-based new user inter= face of > > DAMON. The idea of the new interface is, using directory hierarchies= and > > having one dedicated file for each value. For a short example, users= can do > > the virtual address monitoring via the interface as below: > > > > # 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 > > > > A brief representation of the files hierarchy of DAMON sysfs interfac= e is as > > below. Childs are represented with indentation, directories are havi= ng '/' > > suffix, and files in each directory are separated by comma. > > > > /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_att= rs/ > > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 inte= rvals/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_r= egions/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/pi= d > > =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 acce= ss_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 quot= as/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 wate= rmarks/metric,interval_us,high,mid,low > > =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 =E2=94=82 stat= s/nr_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 ... > > > > Detailed usage of the files will be described in the final Documentat= ion patch > > of this patchset. >=20 > The introduction of the sys DAMON interface makes DAMON seem more=20 > hierarchical, but it brings a problem. From a user's perspective, >=20 > I find it difficult to operate. For example: >=20 > step one: >=20 > echo xxx > /sys/kernel/mm/damon/admin/kdamonds/0/contexts/0/targets/nr >=20 > step two: >=20 > echo /sys/kernel/mm/damon/admin/kdamonds/0/contexts/0/targets/nr/1/pid >=20 > echo /sys/kernel/mm/damon/admin/kdamonds/0/contexts/0/targets/nr/0/pid >=20 > ......... >=20 > Alas, it is really too troublesome to operate, can you make it as simpl= e=20 > as possible, perhaps by referring to the implementation of cgroup. Thank you very much for the great comments. I agree that this interface requires quite a redundant works. Nevertheless, this interface is not ai= med to be used by human hand but user space tools. We provide the DAMON user-sp= ace tool, damo, for the purpose. Damo already supports this interface while introducing nearly-zero change to the end user interface. All you need t= o do to use sysfs in background with damo is adding '--damon_interface sysfs' = to the command. I guess someone might still want low level sysfs control for development = and testing purpose. For the case, damo is providing a new subcommand, fs[1]= , for more low level sysfs control with better interface. It allows users to read/write all hierarchies and values in DAMON sysfs via json format. Fo= r example: # ./damo/damo fs --damon_interface sysfs read { "kdamonds": { "0": { "contexts": { "nr_contexts": "0\n" }, "pid": "-1\n", "state": "off\n" }, "nr_kdamonds": "1\n" } } # cat content.json { "kdamonds": { "0": { "contexts": { "nr_contexts": "1\n" } } } } # ./damo/damo fs --damon_interface sysfs write --content "$(cat conte= nt.json)" # ./damo/damo fs --damon_interface sysfs read { "kdamonds": { "0": { "contexts": { "0": { "monitoring_attrs": { "intervals": { "aggr_us": "100000\n", "sample_us": "5000\n", "update_us": "60000000\n" }, "nr_regions": { "max": "1000\n", "min": "10\n" } }, "operations": "vaddr\n", "schemes": { "nr_schemes": "0\n" }, "targets": { "nr_targets": "0\n" } }, "nr_contexts": "1\n" }, "pid": "-1\n", "state": "off\n" }, "nr_kdamonds": "1\n" } } I admit damo interface is still not perfect. It has many rooms for improvement. If even damo is too heavyweight for you, you could use some general scrip= ts that can do above work in similar manner: https://github.com/sjp38/lazybox/blob/master/scripts/fs.py Thanks, SJ