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=-9.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 94078C433E6 for ; Tue, 2 Feb 2021 15:46:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38A1764F64 for ; Tue, 2 Feb 2021 15:46:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38A1764F64 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 A6A236B0070; Tue, 2 Feb 2021 10:46:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A404E6B0071; Tue, 2 Feb 2021 10:46:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 957816B0072; Tue, 2 Feb 2021 10:46:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0164.hostedemail.com [216.40.44.164]) by kanga.kvack.org (Postfix) with ESMTP id 7E7676B0070 for ; Tue, 2 Feb 2021 10:46:10 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 472998249980 for ; Tue, 2 Feb 2021 15:46:10 +0000 (UTC) X-FDA: 77773754100.21.foot39_3b0b351275cc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 11D51180442C3 for ; Tue, 2 Feb 2021 15:46:10 +0000 (UTC) X-HE-Tag: foot39_3b0b351275cc X-Filterd-Recvd-Size: 6599 Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 15:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1612280770; x=1643816770; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=Id0o2WokyPHWrS8RD/cb5cRLc0A+ZuQ8G+JvdkxiJ/4=; b=WGYlodG2/PiOv01TeYTf+9pwDjWg4iVAXF5HVg0KnWh95b8mt8mtvXsZ 0wRIQH/ZKImmbiwmYG9I9lW6JcJp3//X7gdpd3JdyIF5+/kp6PHzNhW2W W1eXHYzsIl6FG0a9XaGZnjgj/DSNmU4d10qurVlDL7WqwG4TTyC+XvhrS c=; X-IronPort-AV: E=Sophos;i="5.79,395,1602547200"; d="scan'208";a="115209270" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1a-af6a10df.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 02 Feb 2021 15:45:49 +0000 Received: from EX13D31EUA001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-1a-af6a10df.us-east-1.amazon.com (Postfix) with ESMTPS id 9A41AA1F01; Tue, 2 Feb 2021 15:45:37 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.161.247) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 2 Feb 2021 15:45:20 +0000 From: SeongJae Park To: Shakeel Butt CC: SeongJae Park , Andrea Arcangeli , , , , , , Brendan Higgins , Qian Cai , Colin Ian King , Jonathan Corbet , "David Hildenbrand" , , Marco Elver , "Du, Fan" , , "Greg Thelen" , Ian Rogers , , "Kirill A. Shutemov" , Mark Rutland , Mel Gorman , Minchan Kim , Ingo Molnar , , "Peter Zijlstra (Intel)" , Randy Dunlap , Rik van Riel , David Rientjes , Steven Rostedt , Mike Rapoport , , Shuah Khan , , , Vlastimil Babka , Vladimir Davydov , Yang Shi , Huang Ying , , , Linux MM , , LKML Subject: RE: [PATCH v23 07/15] mm/damon: Implement a debugfs-based user space interface Date: Tue, 2 Feb 2021 16:45:06 +0100 Message-ID: <20210202154506.29682-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.161.247] X-ClientProxiedBy: EX13D46UWC001.ant.amazon.com (10.43.162.126) 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, 2 Feb 2021 07:07:24 -0800 Shakeel Butt wrote: > On Tue, Feb 2, 2021 at 2:30 AM SeongJae Park wrote: > > > >> On Mon, 1 Feb 2021 09:37:39 -0800 Shakeel Butt wrote: > >> > >>> On Tue, Dec 15, 2020 at 3:59 AM 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. > >>> > >>> Which kernel space APIs are being referred here? > >> > >> The symbols in 'include/linux/damon.h' > >> > >>> > >>>> 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_target_ids_write(struct file *file, > >>>> + const char __user *buf, size_t count, loff_t *ppos) > >>>> +{ > >>>> + struct damon_ctx *ctx = file->private_data; > >>>> + char *kbuf, *nrs; > >>>> + unsigned long *targets; > >>>> + ssize_t nr_targets; > >>>> + ssize_t ret = count; > >>>> + int i; > >>>> + int err; > >>>> + > >>>> + kbuf = user_input_str(buf, count, ppos); > >>>> + if (IS_ERR(kbuf)) > >>>> + return PTR_ERR(kbuf); > >>>> + > >>>> + nrs = kbuf; > >>>> + > >>>> + targets = str_to_target_ids(nrs, ret, &nr_targets); > >>>> + if (!targets) { > >>>> + ret = -ENOMEM; > >>>> + goto out; > >>>> + } > >>>> + > >>>> + if (targetid_is_pid(ctx)) { > >>>> + for (i = 0; i < nr_targets; i++) > >>>> + targets[i] = (unsigned long)find_get_pid( > >>>> + (int)targets[i]); > >>>> + } > >>>> + > >>>> + mutex_lock(&ctx->kdamond_lock); > >>>> + if (ctx->kdamond) { > >>>> + ret = -EINVAL; > >>>> + goto unlock_out; > >>> > >>> You need to put_pid on the targets array. > >> > >> Good catch! > >> > >>> > >>>> + } > >>>> + > >>>> + err = damon_set_targets(ctx, targets, nr_targets); > >>>> + if (err) > >>>> + ret = err; > >>> > >>> You need to handle the partial failure from damon_set_targets(). > >> > >> My intention is to keep partial success as is. > > > > But, we should put_pid() partial failures... I will simply make this to > > completely fail with no registered target. > > > > You can simplify by simply restricting to one pid/target per each write syscall. Right, thanks for the suggestion. However, I already almost finished writing the fix. If there is no other concern, I'd like to keep current interface. Thanks, SeongJae Park