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=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 AA021C433E0 for ; Fri, 5 Feb 2021 15:59:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1033F650D8 for ; Fri, 5 Feb 2021 15:59:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1033F650D8 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 72E126B0071; Fri, 5 Feb 2021 10:59:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B78B6B007D; Fri, 5 Feb 2021 10:59:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57FEE6B007E; Fri, 5 Feb 2021 10:59:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0146.hostedemail.com [216.40.44.146]) by kanga.kvack.org (Postfix) with ESMTP id 3E6E06B0071 for ; Fri, 5 Feb 2021 10:59:49 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 08EF72470 for ; Fri, 5 Feb 2021 15:59:49 +0000 (UTC) X-FDA: 77784674898.23.moon45_560ad65275e6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id DFB0837608 for ; Fri, 5 Feb 2021 15:59:48 +0000 (UTC) X-HE-Tag: moon45_560ad65275e6 X-Filterd-Recvd-Size: 6206 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Feb 2021 15:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1612540789; x=1644076789; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=TBohInsGRwLMOnqJDl8Pqhxj7U/fXFbfpMKPhnZcUFw=; b=qSgEm1cvbiwUWiBUbg0WJHh674Xi3XfFAs/3dWJas+eZYW+wirU40e4N yM6MANqZbjvAUxTsey+HEUCG8NbvnBxO/j7n/S0TpeJqf4tW8rMJ2bV3+ h3ktbySO8Zmkdpt8eQ8x0FgTUy/Pp4X9HJHkjAvOekETxF4PtHYT9sHmO c=; X-IronPort-AV: E=Sophos;i="5.81,155,1610409600"; d="scan'208";a="82731861" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2b-81e76b79.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 05 Feb 2021 15:59:38 +0000 Received: from EX13D31EUA001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2b-81e76b79.us-west-2.amazon.com (Postfix) with ESMTPS id 0A050A1D83; Fri, 5 Feb 2021 15:59:34 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.162.194) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 5 Feb 2021 15:59:17 +0000 From: SeongJae Park To: Greg KH CC: SeongJae Park , SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v24 07/14] mm/damon: Implement a debugfs-based user space interface Date: Fri, 5 Feb 2021 16:59:02 +0100 Message-ID: <20210205155902.31102-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.194] X-ClientProxiedBy: EX13D11UWB002.ant.amazon.com (10.43.161.20) 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 Fri, 5 Feb 2021 16:29:41 +0100 Greg KH wrote: > On Thu, Feb 04, 2021 at 04:31:43PM +0100, SeongJae Park wrote: > > From: SeongJae Park > > > > DAMON is designed to be used by kernel space code such as the memory > > management subsystems, and therefore it provides only kernel space API. > > That said, letting the user space control DAMON could provide some > > benefits to them. For example, it will allow user space to analyze > > their specific workloads and make their own special optimizations. > > > > For such cases, this commit implements a simple DAMON application kernel > > module, namely 'damon-dbgfs', which merely wraps the DAMON api and > > exports those to the user space via the debugfs. > > > > 'damon-dbgfs' exports three files, ``attrs``, ``target_ids``, and > > ``monitor_on`` under its debugfs directory, ``/damon/``. [...] > > --- > > include/linux/damon.h | 3 + > > mm/damon/Kconfig | 9 + > > mm/damon/Makefile | 1 + > > mm/damon/core.c | 47 +++++ > > mm/damon/dbgfs.c | 387 ++++++++++++++++++++++++++++++++++++++++++ > > 5 files changed, 447 insertions(+) > > create mode 100644 mm/damon/dbgfs.c [...] > > diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c > > new file mode 100644 > > index 000000000000..db15380737d1 > > --- /dev/null > > +++ b/mm/damon/dbgfs.c [...] > > + > > +static int dbgfs_fill_ctx_dir(struct dentry *dir, struct damon_ctx *ctx) > > +{ > > + const char * const file_names[] = {"attrs", "target_ids"}; > > + const struct file_operations *fops[] = {&attrs_fops, &target_ids_fops}; > > + int i; > > + > > + for (i = 0; i < ARRAY_SIZE(file_names); i++) { > > + if (!debugfs_create_file(file_names[i], 0600, dir, > > + ctx, fops[i])) { > > + pr_err("failed to create %s file\n", file_names[i]); > > + return -ENOMEM; > > No need to check the return value of this function, just keep going and > ignore it as there's nothing to do and kernel code should not do > different things based on the output of any debugfs calls. > > Also, this check is totally wrong and doesn't do what you think it is > doing... Ok, I will drop the check. > > > +static int __init __damon_dbgfs_init(void) > > +{ > > + struct dentry *dbgfs_root; > > + const char * const file_names[] = {"monitor_on"}; > > + const struct file_operations *fops[] = {&monitor_on_fops}; > > + int i; > > + > > + dbgfs_root = debugfs_create_dir("damon", NULL); > > + if (IS_ERR(dbgfs_root)) { > > + pr_err("failed to create the dbgfs dir\n"); > > + return PTR_ERR(dbgfs_root); > > Again, no need to check anything, just pass the result of a debugfs call > back into another one just fine. Ok. > > > + } > > + > > + for (i = 0; i < ARRAY_SIZE(file_names); i++) { > > + if (!debugfs_create_file(file_names[i], 0600, dbgfs_root, > > + NULL, fops[i])) { > > Again, this isn't checking what you think it is, so please don't do it. Got it. I will fix those as you suggested in the next version. Thanks, SeongJae Park > > thanks, > > greg k-h