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 X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90F4AC433E0 for ; Tue, 2 Feb 2021 12:28:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC90064F45 for ; Tue, 2 Feb 2021 12:28:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC90064F45 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 635096B0071; Tue, 2 Feb 2021 07:28:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E3116B0072; Tue, 2 Feb 2021 07:28:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 485206B0073; Tue, 2 Feb 2021 07:28:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0141.hostedemail.com [216.40.44.141]) by kanga.kvack.org (Postfix) with ESMTP id 2EAF06B0071 for ; Tue, 2 Feb 2021 07:28:16 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DB94A3633 for ; Tue, 2 Feb 2021 12:28:15 +0000 (UTC) X-FDA: 77773255350.09.box99_46151c5275ca Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id C222B180AD817 for ; Tue, 2 Feb 2021 12:28:15 +0000 (UTC) X-HE-Tag: box99_46151c5275ca X-Filterd-Recvd-Size: 6280 Received: from smtp-fw-9101.amazon.com (smtp-fw-9101.amazon.com [207.171.184.25]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 12:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1612268895; x=1643804895; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=tPW+WSGCYnSNEPfsJLIzZMQfqRKCnJMi8qp6on18UiQ=; b=cXyibWXZ3AcXPrb+iUVqLpXF+S0t+mF/0pcfl1np4jbYbt6o7qNp5y0k rwE4xpdlOkY0r1DO4e1cJiF4nV+WO9XVaU0cxH9c0fWiC+wIbLZ36z8Fp 3XTPOi8WRjDbg8dkilUxjDA0K6429yc/ZayfvBUMiZISgVpmFWY7arPwG U=; X-IronPort-AV: E=Sophos;i="5.79,394,1602547200"; d="scan'208";a="108086815" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2c-456ef9c9.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 02 Feb 2021 12:28:07 +0000 Received: from EX13D31EUA001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2c-456ef9c9.us-west-2.amazon.com (Postfix) with ESMTPS id 0BF0AAECFE; Tue, 2 Feb 2021 12:28:04 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.162.208) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 2 Feb 2021 12:27:48 +0000 From: SeongJae Park To: SeongJae Park CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v23 10/15] mm/damon/dbgfs: Support multiple contexts Date: Tue, 2 Feb 2021 13:27:34 +0100 Message-ID: <20210202122734.15627-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201215115448.25633-11-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.208] X-ClientProxiedBy: EX13D06UWA004.ant.amazon.com (10.43.160.164) To EX13D31EUA001.ant.amazon.com (10.43.165.15) 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 Tue, 15 Dec 2020 12:54:43 +0100 SeongJae Park wrote: > From: SeongJae Park > > In some use cases, users would want to run multiple monitoring context. > For example, if a user wants a high precision monitoring and dedicating > multiple CPUs for the job is ok, because DAMON creates one monitoring > thread per one context, the user can split the monitoring target regions > into multiple small regions and create one context for each region. Or, > someone might want to simultaneously monitor different address spaces, > e.g., both virtual address space and physical address space. > > The DAMON's API allows such usage, but 'damon-dbgfs' does not. > Therefore, only kernel space DAMON users can do multiple contexts > monitoring. > > This commit allows the user space DAMON users to use multiple contexts > monitoring by introducing two new 'damon-dbgfs' debugfs files, > 'mk_context' and 'rm_context'. Users can create a new monitoring > context by writing the desired name of the new context to 'mk_context'. > Then, a new directory with the name and having the files for setting of > the context ('attrs', 'target_ids' and 'record') will be created under > the debugfs directory. Writing the name of the context to remove to > 'rm_context' will remove the related context and directory. > > Signed-off-by: SeongJae Park > --- > mm/damon/dbgfs.c | 213 ++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 211 insertions(+), 2 deletions(-) > > diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c > index a1512d3e5afe..46186b057e1a 100644 > --- a/mm/damon/dbgfs.c > +++ b/mm/damon/dbgfs.c [...] > +/* > + * Remove a context of @name and its debugfs directory. > + * > + * This function should be called while holding damon_dbgfs_lock. > + * > + * Return 0 on success, negative error code otherwise. > + */ > +static int dbgfs_rm_context(char *name) > +{ > + struct dentry *root, *dir, **new_dirs; > + struct damon_ctx **new_ctxs; > + int i, j; > + > + if (damon_nr_running_ctxs()) > + return -EBUSY; > + > + root = dbgfs_dirs[0]; > + if (!root) > + return -ENOENT; > + > + dir = debugfs_lookup(name, root); > + if (!dir) > + return -ENOENT; > + > + new_dirs = kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_dirs), > + GFP_KERNEL); > + if (!new_dirs) > + return -ENOMEM; > + > + new_ctxs = kmalloc_array(dbgfs_nr_ctxs - 1, sizeof(*dbgfs_ctxs), > + GFP_KERNEL); > + if (!new_ctxs) { > + kfree(new_dirs); > + return -ENOMEM; > + } > + > + for (i = 0, j = 0; i < dbgfs_nr_ctxs; i++) { > + if (dbgfs_dirs[i] == dir) { > + debugfs_remove(dbgfs_dirs[i]); > + dbgfs_destroy_ctx(dbgfs_ctxs[i]); In case of virtual address monitoring, dbgfs_destroy_ctx() calls damon_destroy_ctx() and damon_destroy_ctx() doesn't put the target pids. I will fix this in the next version. > + continue; > + } > + new_dirs[j] = dbgfs_dirs[i]; > + new_ctxs[j++] = dbgfs_ctxs[i]; > + } > + > + kfree(dbgfs_dirs); > + kfree(dbgfs_ctxs); > + > + dbgfs_dirs = new_dirs; > + dbgfs_ctxs = new_ctxs; > + dbgfs_nr_ctxs--; > + > + return 0; > +} Thanks, SeongJae Park [...]