From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163029AbdKRIMi (ORCPT ); Sat, 18 Nov 2017 03:12:38 -0500 Received: from terminus.zytor.com ([65.50.211.136]:40877 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163011AbdKRIMa (ORCPT ); Sat, 18 Nov 2017 03:12:30 -0500 Date: Sat, 18 Nov 2017 00:10:09 -0800 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: namhyung@kernel.org, tglx@linutronix.de, b.stolk@gmail.com, linux-kernel@vger.kernel.org, hpa@zytor.com, wangnan0@huawei.com, mingo@kernel.org, dsahern@gmail.com, adrian.hunter@intel.com, acme@redhat.com, jolsa@kernel.org Reply-To: adrian.hunter@intel.com, dsahern@gmail.com, acme@redhat.com, jolsa@kernel.org, tglx@linutronix.de, namhyung@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, b.stolk@gmail.com, mingo@kernel.org, wangnan0@huawei.com To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf evlist: Set the correct idx when adding dummy events Git-Commit-ID: 640d5175a671cd0df0b9e3b5935dc80fc5248973 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 640d5175a671cd0df0b9e3b5935dc80fc5248973 Gitweb: https://git.kernel.org/tip/640d5175a671cd0df0b9e3b5935dc80fc5248973 Author: Arnaldo Carvalho de Melo AuthorDate: Fri, 3 Nov 2017 15:13:29 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 13 Nov 2017 09:39:57 -0300 perf evlist: Set the correct idx when adding dummy events The evsel->idx field is used mainly to access the right bucket in per-event arrays such as the annotation ones, but also to set evsel->tracking, that in turn will decide what of the events will ask for PERF_RECORD_{MMAP,COMM,EXEC} to be generated, i.e. which perf_event_attr will have its mmap, etc fields set. When we were adding the "dummy" event using perf_evlist__add_dummy() we were not setting it correctly, which could result in multiple tracking events. Now that I'll try using a dummy event to be the tracking one when using 'perf record --delay', i.e. when we process the --delay setting we may already have the evlist set up, like with: perf record -e cycles,instructions --delay 1000 ./workload We will need to add a "dummy" event, then reset evsel->tracking for the first event, "cycles", and set it instead to the dummy one, and also setting its attr.enable_on_exec, so that we get the PERF_RECORD_MMAP, etc metadata events while waiting to enable the explicitely requested events, so lets get this straight and set the right evsel->idx. Cc: Adrian Hunter Cc: Bram Stolk Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-nrdfchshqxf7diszhxcecqb9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index c6c891e..ccb749f 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -257,7 +257,7 @@ int perf_evlist__add_dummy(struct perf_evlist *evlist) .config = PERF_COUNT_SW_DUMMY, .size = sizeof(attr), /* to capture ABI version */ }; - struct perf_evsel *evsel = perf_evsel__new(&attr); + struct perf_evsel *evsel = perf_evsel__new_idx(&attr, evlist->nr_entries); if (evsel == NULL) return -ENOMEM;