Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2339796pxb; Fri, 5 Feb 2021 15:40:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwi294YfXWvx65biYwl6ckmUmr24faWA7cscKkwNtKo6hHH2jMB+A/qToTzz6cgwgYVKbk X-Received: by 2002:aa7:c98e:: with SMTP id c14mr2463703edt.213.1612568404791; Fri, 05 Feb 2021 15:40:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612568404; cv=none; d=google.com; s=arc-20160816; b=VnCGtiO6OirbX7UPZ0SzMU7bEBpcuug68OoMhPOwRaoMcMnqQ4JzsAkEfI+Aq2ey1t uw3wWwsRiq1FzQuuy1cuqUip9smAog48c/WzkDb62UDqgS1d1NDXVxgzAKWLlpxARdJ4 uHwPBjPmBsrFI4MzsBJA4nFO/lS0dTnZb+U19yNdMSQ8F2taxUpaHrtRV91SM7RIs7Ih gEe1jvqai+HB9VNPduGHU2ElFsxMKLLIxQgLML1leW0p8qg/A9uM5cFDIwwYDVfCrTp1 P1t20unDDcRzPzzeY1mldBOg1Ud8K0ONrYNLFnGREquAzgebE2/2RMdF5D5Kin7hV0Sq /jlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=TBohInsGRwLMOnqJDl8Pqhxj7U/fXFbfpMKPhnZcUFw=; b=GCE8EaPVE+6zahdEsV5KSuGuuLNiF/618gkP+oJVHaMu0Be/BGUikqyPfikadiMqoP 0UrrrXwlog6BZuChlSvpB9H3ueDZLHrlWpAIghJoEoSc9xLlcVu9DVKrV2Rl4kHfWmh5 JdHGt1SCqQ3Mg1NPtjXFN8PZq3im5gIJX5J3tZB63QTYHVvIACK1vQasu7vXLu8f4hfv RRfp0KfbBDMO5vljo5Xw5zO0UCh0M6+3kQss5+pJQ4FaSc/lEeZVRfy91qCFSKPFU8pg iCfH9wmvq0qVhRDadkPNeHis/QafiofDUUaGZBuezaFhXXJaznLEJRIcNBSpKnFn4FMA 3qCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=jgYImARJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t15si6120290ejj.506.2021.02.05.15.39.39; Fri, 05 Feb 2021 15:40:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=jgYImARJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230518AbhBEXfo (ORCPT + 99 others); Fri, 5 Feb 2021 18:35:44 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:24639 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232066AbhBEOVn (ORCPT ); Fri, 5 Feb 2021 09:21:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1612540829; x=1644076829; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=TBohInsGRwLMOnqJDl8Pqhxj7U/fXFbfpMKPhnZcUFw=; b=jgYImARJD6qkBQV5QsAiU36i737f/WHvRPDZ28run0cIE4FTZ8ks4Jn8 GyOSqHmIGskwEXAHpLVo3laroKOZolM7mIV/Fcrpf5bUZzk7nuh93Bojd YT2CYWqYhsU+6iqwlVGmn8eK14yOvhhs7DyE8hGq1ttOyjvQH9Q7XOrd0 I=; 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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