From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758943AbcBYEHa (ORCPT ); Wed, 24 Feb 2016 23:07:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50539 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751337AbcBYEH2 (ORCPT ); Wed, 24 Feb 2016 23:07:28 -0500 Date: Thu, 25 Feb 2016 09:37:24 +0530 From: Pratyush Anand To: Peter Zijlstra , mpetlan@redhat.com Cc: Jiri Olsa , mingo@kernel.org, alexander.shishkin@linux.intel.com, eranian@google.com, linux-kernel@vger.kernel.org, vince@deater.net, dvyukov@google.com, andi@firstfloor.org, sasha.levin@oracle.com, oleg@redhat.com Subject: Re: [RFC][PATCH 4/7] perf: Fix scaling vs enable_on_exec Message-ID: <20160225040724.GA25658@dhcppc3.redhat.com> References: <20160219143743.692339502@infradead.org> <20160219144132.043429490@infradead.org> <20160223152729.GT6357@twins.programming.kicks-ass.net> <20160223154849.GC9102@krava.redhat.com> <20160223163550.GC11724@dhcppc3.redhat.com> <20160223174741.GL6356@twins.programming.kicks-ass.net> <20160224115351.GS6375@twins.programming.kicks-ass.net> <20160224140239.GT6375@twins.programming.kicks-ass.net> <20160224160241.GU6375@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160224160241.GU6375@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, On 24/02/2016:05:02:41 PM, Peter Zijlstra wrote: > On Wed, Feb 24, 2016 at 03:02:39PM +0100, Peter Zijlstra wrote: > > FWIW, it would be nice to have a similar test for: + Michael, (C Test case for following proposed test case is at the end) > > > > attr = { > > .disabled = true; > > } > > > > sys_perf_event_open(&attr, .pid = self); > > > > if (attr.disabled) > > ioctl(ENABLE); > > > > /* generate N events */ > > > > ioctl(DISABLE); > > > > read(); > > > > /* print event cnt and scale factors */ > > > > and one that has .disabled = false. > > > root@ivb-ep:~/perf# ./main > 1000000903 218851613 218851613 > root@ivb-ep:~/perf# ./main 1 > 1000000235 218981231 218981231 > > > Appears to work... Thanks, Picked patches from your new series and it worked :-) # perf stat -x';' -e 'probe_exact:*' examples/exact_counts 65535;;probe_exact:f_65535x;85984820;100.00 997;;probe_exact:f_997x;85984820;100.00 103;;probe_exact:f_103x;85984820;100.00 3;;probe_exact:f_3x;85984820;100.00 2;;probe_exact:f_2x;85984820;100.00 1;;probe_exact:f_1x;85984820;100.00 ~Pratyush > > --- > > #define _GNU_SOURCE > #include > #include > #include > #include > > #include "perf.h" > > static struct perf_event_attr perf_attr = { > .type = PERF_TYPE_HARDWARE, > .config = PERF_COUNT_HW_INSTRUCTIONS, > .read_format = PERF_FORMAT_TOTAL_TIME_ENABLED | > PERF_FORMAT_TOTAL_TIME_RUNNING, > .exclude_kernel = 1, > .pinned = 1, > }; > > void die(const char *err, ...) > { > va_list params; > > va_start(params, err); > vfprintf(stderr, err, params); > va_end(params); > > exit(-1); > } > > int main (int argc, char **argv) > { > u64 val[3]; > int i, fd; > > perf_attr.disabled = argc > 1; > > fd = sys_perf_event_open(&perf_attr, 0, -1, -1, 0); > if (fd < 0) > die("failed to create perf_event"); > > if (perf_attr.disabled) > ioctl(fd, PERF_EVENT_IOC_ENABLE, 0); > > for (i = 0; i < 100000000; i++) { > asm volatile ("nop\n\r" > "nop\n\r" > "nop\n\r" > "nop\n\r" > "nop\n\r" > "nop\n\r" > "nop\n\r"); > } > > ioctl(fd, PERF_EVENT_IOC_DISABLE, 0); > > read(fd, &val, sizeof(val)); > > printf("%Lu %Lu %Lu\n", val[0], val[1], val[2]); > > return 0; > }