linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* perf: prctl(PR_TASK_PERF_EVENTS_DISABLE) has no effect
@ 2012-07-26 10:54 Iegorov Oleg
  2012-07-27  7:26 ` Ingo Molnar
  0 siblings, 1 reply; 31+ messages in thread
From: Iegorov Oleg @ 2012-07-26 10:54 UTC (permalink / raw)
  To: linux-perf-users, mingo, a.p.zijlstra, acme

as there was no proposed solution that helped me in response to the same 
post by Andrew Steets, I would like to know if it is possible to 
disable/enable perf event counters from the source code?

calling prctl(PR_TASK_PERF_EVENTS_DISABLE) has no effect, nor does 
compiling with -fno-omit-frame-pointer option.

It would be extremely useful to disable perf event counters for some 
parts of code and re-enable them for other parts of code, like:

prctl(PR_TASK_PERF_EVENTS_DISABLE);
// not important for performance analysis code
prctl(PR_TASK_PERF_EVENTS_ENABLE);
// code that needs to be analysed

and then, run perf:

$ perf record ./program
$ perf report

Can anyone tell me how can I enable such functionality?
Thank you

--Oleg

^ permalink raw reply	[flat|nested] 31+ messages in thread
* perf: prctl(PR_TASK_PERF_EVENTS_DISABLE) has no effect
@ 2012-01-27 17:03 Andrew Steets
  2012-01-27 17:12 ` Peter Zijlstra
  2012-01-28 12:01 ` Ingo Molnar
  0 siblings, 2 replies; 31+ messages in thread
From: Andrew Steets @ 2012-01-27 17:03 UTC (permalink / raw)
  To: linux-perf-users, linux-kernel
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo

prctl(PR_TASK_PERF_EVENTS_DISABLE) doesn't appear to disable perf event
counters.  Here is a demonstration program:

#include <linux/prctl.h>

void loop_events_disabled() {
     volatile int x;
     int i;
     for (i = 0; i < 1000000000; i++)
         x = i;
     return;
}

void loop_events_enabled() {
     volatile int x;
     int i;
     for (i = 0; i < 1000000000; i++)
         x = i;
     return;
}

int main(int argc, char **argv) {
     prctl(PR_TASK_PERF_EVENTS_ENABLE);
     loop_events_enabled();
     prctl(PR_TASK_PERF_EVENTS_DISABLE);
     loop_events_disabled();
}

I would not expect to see loop_events_disabled() show up in the profile
as reported by perf report, but it does.

$ perf record ./a.out
$ perf report -n --stdio
# Events: 3K cycles
#
# Overhead  Samples    Command      Shared Object                Symbol
# ........ ..........  .......  .................  ....................
#
     51.80%       1679    a.out  a.out              [.] loop_events_enabled
     48.07%       1578    a.out  a.out              [.] loop_events_disabled
      0.03%          5    a.out  [kernel.kallsyms]  [k] intel_pmu_enable_all
      0.03%          1    a.out  [kernel.kallsyms]  [k] sched_clock
      0.03%          1    a.out  [kernel.kallsyms]  [k] ktime_get
      0.03%          1    a.out  [kernel.kallsyms]  [k] update_cpu_load
      0.01%          1    a.out  [sunrpc]           [k] generic_match

I have tested this on several kernels including 3.3rc1.  Can anyone tell
me if I'm using this wrong or if this is a bug?

-Andrew

-- 

---------------------------------------------------------------
This email, along with any attachments, is confidential. If you 
believe you received this message in error, please contact the 
sender immediately and delete all copies of the message.  
Thank you.

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2012-08-06  1:47 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-26 10:54 perf: prctl(PR_TASK_PERF_EVENTS_DISABLE) has no effect Iegorov Oleg
2012-07-27  7:26 ` Ingo Molnar
2012-07-27  8:00   ` Peter Zijlstra
2012-07-27  8:18     ` Ingo Molnar
2012-07-27  8:29       ` Peter Zijlstra
2012-07-27 11:40         ` Iegorov Oleg
2012-07-27 11:53         ` Ingo Molnar
2012-07-30 20:04           ` Andi Kleen
2012-07-31  5:47           ` Peter Zijlstra
2012-07-31  7:16             ` Ingo Molnar
2012-07-31 19:48               ` Peter Zijlstra
2012-07-27 11:56   ` [RFD] perf: events defined contexts (was Re: perf: prctl(PR_TASK_PERF_EVENTS_DISABLE) has no effect) Frederic Weisbecker
2012-07-27 12:45     ` Jiri Olsa
2012-08-06  1:41       ` Namhyung Kim
  -- strict thread matches above, loose matches on Subject: below --
2012-01-27 17:03 perf: prctl(PR_TASK_PERF_EVENTS_DISABLE) has no effect Andrew Steets
2012-01-27 17:12 ` Peter Zijlstra
2012-01-27 20:06   ` Andrew Steets
2012-01-27 21:34     ` Peter Zijlstra
2012-01-28 12:01 ` Ingo Molnar
2012-01-28 23:48   ` Andrew Steets
2012-01-29 16:32     ` Ingo Molnar
2012-01-29 17:50       ` Gleb Natapov
2012-01-30  9:52       ` Peter Zijlstra
2012-01-30 10:11         ` Ingo Molnar
2012-01-30 11:01           ` Peter Zijlstra
2012-01-30 11:31             ` Ingo Molnar
2012-01-30 13:45               ` Peter Zijlstra
2012-01-30 13:58                 ` Ingo Molnar
2012-01-30 15:30                 ` Arnaldo Carvalho de Melo
2012-01-30 15:29             ` Arnaldo Carvalho de Melo
2012-02-01 19:03           ` Frederic Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).