From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: sahil aggarwal <sahil.agg15@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: Sampling on sched:sched_switch
Date: Tue, 14 Apr 2015 09:15:59 -0300 [thread overview]
Message-ID: <20150414121559.GD16027@kernel.org> (raw)
In-Reply-To: <CAGAANTXY8UiP2yRUg5tVBB+PQdH8=X27MKUj=nSHvWHk-x5MJQ@mail.gmail.com>
Em Tue, Apr 14, 2015 at 11:12:11AM +0530, sahil aggarwal escreveu:
> In my case:
> bash-4.1# sudo perf stat -e sched:sched_switch sleep 1
> Performance counter stats for 'sleep 1':
> 0 sched:sched_switch
> 1.004714901 seconds time elapsed
So, there are some critical pieces of information missing here:
- perf --version
- cat /proc/cpuinfo
- uname -a
- What distribution is this?
So that we can try to figure this out.
> And if i do:
> bash-4.1# perf stat -e cs sleep 1
> Performance counter stats for 'sleep 1':
> 1 cs
> 1.003306642 seconds time elapsed
> To enable sampling on sched:sched_switch my perf_event_attr look like:
> e_open->attr.disabled = 1;
> e_open->attr.type = PERF_TYPE_TRACEPOINT;
> e_open->attr.config = 87;
in my machine:
[root@zoo ~]# cat /sys/kernel/debug/events/sched/sched_switch/format
name: sched_switch
ID: 263
> e_open->attr.size = sizeof(e_open->attr);
> e_open->attr.sample_period = 1;
> e_open->attr.inherit = 1;
> e_open->attr.sample_type = PERF_SAMPLE_TIME |
> PERF_SAMPLE_RAW |
> PERF_SAMPLE_CPU |
> PERF_SAMPLE_TID ;
> e_open->attr.__reserved_1 = 0;
> e_open->attr.read_format = 0;
> Running in separate thread for each CPU:
Running in separate thread for each CPU? Can you ellaborate on this?
> perf_event_open(&e_open->attr,2552,0,-1,0)
> perf_event_open(&e_open->attr,2552,1,-1,0)
So you have two counters, one in each CPU, for the same thread? What is
the intent?
If I go to do it with 'perf stat' it uses:
[root@zoo ~]# perf stat -vv -p 7762 -e sched:*switch 2>&1 | grep sys_perf_event_open
sys_perf_event_open: pid 7762 cpu -1 group_fd -1 flags 0x8
^C[root@zoo ~]#
Just one sys_perf_event_open syscall, stating that its the thread 7762
that should be monitored, in whatever CPU it ends up running.
Of course I can have multiple sys_perf_event_open() calls, from
different users even, if they have the appropriate permissions, and as
well many from the same user, but why, on the same monitoring session,
create one thread per CPU if the thread will only run in one CPU at a
time? You will end up having to order events from multiple ring buffers,
etc.
>
> But if do :
>
> e_open->attr.disabled = 1;
> e_open->attr.type = PERF_TYPE_SOFTWARE;
> e_open->attr.config = PERF_COUNT_SW_CONTEXT_SWITCHES;
> e_open->attr.size = sizeof(e_open->attr);
> e_open->attr.sample_period = 1;
> e_open->attr.inherit = 1;
> e_open->attr.sample_type = PERF_SAMPLE_TIME |
>
> PERF_SAMPLE_RAW |
>
> PERF_SAMPLE_CPU |
>
> PERF_SAMPLE_TID ;
> e_open->attr.__reserved_1 = 0;
> e_open->attr.read_format = 0;
>
> It writes events to ring buffer but of course without any
> args(prev_comm,prev_pid,next_comm,next_pid)
>
> So i am not able to understand this difference. Why sched:sched_switch
> doesnt give me any counter.
The difference is that you're using two different kinds of events, as you
can see on the attr.type and attr.config above, for some reason in your
case the PERF_TYPE_TRACEPOINT one is not happening, being lost or not
being asked for in some subtle way.
- Arnaldo
next prev parent reply other threads:[~2015-04-14 12:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-13 13:04 Sampling on sched:sched_switch sahil aggarwal
2015-04-13 15:11 ` Arnaldo Carvalho de Melo
2015-04-14 5:42 ` sahil aggarwal
2015-04-14 12:15 ` Arnaldo Carvalho de Melo [this message]
2015-04-14 12:30 ` sahil aggarwal
2015-04-14 12:59 ` Arnaldo Carvalho de Melo
2015-04-14 13:30 ` sahil aggarwal
2015-04-14 14:22 ` Arnaldo Carvalho de Melo
2015-04-14 14:55 ` sahil aggarwal
2015-04-15 6:17 ` sahil aggarwal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150414121559.GD16027@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sahil.agg15@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).