Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp389017pxm; Fri, 25 Feb 2022 09:56:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoxNT0vBX7bD0HuJZYRJsQraFw3mWZcs/CXkIwy1PG6uzQmicPAjSt95Mw3yAu9JmRRUYv X-Received: by 2002:a17:90a:d314:b0:1bc:d942:2606 with SMTP id p20-20020a17090ad31400b001bcd9422606mr4250223pju.169.1645811781199; Fri, 25 Feb 2022 09:56:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645811781; cv=none; d=google.com; s=arc-20160816; b=I6RaQSJZTd7Rv9u9JUpbeuxKnYV5RhRH+eJsoqTkqOcyehY6XRKSjzBKhPXnlFEE1P B457RDlnsHYIf49OjEEDD7B0bOwJvOcdK9vuIkRhjoLm1MHm+ML/8hXaRJemVZwjpqJ/ zrI7iPy1juQLR2K9XS39i+zViWwJJ5ddbX7PbTzwlc3ss7vqKdT3oNEFSFj+W8Q5qDqq dxodlvMuRJucgdVZrmINx8cNz27cAMxbaAmv9ceXFmHIIipdRWrjZn4HqWtab5BoqhOR DpCjsRiFcOADFp3mgsx3uSPGmlxC3pkKyqFZ5O74OPCBA4sWTfs0xbbbAyl93fw4Aa/6 w2uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=xrFsopE0AsEAvzAdESbJ8XHHZTq/qwsdK3+eOGqm08A=; b=GZW47CxsBvU8KzoqdXbB2DyV/a1Iq3YtLDEf7IAx9nt0Y9QzcLyYDY0F84aPI7lLA1 +JHvBQpOzCS7DG8b4LNLt/z3R9cc3VBC9C4yPdVWCDEFOS291E7inFgLNvGPDTndPMxX cuIPYj30ZpKtFhESRIqAyDsuOs4fA94J8+pExV+7pigrrUrf77e5Xf/yutH7x3kfpf2l m5b/x3u4LA/g6Gduot7qsbXwVqzylr/a0wfdI6Pr7kVitaKlAw87bjB9Q+ybHnXm14kH rWAldB/oaoiwLnIrK7HqYvYKlJ+qlnI8rVbNOd6kGMS6SmSPyxIsdwyTU2HogDIVDy8p LwCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UAEdRQDp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r19-20020a63ec53000000b00363402e52d9si2505014pgj.511.2022.02.25.09.56.04; Fri, 25 Feb 2022 09:56:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UAEdRQDp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238390AbiBYILF (ORCPT + 99 others); Fri, 25 Feb 2022 03:11:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238383AbiBYILD (ORCPT ); Fri, 25 Feb 2022 03:11:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11C4882D1C; Fri, 25 Feb 2022 00:10:28 -0800 (PST) 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 A984F61BEF; Fri, 25 Feb 2022 08:10:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D13DC340E7; Fri, 25 Feb 2022 08:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645776627; bh=M4USnKyDoarCLAxcj1URQPBkgtFfHFlk4iSdKCZvhDU=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=UAEdRQDpfxyMq22KEHqXjb2MSXT45ERk5n65VvbAVYMpGvJF2emahbmmx8FCEcaWo IBZj1FH+v+jljfDybUB2oX/ziJbvr458jFZUU/LCHrJtVOEj55YFm4pOz3+qr40Td5 uVu28mVrlu9wkKlEb4dQb4mmvy6AIeO4SE7ukOOIrVKDgJ0hlemya2PJmdr58Es1G/ 8/PmuB9BY/fbAIB1lHpSLa1/sz3lFnU7sWIEAgCgptikkt2IJjQrn9sn2w+xsS2JWy XGrzsQG/ACQ3uwhDufUPV/+CQznIr4MdGjYLX/D9nCi+U6/UU1lfPWoRAid6ydhRzJ /TYBZFQERCYPw== 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 03/12] mm/damon: Implement a minimal stub for sysfs-based DAMON interface Date: Fri, 25 Feb 2022 08:10:24 +0000 Message-Id: <20220225081024.1979-1-sj@kernel.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 In-Reply-To: <66331451-48d8-6658-cdce-6e79df27ae5e@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Xin, On Fri, 25 Feb 2022 15:21:05 +0800 xhao@linux.alibaba.com wrote: > Hi, SeongJae: > > On 2/23/22 11:20 PM, SeongJae Park wrote: > > DAMON's debugfs-based user interface 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 separated by > > white spaces. As a result, it is ineffient, hard to be used, and > > difficult to be extended. Especially, keeping backward compatibility of > > user space tools is getting only challenging. It would be better to > > implement another reliable and flexible interface and deprecate the > > debugfs interface in long term. > > > > To this end, this commit implements a stub of a part of the new user > > interface of DAMON using sysfs. Specifically, this commit implements > > the sysfs control parts for virtual address space monitoring. > > > > More specifically, the idea of the new interface is, using directory > > hierarchies and making one file for one value. The hierarchy that this > > commit is introducing is as below. In the below figure, > > parents-children relations are represented with indentations, each > > directory is having ``/`` suffix, and files in each directory are > > separated by comma (","). > > > > /sys/kernel/mm/damon/admin > > │ kdamonds/nr > > │ │ 0/state,pid > > │ │ │ contexts/nr > > │ │ │ │ 0/operations > > │ │ │ │ │ monitoring_attrs/ > > │ │ │ │ │ │ intervals/sample_us,aggr_us,update_us > > │ │ │ │ │ │ nr_regions/min,max > > │ │ │ │ │ targets/nr > > │ │ │ │ │ │ 0/pid > > │ │ │ │ │ │ ... > > │ │ │ │ ... > > │ │ ... > > > > > Writing a number to each 'nr' file makes directories of name <0> to > > in the directory of the 'nr' file. That's all this commit does. > > Writing proper values to relevant files will construct the DAMON > > contexts, and writing a special keyword, 'on', to 'state' files for each > > kdamond will ask DAMON to start the constructed contexts. > > > > For a short example, using below commands for > > monitoring virtual address spaces of a given workload is imaginable: > > > > # cd /sys/kernel/mm/damon/admin/ > > # echo 1 > kdamonds/nr > > # echo 1 > kdamonds/0/contexts/nr > > # echo vaddr > kdamonds/0/contexts/0/damon_type > > # echo 1 > kdamonds/0/contexts/0/targets/nr > > # echo $(pidof ) > kdamonds/0/contexts/0/targets/0/pid > > # echo on > kdamonds/0/state > > I do some test about the sys interface, like this: > > [root@rt2k03395 0]# tree > . > ├── contexts > │ ├── 0 > │ │ ├── monitoring_attrs > │ │ │ ├── intervals > │ │ │ │ ├── aggr_us > │ │ │ │ ├── sample_us > │ │ │ │ └── update_us > │ │ │ └── nr_regions > │ │ │ ├── max > │ │ │ └── min > │ │ ├── operations > │ │ ├── schemes > │ │ │ └── nr > │ │ └── targets > │ │ ├── 0 > │ │ │ ├── pid > │ │ │ └── regions > │ │ │ ├── 0 > │ │ │ │ ├── end > │ │ │ │ └── start > │ │ │ ├── 1 > │ │ │ │ ├── end > │ │ │ │ └── start > │ │ │ ├── 10 > │ │ │ │ ├── end > │ │ │ │ └── start > │ │ │ ├── 11 > │ │ │ │ ├── end > │ │ │ │ └── start > │ │ │ ├── 12 > > cd regions/ > [root@rt2k03395 regions]# ls > 0 10 12 14 16 18 2 21 23 25 27 29 30 32 34 36 38 4 > 41 43 45 47 49 6 8 nr > 1 11 13 15 17 19 20 22 24 26 28 3 31 33 35 37 39 40 > 42 44 46 48 5 7 9 > [root@rt2k03395 regions]# cd 44/cat * > > [root@rt2k03395 regions/44]# cat * > 0 0 > > I'm skeptical about the number regions ? And after manually setting the > number of nr, the processing of > > "start" and "end" will be very troublesome,I guess you might want to do > some special region addresses, > > such as hot or cold region, Is that true ? The purpose of regions/ directory is for supporting the initial monitoring regions feature of debugfs, which is optional for virtual address spaces monitoring, but essential for physical address space monitoing. If you need to monitor only virtual address spaces, you don't need to populate the directory. In a future, we could add nr_accesses and age files under each region directory and apply the monitoring results there. > But I think you need to think > about how do you deal with too many > > uncontacted reigons that need to be done. Sysfs interface is not aimed to be used by human hand but user space tools, and we provide a reference tool, damo. Please consider using that or implement your own. You could also refer to my reply to your other email for this point: https://lore.kernel.org/linux-mm/20220225080513.1908-1-sj@kernel.org/ Thanks, SJ [...]