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=-11.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 9528EC43457 for ; Thu, 15 Oct 2020 15:23:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F0A6D2226B for ; Thu, 15 Oct 2020 15:23:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="EVzLyoij" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0A6D2226B 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 310BE940007; Thu, 15 Oct 2020 11:23:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E862900002; Thu, 15 Oct 2020 11:23:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FCA8940007; Thu, 15 Oct 2020 11:23:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0084.hostedemail.com [216.40.44.84]) by kanga.kvack.org (Postfix) with ESMTP id EA2A2900002 for ; Thu, 15 Oct 2020 11:23:15 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 748BC362B for ; Thu, 15 Oct 2020 15:23:15 +0000 (UTC) X-FDA: 77374528350.29.fifth21_610096427215 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 52FA518086CD4 for ; Thu, 15 Oct 2020 15:23:15 +0000 (UTC) X-HE-Tag: fifth21_610096427215 X-Filterd-Recvd-Size: 4710 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Thu, 15 Oct 2020 15:23: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=1602775395; x=1634311395; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=N7Pt2vWfkL2KgMmp7j77tD/M3NxUitM8f78mdFyOf0g=; b=EVzLyoijSrRcheK3YvJzn4mChypeBmgTVNVlbyPpc/Fw9YDVZnvUZxyN WGwDRE8tX97/p7ByJgRS9GDFw+gR1jzQQU67SPwy/gpuz8pCCZbsUpN8H hYd/aZ98dd1pGL3FfLBLWwWC2ZzbtU+q4PGocY9cbbOzzLSYaDu8TMMGV Y=; X-IronPort-AV: E=Sophos;i="5.77,379,1596499200"; d="scan'208";a="59534766" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 15 Oct 2020 15:23:12 +0000 Received: from EX13D31EUB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-1a-7d76a15f.us-east-1.amazon.com (Postfix) with ESMTPS id 4EA9CA250B; Thu, 15 Oct 2020 15:22:59 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.160.67) by EX13D31EUB001.ant.amazon.com (10.43.166.210) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 15 Oct 2020 15:22:41 +0000 From: SeongJae Park To: SeongJae Park CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v21 10/18] mm/damon: Implement a debugfs-based user space interface Date: Thu, 15 Oct 2020 17:22:26 +0200 Message-ID: <20201015152226.7106-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201005105522.23841-11-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.67] X-ClientProxiedBy: EX13P01UWB003.ant.amazon.com (10.43.161.209) To EX13D31EUB001.ant.amazon.com (10.43.166.210) 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 Mon, 5 Oct 2020 12:55:14 +0200 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. [...] > + > +static ssize_t dbgfs_monitor_on_write(struct file *file, > + const char __user *buf, size_t count, loff_t *ppos) > +{ > + ssize_t ret = count; > + char *kbuf; > + int err; > + > + kbuf = user_input_str(buf, count, ppos); > + if (IS_ERR(kbuf)) > + return PTR_ERR(kbuf); > + > + /* Remove white space */ > + if (sscanf(kbuf, "%s", kbuf) != 1) > + return -EINVAL; > + if (!strncmp(kbuf, "on", count)) > + err = dbgfs_start_ctxs(dbgfs_ctxs, dbgfs_nr_ctxs); > + else if (!strncmp(kbuf, "off", count)) > + err = damon_stop(dbgfs_ctxs, dbgfs_nr_ctxs); > + else > + return -EINVAL; > + > + if (err) > + ret = err; > + return ret; 'kbuf' should be freed before returning from this function. I will fix it in the next version. To find more potential memory leaks, I ran 'kmemleak' after a set of correctness tests[1], but it didn't find more leaks. [1] https://github.com/awslabs/damon-tests/tree/master/corr Thanks, SeongJae Park