Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2542016pxu; Mon, 7 Dec 2020 09:07:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMTUVQoA86mrtv3cVMGiIH+3ygCI8dnKXcKbS1Nx+OCq3YRzFXzmYzpyahnI6Qzl/MzZtk X-Received: by 2002:a50:fe0e:: with SMTP id f14mr21346441edt.159.1607360837551; Mon, 07 Dec 2020 09:07:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607360837; cv=none; d=google.com; s=arc-20160816; b=xhlcWRouYc0Rv4sE+hs+bY6C19GCJUGzInOJilIwQDbBgH6VTuHgklH+ztsIElhDYL 4DKsqPyjpCJifHwd4xIvVeJnqpxBXmkBbldsbqQWtbuM76Ozhp0nZ+2uSGzzXPUWkdHL mVGsrV04p63nlbBidx8tktdtpQykF6Wv7eS0Hie4kNbfyNfJS5Mw69pLA74b1Cd0RK9q wfhiuoaQTW0QjfAlJLCTOoxSQDd7ShdMhN9+nIAXg0yr/9rEGUi8C+dwp2DeeQrJzo+B 7u6tdulGBLL3XhAMZEWrQ1Snqegle3ux6gM26oQgnuR9kqdqrUt55EBFZH91GatkZXFu 4isg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Iq7L3cMWN/tN2g8AJM340gjao2ceuIr18JkiEnHTYZ0=; b=EVmaN1y3UgUN/ViFlC/d6OEMlI+uVPCxhdYJYpBl55Hz36UrrtcYAvQKyxHU+sg8KY AdraBb9lKJeli+jnfK1bF2Sk/zb7YMn1iPBgOUfpDh7KQPs/K0HDb06yHsEa4Jbso/yD xIHTHReLBjDvcvenLQlzhm4SPXhq6hmEBK3zEn6mEwr/CcbyGYBz5LhyMGwrcPGlY8SB +iryYMuj3+GW0skrhIvf+r9cfzR+PmSNJYaBBaVve558LAOfaS50TpgFvcWc699qOzOx 7/oXVLw/VAKvVbtRptWPpt2/JcjWNkZKRlW0FuMAIc/yk/6pRoWk8r2fqSALe9i5M2sv pSeg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x5si8444630edv.585.2020.12.07.09.06.52; Mon, 07 Dec 2020 09:07:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727836AbgLGRDP (ORCPT + 99 others); Mon, 7 Dec 2020 12:03:15 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2214 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726408AbgLGRDO (ORCPT ); Mon, 7 Dec 2020 12:03:14 -0500 Received: from fraeml734-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4CqV0v0pSyz67MMK; Tue, 8 Dec 2020 00:59:59 +0800 (CST) Received: from lhreml741-chm.china.huawei.com (10.201.108.191) by fraeml734-chm.china.huawei.com (10.206.15.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 7 Dec 2020 18:02:31 +0100 Received: from [10.47.199.254] (10.47.199.254) by lhreml741-chm.china.huawei.com (10.201.108.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 7 Dec 2020 17:02:25 +0000 Subject: Re: [PATCH 2/3] perf tools: Allow to enable/disable events via control file To: Jiri Olsa , Arnaldo Carvalho de Melo CC: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , "Alexander Shishkin" , Michael Petlan , Ian Rogers , Stephane Eranian References: <20201206170519.4010606-1-jolsa@kernel.org> <20201206170519.4010606-3-jolsa@kernel.org> From: Alexei Budankov Message-ID: <7bcde520-e933-c2d6-c960-3f8acdaf6047@huawei.com> Date: Mon, 7 Dec 2020 20:02:20 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201206170519.4010606-3-jolsa@kernel.org> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.199.254] X-ClientProxiedBy: braeml702-chm.china.huawei.com (10.226.71.46) To lhreml741-chm.china.huawei.com (10.201.108.191) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Regards, Alexei