Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752121Ab2BUPcE (ORCPT ); Tue, 21 Feb 2012 10:32:04 -0500 Received: from mail-pz0-f46.google.com ([209.85.210.46]:39487 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751797Ab2BUPcC (ORCPT ); Tue, 21 Feb 2012 10:32:02 -0500 Authentication-Results: mr.google.com; spf=pass (google.com: domain of dsahern@gmail.com designates 10.68.213.232 as permitted sender) smtp.mail=dsahern@gmail.com; dkim=pass header.i=dsahern@gmail.com Message-ID: <4F43B8EC.30400@gmail.com> Date: Tue, 21 Feb 2012 08:31:56 -0700 From: David Ahern User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: Stephane Eranian CC: linux-kernel@vger.kernel.org, acme@redhat.com, peterz@infradead.org, mingo@elte.hu, eric.dumazet@gmail.com Subject: Re: [PATCH] perf tools: fix broken perf record -a mode References: <20120221145424.GA6757@quad> In-Reply-To: <20120221145424.GA6757@quad> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2060 Lines: 58 On 2/21/12 7:54 AM, Stephane Eranian wrote: > > The following commit: > b52956c perf tools: Allow multiple threads or processes in record, stat, top > > introduced a bug in the thread_map code which caused > perf record -a to not setup system-wide monitoring properly. > > $ taskset -c 1 noploop 1000& > $ perf record -a -C 1 sleep 10 > $ perf report -D | tail -20 > cycles stats: > TOTAL events: 4413 > MMAP events: 4025 > COMM events: 340 > SAMPLE events: 48 > > Here I was expecting about 10,000 samples and not 48. > > In system-wide mode, the PID passed to perf_event_open() > must be -1 and it was 0. That caused the kernel to setup > a per-process event on PID:0. Consequently, the number > of samples captured does not correspond to the requested > measurement. > > The following one-liner fixes the problem for me with or > without -C. > > I would also suggest to change the malloc() to something > that matches the struct definition. thread_map->map[] is > declared as int map[] and not pid_t map[]. If map[] can > only contain pids, then change the struct definition. > > Signed-off-by: Stephane Eranian > --- > > diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c > index e15983c..84d9bd78 100644 > --- a/tools/perf/util/thread_map.c > +++ b/tools/perf/util/thread_map.c > @@ -229,7 +229,7 @@ static struct thread_map *thread_map__new_by_tid_str(const char *tid_str) > if (!tid_str) { > threads = malloc(sizeof(*threads) + sizeof(pid_t)); > if (threads != NULL) { > - threads->map[1] = -1; > + threads->map[0] = -1; > threads->nr = 1; > } > return threads; Damn. Hope you did not spend much time chasing it down. Acked-by: David Ahern -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/