linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Milian Wolff <milian.wolff@kdab.com>
To: linux-perf-users@vger.kernel.org
Subject: perf inject --sched-stat can produce invalid perf.data files
Date: Tue, 16 Aug 2016 17:56:10 +0200	[thread overview]
Message-ID: <1705181.9Ekn7j0XTY@agathebauer> (raw)

[-- Attachment #1: Type: text/plain, Size: 2209 bytes --]

Hey all,

I've hit another issue that I have trouble understanding and fixing:

~~~~~~~~~~~~
echo 1 | sudo tee /proc/sys/kernel/sched_schedstats

perf record \
    --event sched:sched_stat_sleep/call-graph=no/ \
    --event sched:sched_switch/call-graph=fp/ \
    --output perf.data.raw \
    sleep 1

echo 0 | sudo tee /proc/sys/kernel/sched_schedstats

perf inject --sched-stat --input perf.data.raw --output perf.data
perf script # or perf report
0x4e18 [0xd8]: failed to process type: 9
~~~~~~~~~~~~

This happens only for the perf.data produced by perf-inject when at least one 
of the sched events has no call graph.

Looking at the code, I see that the issue is triggered in evsel.c:

~~~~~~~~~~~~
	if (type & PERF_SAMPLE_CALLCHAIN) {
		const u64 max_callchain_nr = UINT64_MAX / sizeof(u64);

		OVERFLOW_CHECK_u64(array);
		data->callchain = (struct ip_callchain *)array++;
		if (data->callchain->nr > max_callchain_nr)
			return -EFAULT;
		sz = data->callchain->nr * sizeof(u64);
		OVERFLOW_CHECK(array, sz, max_size);
		array = (void *)array + sz;
	}
~~~~~~~~~~~~

In GDB:

~~~~~~~~~~~~
(gdb) break evsel.c:1859
Breakpoint 1 at 0x5555556704d9: file util/evsel.c, line 1859.
(gdb) run
Starting program: /home/milian/.bin/perf script
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Breakpoint 1, perf_evsel__parse_sample (evsel=0x5555571c1d50, 
event=0x7ffff7ff4e18, data=0x7fffffffb3e0) at util/evsel.c:1861
1861                    data->callchain = (struct ip_callchain *)array++;
(gdb) next
1862                    if (data->callchain->nr > max_callchain_nr)
(gdb) print *data->callchain
$1 = {nr = 61654255534090, ips = 0x7ffff7ff4e58}
(gdb) next
1864                    sz = data->callchain->nr * sizeof(u64);
(gdb) 
1865                    OVERFLOW_CHECK(array, sz, max_size);
(gdb) print sz
$2 = 493234044272720
(gdb) next
1934                                    return -EFAULT;
~~~~~~~~~~~~

Can someone please look into this issue and find a way to fix perf-inject? 

Thanks

-- 
Milian Wolff | milian.wolff@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5903 bytes --]

             reply	other threads:[~2016-08-16 16:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-16 15:56 Milian Wolff [this message]
2016-08-30 21:26 ` perf inject --sched-stat can produce invalid perf.data files Milian Wolff

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=1705181.9Ekn7j0XTY@agathebauer \
    --to=milian.wolff@kdab.com \
    --cc=linux-perf-users@vger.kernel.org \
    /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).