Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4991484pxu; Thu, 10 Dec 2020 10:11:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzt3YjGKf69ajqq4K0sO56STv5Hn+f4ZYKIyR8TIT/kQUr0aomW3D47/jB/gJXP6G6BALyy X-Received: by 2002:a50:f392:: with SMTP id g18mr8117722edm.306.1607623865097; Thu, 10 Dec 2020 10:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607623864; cv=none; d=google.com; s=arc-20160816; b=q96L5SW550ChgtW77ZxbuEjkj5IU+WILKCAXz0xIs6ttOe6wUQ0oF52MN6g4UE7CxM 0DslG5tqgw/KNmhsS59IIhPV/7QXKdCSvzLhL9j/rIEKR3TtytEZaFgjv/aXsjGnxIwr C1sd1oQTJUhxGGRAya55c2/kkigRfGcK4js2QKx5/8Nxpz7TRCUvVIzf0WjI/JbGrGYN RaFVyY1cFIGY38aK8h7TTFZGb5wpa23LYNeyYB1C0/9tDFXHbD9Uie2ouQTKC6UACSvY pjTi2YcOS52Yd7pIJcI6cSzHNH/youPUuasrIZ+MnQpq1pU0mHruzkWGEhvIdIv+IBls ENPg== 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:date:dkim-signature; bh=vzwpL+oyCC6ybTYdSfCdXZ5JS1M9p4/+mGraiaF/j9s=; b=WQq3xJ16iZBH2Tu0G4/1GpSBax+0dc5WZv/ovOQJrUA8aYLVx0jVb7wtQrRqhJrkZw JsM4lA1EV9k1PFZ7VLGNpGRR3Ofb5gguqcCOh5r4gOPyWy9DSLzyDj9/nWaHFj8LmqXY ufaYht+jGChnNyZN4RmnulY5sYSVd1KDdCltwoaBcQ1kV0/TW8x0LCufnVqu5WLoseQn Cyn/1E2LcQfVdm1vzyj0TgFP+3rn8RuKX63nEzxivxYkC9BBunvDAsP9tK6JONV3ytI9 ewy24bCaZ/TBG9gt6+QmcpmQOvfWszws6Io6YhTjGH79/DyGpcEh0dvnVCe+m7Q0uiSC F8zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a7FGgSxW; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs12si2952359ejb.127.2020.12.10.10.10.42; Thu, 10 Dec 2020 10:11:04 -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=@redhat.com header.s=mimecast20190719 header.b=a7FGgSxW; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404077AbgLJSIc (ORCPT + 99 others); Thu, 10 Dec 2020 13:08:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30012 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392845AbgLJSIX (ORCPT ); Thu, 10 Dec 2020 13:08:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1607623616; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vzwpL+oyCC6ybTYdSfCdXZ5JS1M9p4/+mGraiaF/j9s=; b=a7FGgSxWNpoJVrX5jNakOgvBwOMumYhWXWN9PQkqI3ufHTSTubaQYGST/wCVYine2fMn9R P2lZU6CuART6L/C0X543ewI78ppFF/ZfTm+osoq+uyV1DzICYnbIiRYKWLYiIxiR61s9rU 517NislATGmEtYr4AKalzFczMpMcGTA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-CraozjSoN-ChzJf9f-h3Pg-1; Thu, 10 Dec 2020 13:06:52 -0500 X-MC-Unique: CraozjSoN-ChzJf9f-h3Pg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3158B84A5EC; Thu, 10 Dec 2020 18:06:50 +0000 (UTC) Received: from krava (unknown [10.40.192.193]) by smtp.corp.redhat.com (Postfix) with SMTP id 1041F5F9B8; Thu, 10 Dec 2020 18:06:46 +0000 (UTC) Date: Thu, 10 Dec 2020 19:06:46 +0100 From: Jiri Olsa To: Alexei Budankov Cc: Jiri Olsa , Arnaldo Carvalho de Melo , 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: <20201210180646.GA186916@krava> 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 10, 2020 at 05:24:30PM +0100, Jiri Olsa wrote: > 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 actualy it's already checked in evlist__ctlfd_recv, evsel_name at worst will be empty string so evlist__find_evsel_by_str will fail I'll add '' around %s in the error output string: failed: can't find '%s' event so it's obvious when it's empty jirka