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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 AC122C433E0 for ; Tue, 2 Feb 2021 15:07:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 52AD064FA9 for ; Tue, 2 Feb 2021 15:07:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52AD064FA9 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CCAF66B006C; Tue, 2 Feb 2021 10:07:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C542F6B0071; Tue, 2 Feb 2021 10:07:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B435C6B0072; Tue, 2 Feb 2021 10:07:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id 9E74F6B006C for ; Tue, 2 Feb 2021 10:07:42 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4026D1EF1 for ; Tue, 2 Feb 2021 15:07:42 +0000 (UTC) X-FDA: 77773657164.14.boy34_0f102c4275cb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 81150182299A8 for ; Tue, 2 Feb 2021 15:07:40 +0000 (UTC) X-HE-Tag: boy34_0f102c4275cb X-Filterd-Recvd-Size: 6854 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 15:07:37 +0000 (UTC) Received: by mail-io1-f42.google.com with SMTP id y19so21628001iov.2 for ; Tue, 02 Feb 2021 07:07:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qSaBqeixyLoPS7VQTztlKi6qFU0Qbrugp50S56jr5mo=; b=qo7wdufOKgjOWexMGi1hjFJluj4S5JVNPRIcPOazUZET4YgNCdnnmfjDt7rOD69L9r Ah24o+deXPTmY5JRsgorml/Jj2mGs5Pl09/VAA8d7gurp3QJra6Vm7WTiAAZY5HyRsvt 2TdIWnUF3/ppKAP1XrMqSMl/IFmUiLgl2wT+Yd3b+TEVHoL+eNWr36VbaSDeTO99HSu1 7NSLf8Eo0A237Bne/JYdDAYiLAFNjwQTY7iWjqVbwmlEyjXVCJWp+EpXKDRkSdSy5LoE wqziZLeuJQx0gU9WXfBCqQjBKGyStmWHUzy2yQfB+SIfx8YxhjIEJsqVikiCGgDy8EF0 oUuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qSaBqeixyLoPS7VQTztlKi6qFU0Qbrugp50S56jr5mo=; b=XVaWOh68MY6OFJDWriSiIFTEbgAeUhlcK0V6QuOqdyTkyagUD/j1No3ogy39oj+BKR i1s623gLDmUDy7nBHTMX4Bk8rD3FUdrfnv6ehIPUuQTqIfixX627CyRK1HwxGfQjBzqp AVfBZ4vP3ADQOrj5XHhC+hSAwxoyS/RxD0u5lp1Ddi3VJE3wtORFJChJote0boMJwiZ0 L+vUn1CnKXdBAoA1IV4GKaK18tcIvaY6lxxgul+g7/zgcwIcZ6rVy1NE3d4j8rQPbCXd rKgn1ftJCZgJx6YJIy1ZDze6d5NctQvFR3qmXPXxeaUB3V95PPy/tDS133eO3beFdySK tf+g== X-Gm-Message-State: AOAM533xEdI56wdK9zhpR6IVSBb0OVR773w8N31XQAcrr8IQLEsfMYTv FvEewgLpfXbktxP5iCcyHMtu58PHik/qs+FthWhVbA== X-Google-Smtp-Source: ABdhPJzhMHWkMiRs3WM2ZLtw7rZyrwv1+Nw+UECr04uEP4/xVmh16Q9NhYcR2ZjVysW2tfQfvmsGva3x81dUDGR1PGY= X-Received: by 2002:a5e:de04:: with SMTP id e4mr6413370iok.122.1612278456264; Tue, 02 Feb 2021 07:07:36 -0800 (PST) MIME-Version: 1.0 References: <20210202102915.19902-1-sjpark@amazon.com> In-Reply-To: <20210202102915.19902-1-sjpark@amazon.com> From: Shakeel Butt Date: Tue, 2 Feb 2021 07:07:24 -0800 Message-ID: Subject: Re: [PATCH v23 07/15] mm/damon: Implement a debugfs-based user space interface To: SeongJae Park Cc: Jonathan.Cameron@huawei.com, Andrea Arcangeli , acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, benh@kernel.crashing.org, brendan.d.gregg@gmail.com, Brendan Higgins , Qian Cai , Colin Ian King , Jonathan Corbet , David Hildenbrand , dwmw@amazon.com, Marco Elver , "Du, Fan" , foersleo@amazon.de, Greg Thelen , Ian Rogers , jolsa@redhat.com, "Kirill A. Shutemov" , Mark Rutland , Mel Gorman , Minchan Kim , Ingo Molnar , namhyung@kernel.org, "Peter Zijlstra (Intel)" , Randy Dunlap , Rik van Riel , David Rientjes , Steven Rostedt , Mike Rapoport , sblbir@amazon.com, Shuah Khan , sj38.park@gmail.com, snu@amazon.de, Vlastimil Babka , Vladimir Davydov , Yang Shi , Huang Ying , zgf574564920@gmail.com, linux-damon@amazon.com, Linux MM , linux-doc@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" 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, 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.