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=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 C5E00C433E0 for ; Tue, 2 Feb 2021 15:48:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E0EF64ECE for ; Tue, 2 Feb 2021 15:48:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235767AbhBBPsS (ORCPT ); Tue, 2 Feb 2021 10:48:18 -0500 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:3118 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235242AbhBBPqv (ORCPT ); Tue, 2 Feb 2021 10:46:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1612280810; x=1643816810; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=Id0o2WokyPHWrS8RD/cb5cRLc0A+ZuQ8G+JvdkxiJ/4=; b=cnuEaRbww26fhzmLJUO0VQq/MfR3SeJQ/a51/rjBm+GvYRWcTyxfncLY 1s5XR61jy4Qw7/vFlLZD7riOex8byYLDhLNzzFjKqAAvuqLuwsCQuuqSl tCSpnHMdU1ppQ3dTqYPk+lDsWQ5m2nAoRMCG44LAI62GHGvb/KBmZ9DYT 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) Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org 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