Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1203328

[PATCH] perf tools: Unset perf_event_attr::freq when period term is set

From Jiri Olsa <jolsa@redhat.com>
Newsgroups linux.kernel
Subject [PATCH] perf tools: Unset perf_event_attr::freq when period term is set
Date 2015-08-08 19:20 +0200
Message-ID <pVfWN-5cg-5@gated-at.bofh.it> (permalink)
References <pUGcG-3xm-7@gated-at.bofh.it> <pUGcG-3xm-11@gated-at.bofh.it> <pUS4a-3Sp-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Aug 07, 2015 at 12:38:43PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Aug 06, 2015 at 03:44:53PM -0400, kan.liang@intel.com escreveu:
> > From: Kan Liang <kan.liang@intel.com>
> > Here are some examples and test results.
> > 
> > 1. Comparing the elapsed time and perf.data size from "kernbench -M -H".
> > 
> >  The test command for FULL callgraph and time support.
> >    "perf record -e
> >    '{cpu/cpu-cycles,period=100000/,cpu/instructions,period=20000/p}'
> >    --call-graph fp --time"
> 
> Jiri, while testing this I noticed that the message for EINVAL when
> using the cpu// syntax (per-event settings) is cryptic:
> 
>   [root@zoo ~]# perf record -e 'cpu/cpu-cycles,call-graph=fp,time,period=100000/p' ls
>   Error:
>   The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cpu/cpu-cycles,call-graph=fp,time,period=100000/p).
>   /bin/dmesg may provide additional information.
>   No CONFIG_PERF_EVENTS=y kernel support configured?
> 
> Whereas if we use -F, it is much, much clearer, telling the user exactly
> what is failing and what needs to be done to make it work:
> 
>   [root@zoo ~]# perf record -F 100000 -e cpu/cpu-cycles/ usleep 1
>   Maximum frequency rate (25000) reached.
>   Please use -F freq option with lower value or consider
>   tweaking /proc/sys/kernel/perf_event_max_sample_rate.
>   [root@zoo ~]# 
> 
> Hope this is something easy to wire up, given your event parsing kung foo
> skillz...

my kungu foo found there was actually another issue ;-)

we did not clear up attr->freq bit.. so the sample_period
was handled as sample_freq value.. please check the patch
below

anyfoo, now period setup can raise sky high (which is correct)
and once it meets the God it shows:

[jolsa@krava perf]$ ./perf record -e 'cpu/cpu-cycles,call-graph=fp,time,period=1000000000000000000000000/' ls
event syntax error: '..time,period=1000000000000000000000000/'
                                  \___ parser error

I'll check if we could add some default error message when value
crosses the type maximum.. which now falls to parser error

jirka


---
We need to unset 'perf_event_attr::freq' bit (default 1) when
'period' term is specified within event definition like:

  -e 'cpu/cpu-cycles,call-graph=fp,time,period=100000'

otherwise it will handle the period value as frequency
(and fail if it crossed the maximum allowed frequency value).

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/n/tip-7f3gjwbekakhyxr47wvin4zb@git.kernel.org
---
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d902cad4ce10..4c779d23b1d7 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -623,6 +623,7 @@ static void apply_config_terms(struct perf_evsel *evsel,
 		switch (term->type) {
 		case PERF_EVSEL__CONFIG_TERM_PERIOD:
 			attr->sample_period = term->val.period;
+			attr->freq = 0;
 			break;
 		case PERF_EVSEL__CONFIG_TERM_TIME:
 			if (term->val.time)
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RFC V9 1/3] perf,tools: move callchain option parse code to util.c kan.liang@intel.com - 2015-08-07 05:10 +0200
  [PATCH RFC V9 2/3] perf,tools: per-event callgraph support kan.liang@intel.com - 2015-08-07 05:10 +0200
    Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Jiri Olsa <jolsa@redhat.com> - 2015-08-07 13:00 +0200
    Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-07 17:50 +0200
      Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Jiri Olsa <jolsa@redhat.com> - 2015-08-08 18:50 +0200
        Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-08 19:40 +0200
      RE: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support "Liang, Kan" <kan.liang@intel.com> - 2015-08-10 15:00 +0200
        Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-10 17:40 +0200
          RE: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support "Liang, Kan" <kan.liang@intel.com> - 2015-08-10 21:00 +0200
            Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-10 21:40 +0200
    Re: [PATCH RFC V9 2/3] perf,tools: per-event callgraph support Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-07 18:00 +0200
      [PATCH] perf tools: Unset perf_event_attr::freq when period term is  set Jiri Olsa <jolsa@redhat.com> - 2015-08-08 19:20 +0200
        [tip:perf/core] perf tools: Unset perf_event_attr::  freq when period term is set tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-08-12 14:40 +0200
  [PATCH] perf tools: Move perf_counts struct and functions into  separate object Jiri Olsa <jolsa@redhat.com> - 2015-08-07 13:00 +0200
    Re: [PATCH] perf tools: Move perf_counts struct and functions into  separate object Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-08-07 15:20 +0200
    [tip:perf/core] perf stat:   Move perf_counts struct and functions into separate object tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-08-12 14:30 +0200
  [tip:perf/core] perf callchain:   Move option parsing code to util.c tip-bot for Kan Liang <tipbot@zytor.com> - 2015-08-12 14:30 +0200

csiph-web