Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4969351pxu; Thu, 10 Dec 2020 09:39:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSATrD+1wn+ZKDHJ56tfDnPl7r5ZAhI41zeF4Z9LOdG2x7vitoAZaNQkyg5djIvUvPxHu6 X-Received: by 2002:a50:d646:: with SMTP id c6mr7856137edj.177.1607621999434; Thu, 10 Dec 2020 09:39:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607621999; cv=none; d=google.com; s=arc-20160816; b=ly7DGFxM2cPW47ar06to42rJYtR9k6K2Kp6z5qUZye9ZDfOrXyuyYyqD9+f7uFiMQ8 Vpf9TTNL+CNnyrByn5b8bMqLMpm85qGS4daJ4Yx+7xfgWl8OW9vrA8QBOhw8ZQjZHnuW VjXHHlGn67V0/ihaX46W6E3T+Ie98kkDkm4Fuiqu2O2wXp18wHSRcJbO6WBIEXI8M8jA ww0oY/vg4zuMwwSSkHz2QxsyQzAusCWxyLWhkbdZhMiTps/hX0RR0k970Lo+yK8U6Ubo /2F/YxRn5c+IFRbo1FI3Rf2P40CjL4evPaF87P+8hATd606b6pz5IQOxvFPxKtq0xR4N UWlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=WV5ov9bFxC093Bg0wQRJM6PY8uFJ30B1zUMScDd3ANs=; b=HAgIa+t5Z3M1lp577nQbpDzmdzt0+XcWrHTT0WOsrnhvyD1uD0wdXM2f5VWgGTsqun vCUmvddHVROLs3/lrBH7cwPi2d4CP5xc57FrQIrzTPSsYqvVgiLXPzBnJa9PWn9oBiLL gOg6OVq3KC/8iDKmixAroViv1DEmUKqnI94s8SiUQZVtOEN5GK+Hv2dwQU62XVw34gHf uivgH6HrVrFFKuMkFfXfdrRuA/F4DM8aUzomN4X6MjI+js+ii/Nl1TouiDAauVb0LYix XLJU02XU8DNKTgQnDA640EPXF5MQWvBObDf7MZ4s2D3d9cf7uVt3lilHvamCQDvZUIzs d2Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VNEz78OH; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gr1si2958479ejb.742.2020.12.10.09.39.35; Thu, 10 Dec 2020 09:39:59 -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=@kernel.org header.s=k20201202 header.b=VNEz78OH; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404109AbgLJRPr (ORCPT + 99 others); Thu, 10 Dec 2020 12:15:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:49646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392706AbgLJRPe (ORCPT ); Thu, 10 Dec 2020 12:15:34 -0500 Date: Thu, 10 Dec 2020 14:15:03 -0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607620493; bh=2S1yzn1LvueIMmhCg3+RBjk+1uwi+KxA+4jgKLSnIxE=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=VNEz78OHUZijXeF9SiPHSyOd249IHtspdSyid3L17++UaePtTCwpixS4XZ/zymiJO 4PLzs12TvJqdiN7h0RLOX0MLPHYssWMvh2KIYJsFSGP/aqpV81oRVcxiM2Y92YeOGh FOcIo00R6qkYQvnNiTikt8LSEFXgpFODGXnD4GowyrdUVBXIDuFBNPBpqLdDpjnRjx dQT6qTkdTuswqbAWRfPLCX2YEoRwsTyNa/S3o5Cipm773jLTwnyltH5n97FjbyAUKh Mmql7t15tHzNh96MEt3U3WHz3IcFUw/GPRDMwae9qe0xZFyY1qlASYdYXiM+Mhzzi1 N1fw+tpf8EAOg== From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Alexei Budankov , Jiri Olsa , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Ian Rogers , Stephane Eranian Subject: Re: [PATCH 2/3] perf tools: Allow to enable/disable events via control file Message-ID: <20201210171503.GA195565@kernel.org> References: <20201206170519.4010606-1-jolsa@kernel.org> <20201206170519.4010606-3-jolsa@kernel.org> <7bcde520-e933-c2d6-c960-3f8acdaf6047@huawei.com> <20201210162430.GH69683@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201210162430.GH69683@krava> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Dec 10, 2020 at 05:24:30PM +0100, Jiri Olsa escreveu: > On Mon, Dec 07, 2020 at 08:02:20PM +0300, Alexei Budankov wrote: > > Hi, > > > > On 06.12.2020 20:05, Jiri Olsa wrote: > > > Adding new control events to enable/disable specific event. > > > The interface string for control file are: > > > > > > 'enable-' > > > 'disable-' > > > > > > > > > > > > when received the command, perf will scan the current evlist > > > for and if found it's enabled/disabled. > > > > > > > > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > > > index 70aff26612a9..05723227bebf 100644 > > > --- a/tools/perf/util/evlist.c > > > +++ b/tools/perf/util/evlist.c > > > @@ -1915,7 +1915,13 @@ static int evlist__ctlfd_recv(struct evlist *evlist, enum evlist_ctl_cmd *cmd, > > > bytes_read == data_size ? "" : c == '\n' ? "\\n" : "\\0"); > > > > > > if (bytes_read > 0) { > > > - if (!strncmp(cmd_data, EVLIST_CTL_CMD_ENABLE_TAG, > > > + if (!strncmp(cmd_data, EVLIST_CTL_CMD_ENABLE_EVSEL_TAG, > > > + (sizeof(EVLIST_CTL_CMD_ENABLE_EVSEL_TAG)-1))) { > > > + *cmd = EVLIST_CTL_CMD_ENABLE_EVSEL; > > > + } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_DISABLE_EVSEL_TAG, > > > + (sizeof(EVLIST_CTL_CMD_DISABLE_EVSEL_TAG)-1))) { > > > + *cmd = EVLIST_CTL_CMD_DISABLE_EVSEL; > > > + } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_ENABLE_TAG, > > > (sizeof(EVLIST_CTL_CMD_ENABLE_TAG)-1))) { > > > *cmd = EVLIST_CTL_CMD_ENABLE; > > > } else if (!strncmp(cmd_data, EVLIST_CTL_CMD_DISABLE_TAG, > > > @@ -1952,6 +1958,8 @@ int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd) > > > char cmd_data[EVLIST_CTL_CMD_MAX_LEN]; > > > int ctlfd_pos = evlist->ctl_fd.pos; > > > struct pollfd *entries = evlist->core.pollfd.entries; > > > + struct evsel *evsel; > > > + char *evsel_name; > > > > > > if (!evlist__ctlfd_initialized(evlist) || !entries[ctlfd_pos].revents) > > > return 0; > > > @@ -1967,6 +1975,26 @@ int evlist__ctlfd_process(struct evlist *evlist, enum evlist_ctl_cmd *cmd) > > > case EVLIST_CTL_CMD_DISABLE: > > > evlist__disable(evlist); > > > break; > > > + case EVLIST_CTL_CMD_ENABLE_EVSEL: > > > + evsel_name = cmd_data + sizeof(EVLIST_CTL_CMD_ENABLE_EVSEL_TAG) - 1; > > > > It makes sense to check that evsel_name still points > > into cmd_data buffer after assigning to event name. > > right, will add that So, I'm finishing test builds, so probably I'll push the first two patches publicly and then you can send a patch on top of this, ok? Unless the tests break somewhere and then I'll have to restart, so I'll fold in whatever gets at that time... - Arnaldo