Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp661039pxb; Tue, 2 Feb 2021 14:43:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyo9pj7/13OPSw466DxAmdwPdRdaGIPVQHDptiFRwdtzvOFvGrrTPyG/32KGrEgc3aio7qP X-Received: by 2002:a17:906:1a0c:: with SMTP id i12mr228686ejf.276.1612305830512; Tue, 02 Feb 2021 14:43:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612305830; cv=none; d=google.com; s=arc-20160816; b=vJiSMeQA8lV4jESznOV0JDsERYgTBnl7WWFlbK+IMH8VqetFtbDxl1Ti7rNtQvhtHD kgnPv9LaDZTHiefCPepl3FUyNmvR6DULtutZ4D0OkRrzCmfK6n7imw8ir7CouDIzaoZF Ux54GzOQ6M6LMt+GAUuyqcTQIAsS8ditAns4cqRVSFIv4t6EAgDCqsXCWYcJwN8TD6yn /k3Y51t0aL9aUZq7SQ+868PyLeT9oz8+PrADsrqLs3WtsG+NgiGgdQiMNH7ULKJtUI9Z UMCLd00SZmu47g4Ya8YR+e0cKWrn8jrAIVCb4slSkp9iL9xpXnjrNEiIePoVt3KZuFfX 5Vlw== 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=Id0o2WokyPHWrS8RD/cb5cRLc0A+ZuQ8G+JvdkxiJ/4=; b=UviRa7bNO3PQkb3hOoiSULdBumwXvN4AslVtlb42GhiaIGn4/7h99SYzsG39exhN/2 A68UwRtUDAYE8SAgppR12kRrBpSOe2vRPS0iu3PRrHXetBkL2AboejmpP/uagQxRi9Qf BUuOykUFgjyCAvAiQXxp2Pjqyy0b92+QLbClsU+Fw44aXt+xlwqEr+43KAfdGuVM4O66 jivpy6aQzs30Bq1Sjup+jclrPzXT7fBoSRgitfSV4l9Pb0lKEXiMYtfQCHBXHwiDNONq iBkwMhAbl20j1iucaghF7CEujkkhcpZYruO/AkCInzmimPmNH0O2GqhMESdXMGOo5ZqL 92+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=cnuEaRbw; 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 fx25si149408ejb.58.2021.02.02.14.43.25; Tue, 02 Feb 2021 14:43:50 -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=cnuEaRbw; 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 S235655AbhBBPs3 (ORCPT + 99 others); Tue, 2 Feb 2021 10:48:29 -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-kernel@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