Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1306221 > unrolled thread
| Started by | Wang Nan <wangnan0@huawei.com> |
|---|---|
| First post | 2016-01-11 14:50 +0100 |
| Last post | 2016-01-11 15:30 +0100 |
| Articles | 20 on this page of 94 — 11 participants |
Back to article view | Back to linux.kernel
[PATCH 00/53] perf tools: Bugfix, BPF improvement and perf record flight record mode Wang Nan <wangnan0@huawei.com> - 2016-01-11 14:50 +0100
[PATCH 44/53] perf tools: Automatically add new channel according to evlist Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 01/53] perf tools: Add -lutil in python lib list for broken python-config Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
Re: [PATCH 01/53] perf tools: Add -lutil in python lib list for broken python-config Jiri Olsa <jolsa@redhat.com> - 2016-01-12 10:50 +0100
[tip:perf/urgent] perf tools: Add -lutil in python lib list for broken python-config tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:10 +0100
[PATCH 09/53] perf: bpf: Fix build breakage due to libbpf Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[tip:perf/urgent] perf bpf: Fix build breakage due to libbpf "tip-bot for Naveen N. Rao" <tipbot@zytor.com> - 2016-01-12 11:20 +0100
[PATCH 52/53] perf record: Toggle tailsize ring buffer for reading Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 17/53] perf test: Improve bp_signal Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
Re: [PATCH 17/53] perf test: Improve bp_signal Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 22:40 +0100
Re: [PATCH 17/53] perf test: Improve bp_signal "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-12 05:20 +0100
Re: [PATCH 17/53] perf test: Improve bp_signal Jiri Olsa <jolsa@redhat.com> - 2016-01-12 10:30 +0100
Re: [PATCH 17/53] perf test: Improve bp_signal Will Deacon <will.deacon@arm.com> - 2016-01-12 15:20 +0100
Re: [PATCH 17/53] perf test: Improve bp_signal Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-12 15:20 +0100
[PATCH 47/53] perf record: Don't read from and poll overwrite channel Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 28/53] perf tools: Move timestamp creation to util Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 39/53] perf record: Re-synthesize tracking events after output switching Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 33/53] perf record: Introduce record__finish_output() to finish a perf.data Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 46/53] perf tools: Squash overwrite setting into channel Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 34/53] perf record: Use OPT_BOOLEAN_SET for buildid cache related options Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 43/53] perf tools: Add evlist channel helpers Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 51/53] perf record: Read from tailsize ring buffer Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 42/53] perf record: Prevent reading invalid data in record__mmap_read Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
Re: [PATCH 42/53] perf record: Prevent reading invalid data in record__mmap_read Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-01-11 15:30 +0100
Re: [PATCH 42/53] perf record: Prevent reading invalid data in record__mmap_read Arnaldo Carvalho de Melo <acme@redhat.com> - 2016-01-11 16:10 +0100
Re: [PATCH 42/53] perf record: Prevent reading invalid data in record__mmap_read Arnaldo Carvalho de Melo <acme@redhat.com> - 2016-01-11 16:10 +0100
[PATCH 40/53] perf record: Generate tracking events for process forked by perf Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 41/53] perf record: Ensure return non-zero rc when mmap fail Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 49/53] perf tools: Consider TAILSIZE bit when caclulate is_pos Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 31/53] perf tools: Add perf_data_file__switch() helper Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 50/53] perf tools: Set tailsize attribut bit for overwrite events Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 45/53] perf tools: Operate multiple channels Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 30/53] perf record: Extract synthesize code to record__synthesize() Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 07/53] tools: Move Makefile.arch from perf/config to tools/scripts Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
Re: [PATCH 07/53] tools: Move Makefile.arch from perf/config to tools/scripts "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
Re: [PATCH 07/53] tools: Move Makefile.arch from perf/config to tools/scripts Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 15:20 +0100
[tip:perf/urgent] tools: Move Makefile.arch from perf/ config to tools/scripts tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
[PATCH 53/53] perf record: Allow generate tracking events at the end of output Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 48/53] perf tools: Enable overwrite settings Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:00 +0100
[PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test hist' Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
Re: [PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test hist' Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-01-11 15:30 +0100
Re: [PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test hist' Arnaldo Carvalho de Melo <acme@redhat.com> - 2016-01-11 16:00 +0100
Re: [PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test hist' Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 16:40 +0100
[tip:perf/urgent] perf test: Fix false TEST_OK result for ' perf test hist' tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
[PATCH 15/53] perf tools: Fix symbols searching for offline module in buildid-cache Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[PATCH 06/53] perf tools: Fix PowerPC native building Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[tip:perf/urgent] perf tools: Fix PowerPC native building tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
[PATCH 23/53] perf tools: Support setting different slots in a BPF map separately Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[PATCH 02/53] perf tools: Fix phony build target for build-test Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[tip:perf/urgent] perf tools: Fix phony build target for build-test tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
[PATCH 19/53] perf tools: Enable BPF object configure syntax Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[PATCH 05/53] perf tools: Test correct path of perf in build-test Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 16:30 +0100
Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 23:10 +0100
Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 23:40 +0100
Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 23:50 +0100
Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-12 08:20 +0100
Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-12 15:10 +0100
[PATCH 20/53] perf record: Apply config to BPF objects before recording Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[PATCH 14/53] perf test: Check environment before start real BPF test Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
Re: [PATCH 14/53] perf test: Check environment before start real BPF test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 23:00 +0100
Re: [PATCH 14/53] perf test: Check environment before start real BPF test "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-12 08:50 +0100
[PATCH 26/53] perf data: Support converting data from bpf_perf_event_output() Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[PATCH 36/53] perf record: Split output into multiple files via '--switch-output' Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[PATCH 12/53] perf test: Reset err after using it hold errcode in hist testcases Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[tip:perf/urgent] perf test: Reset err after using it hold errcode in hist testcases tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
[PATCH 29/53] perf tools: Make ordered_events reusable Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
Re: [PATCH 29/53] perf tools: Make ordered_events reusable Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 22:40 +0100
[PATCH 04/53] perf tools: Pass O option to Makefile.perf in build-test Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[PATCH 32/53] perf record: Turns auxtrace_snapshot_enable into 3 states Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[PATCH 16/53] perf tools: Fix mmap2 event allocation in synthesize code Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
Re: [PATCH 16/53] perf tools: Fix mmap2 event allocation in synthesize code Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 22:10 +0100
[PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in synthesize code Wang Nan <wangnan0@huawei.com> - 2016-01-12 11:20 +0100
RE: [PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in synthesize code 平松雅巳 / HIRAMATU,MASAMI <masami.hiramatsu.pt@hitachi.com> - 2016-01-12 11:50 +0100
Re: [PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in synthesize code "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-12 12:00 +0100
Re: [PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in synthesize code "acme@kernel.org" <acme@kernel.org> - 2016-01-12 15:30 +0100
RE: [PATCH 16/53 v2] perf tools: Fix mmap2 event allocation in synthesize code 平松雅巳 / HIRAMATU,MASAMI <masami.hiramatsu.pt@hitachi.com> - 2016-01-13 01:50 +0100
[tip:perf/urgent] perf tools: Fix mmap2 event allocation in synthesize code tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-13 10:50 +0100
[PATCH 08/53] perf tools: Add missing sources in perf's MANIFEST Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[PATCH 21/53] perf tools: Enable passing event to BPF object Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:10 +0100
[PATCH 25/53] perf tools: Introduce bpf-output event Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
[PATCH 18/53] perf tools: Add API to config maps in bpf object Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
[PATCH 24/53] perf tools: Enable indices setting syntax for BPF maps Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
[PATCH 22/53] perf tools: Support perf event alias name Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
[PATCH 13/53] perf tools: Prevent calling machine__delete() on non-allocated machine Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
Re: [PATCH 13/53] perf tools: Prevent calling machine__delete() on non-allocated machine Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-11 16:50 +0100
Re: [PATCH 13/53] perf tools: Prevent calling machine__delete() on non-allocated machine "Wangnan (F)" <wangnan0@huawei.com> - 2016-01-12 08:10 +0100
Re: [PATCH 13/53] perf tools: Prevent calling machine__delete() on non-allocated machine Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-12 15:10 +0100
[PATCH 10/53] tools build: Add BPF feature check to test-all Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
[tip:perf/urgent] tools build: Add BPF feature check to test-all tip-bot for Wang Nan <tipbot@zytor.com> - 2016-01-12 11:20 +0100
[PATCH 37/53] perf record: Force enable --timestamp-filename when --switch-output is provided Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
[PATCH 03/53] perf tools: Set parallel making options build-test Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:20 +0100
[PATCH 35/53] perf record: Add '--timestamp-filename' option to append timestamp to output filename Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:30 +0100
[PATCH 38/53] perf record: Disable buildid cache options by default in switch output mode Wang Nan <wangnan0@huawei.com> - 2016-01-11 15:30 +0100
Page 3 of 5 — ← Prev page 1 2 [3] 4 5 Next page →
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Date | 2016-01-11 15:30 +0100 |
| Subject | Re: [PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test hist' |
| Message-ID | <qPLDQ-3yx-13@gated-at.bofh.it> |
| In reply to | #1306258 |
On 01/11/2016 04:48 PM, Wang Nan wrote:
> Commit 71d6de64feddd4b455555326fba2111b3006d9e0 ('perf test: Fix hist
> testcases when kptr_restrict is on') solves a double free problem when
You didn't run this patch thru scripts/checkpatch.pl, I guess? A certain
commit citing style is enforced now, and yours doesn't quite match it...
> 'perf test hist' calling setup_fake_machine(). However, the result is
> still incorrect. For example:
>
> $ ./perf test -v 'filtering hist entries'
> 25: Test filtering hist entries :
> --- start ---
> test child forked, pid 4186
> Cannot create kernel maps
> test child finished with 0
> ---- end ----
> Test filtering hist entries: Ok
>
> In this case the body of this test is not get executed at all, but the
> result is 'Ok'.
>
> Actually, in setup_fake_machine() there's no need to create real kernel
> maps. What we want is the fake maps. This patch removes the
> machine__create_kernel_maps() in setup_fake_machine(), so it won't be
> affected by kptr_restrict setting.
>
> Test result:
>
> $ cat /proc/sys/kernel/kptr_restrict
> 1
> $ ~/perf test -v hist
> 15: Test matching and linking multiple hists :
> --- start ---
> test child forked, pid 24031
> test child finished with 0
> ---- end ----
> Test matching and linking multiple hists: Ok
> [SNIP]
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Suggested-by: Namhyung Kim <namhyung@kernel.org>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
[...]
MBR, Sergei
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@redhat.com> |
|---|---|
| Date | 2016-01-11 16:00 +0100 |
| Subject | Re: [PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test hist' |
| Message-ID | <qPM6T-3KB-27@gated-at.bofh.it> |
| In reply to | #1306307 |
Em Mon, Jan 11, 2016 at 05:25:48PM +0300, Sergei Shtylyov escreveu:
> On 01/11/2016 04:48 PM, Wang Nan wrote:
>
> >Commit 71d6de64feddd4b455555326fba2111b3006d9e0 ('perf test: Fix hist
> >testcases when kptr_restrict is on') solves a double free problem when
>
> You didn't run this patch thru scripts/checkpatch.pl, I guess? A
> certain commit citing style is enforced now, and yours doesn't quite
> match it...
Which is? /me goes to read checpatch.pl...
- Arnaldo
> >'perf test hist' calling setup_fake_machine(). However, the result is
> >still incorrect. For example:
> >
> > $ ./perf test -v 'filtering hist entries'
> > 25: Test filtering hist entries :
> > --- start ---
> > test child forked, pid 4186
> > Cannot create kernel maps
> > test child finished with 0
> > ---- end ----
> > Test filtering hist entries: Ok
> >
> >In this case the body of this test is not get executed at all, but the
> >result is 'Ok'.
> >
> >Actually, in setup_fake_machine() there's no need to create real kernel
> >maps. What we want is the fake maps. This patch removes the
> >machine__create_kernel_maps() in setup_fake_machine(), so it won't be
> >affected by kptr_restrict setting.
> >
> >Test result:
> >
> > $ cat /proc/sys/kernel/kptr_restrict
> > 1
> > $ ~/perf test -v hist
> > 15: Test matching and linking multiple hists :
> > --- start ---
> > test child forked, pid 24031
> > test child finished with 0
> > ---- end ----
> > Test matching and linking multiple hists: Ok
> > [SNIP]
> >
> >Signed-off-by: Wang Nan <wangnan0@huawei.com>
> >Suggested-by: Namhyung Kim <namhyung@kernel.org>
> >Acked-by: Namhyung Kim <namhyung@kernel.org>
> >Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> >Cc: Jiri Olsa <jolsa@kernel.org>
> >Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> [...]
>
> MBR, Sergei
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-01-11 16:40 +0100 |
| Subject | Re: [PATCH 11/53] perf test: Fix false TEST_OK result for 'perf test hist' |
| Message-ID | <qPMJA-4ee-17@gated-at.bofh.it> |
| In reply to | #1306367 |
Em Mon, Jan 11, 2016 at 12:58:37PM -0200, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Jan 11, 2016 at 05:25:48PM +0300, Sergei Shtylyov escreveu:
> > On 01/11/2016 04:48 PM, Wang Nan wrote:
> >
> > >Commit 71d6de64feddd4b455555326fba2111b3006d9e0 ('perf test: Fix hist
> > >testcases when kptr_restrict is on') solves a double free problem when
> >
> > You didn't run this patch thru scripts/checkpatch.pl, I guess? A
> > certain commit citing style is enforced now, and yours doesn't quite
> > match it...
>
> Which is? /me goes to read checpatch.pl...
So, this is it:
[acme@felicio linux]$ scripts/checkpatch.pl /wb/1.patch
ERROR: Please use git commit description style 'commit <12+ chars of
sha1> ("<title line>")' - ie: 'Commit 71d6de64fedd ("perf test: Fix hist
testcases when kptr_restrict is on")'
#62:
Commit 71d6de64feddd4b455555326fba2111b3006d9e0 ('perf test: Fix hist
total: 1 errors, 0 warnings, 11 lines checked
/wb/1.patch has style problems, please review.
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
[acme@felicio linux]$
Ok, matches what I use with this macro that I run in vim with ':!fixes'
after selecting the long commit hash:
#!/bin/bash
if [ $# -eq 1 ] ; then
cset=$1
else
read cset
fi
git log --oneline $cset | head -1 | sed -r 's/([^ ]+) (.*)/Fixes: \1 \("\2\")/g'
------------------------
And I have:
[acme@felicio linux]$ grep abbrev .git/config
abbrev = 12
- Arnaldo
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Wang Nan <tipbot@zytor.com> |
|---|---|
| Date | 2016-01-12 11:20 +0100 |
| Subject | [tip:perf/urgent] perf test: Fix false TEST_OK result for ' perf test hist' |
| Message-ID | <qQ4dv-7Y1-43@gated-at.bofh.it> |
| In reply to | #1306258 |
Commit-ID: 71b3ee7e65ffb48135d875d9c36e3183b9ecffeb
Gitweb: http://git.kernel.org/tip/71b3ee7e65ffb48135d875d9c36e3183b9ecffeb
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Mon, 11 Jan 2016 13:48:02 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 11 Jan 2016 19:22:22 -0300
perf test: Fix false TEST_OK result for 'perf test hist'
Commit 71d6de64fedd ("perf test: Fix hist testcases when kptr_restrict is on")
solves a double free problem when 'perf test hist' calling
setup_fake_machine(). However, the result is still incorrect. For example:
$ ./perf test -v 'filtering hist entries'
25: Test filtering hist entries :
--- start ---
test child forked, pid 4186
Cannot create kernel maps
test child finished with 0
---- end ----
Test filtering hist entries: Ok
In this case the body of this test is not get executed at all, but the
result is 'Ok'.
Actually, in setup_fake_machine() there's no need to create real kernel
maps. What we want are the fake maps. This patch removes the
machine__create_kernel_maps() in setup_fake_machine(), so it won't be
affected by kptr_restrict setting.
Test result:
$ cat /proc/sys/kernel/kptr_restrict
1
$ ~/perf test -v hist
15: Test matching and linking multiple hists :
--- start ---
test child forked, pid 24031
test child finished with 0
---- end ----
Test matching and linking multiple hists: Ok
[SNIP]
Suggested-and-Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1452520124-2073-12-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/hists_common.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c
index bcfd081..071a8b5 100644
--- a/tools/perf/tests/hists_common.c
+++ b/tools/perf/tests/hists_common.c
@@ -87,11 +87,6 @@ struct machine *setup_fake_machine(struct machines *machines)
return NULL;
}
- if (machine__create_kernel_maps(machine)) {
- pr_debug("Cannot create kernel maps\n");
- return NULL;
- }
-
for (i = 0; i < ARRAY_SIZE(fake_threads); i++) {
struct thread *thread;
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-01-11 15:10 +0100 |
| Subject | [PATCH 15/53] perf tools: Fix symbols searching for offline module in buildid-cache |
| Message-ID | <qPLku-3rc-13@gated-at.bofh.it> |
| In reply to | #1306221 |
Before this patch, if a sample is triggered inside an offline module
(module not in /lib/modules/`uname -r`/), even if the module is in
buildid-cache, 'perf report' is still unable to get correct symbol.
For example:
# rm -rf ~/.debug/
# perf buildid-cache -a ./mymodule.ko
# perf probe -m ./mymodule.ko -a get_mymodule_val
Added new event:
probe:get_mymodule_val (on get_mymodule_val in mymodule)
You can now use it in all perf tools, such as:
perf record -e probe:get_mymodule_val -aR sleep 1
# perf record -e probe:get_mymodule_val cat /proc/mymodule
mymodule:3
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.011 MB perf.data (1 samples) ]
# perf report --stdio
[SNIP]
#
# Overhead Command Shared Object Symbol
# ........ ....... ................ ......................
#
100.00% cat [mymodule] [k] 0x0000000000000001
# perf report -vvvv --stdio
dso__load_sym: adjusting symbol: st_value: 0 sh_addr: 0 sh_offset: 0x70
symbol__new: get_mymodule_val 0x70-0x8a
[SNIP]
This is caused by dso__load() -> dso__load_sym(). In dso__load(), kmod
is true only when dso is regular kernel module. All files loaded from
buildid-cache is treated as user programs. Following dso__load_sym()
set map->pgoff incorrectly.
This patch gives kernel modules in buildid-cache a chance to adjust
value of kmod. After dso__load() get the type of symbols, if it is
buildid, check the last 3 chars of original filename against '.ko',
and adjust the value of kmod if the file is a kernel module.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
---
tools/perf/util/build-id.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/build-id.h | 1 +
tools/perf/util/symbol.c | 4 ++++
3 files changed, 49 insertions(+)
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 6a7e273..6b18082 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -166,6 +166,50 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size)
return build_id__filename(build_id_hex, bf, size);
}
+bool dso__build_id_is_kmod(const struct dso *dso, char *bf, size_t size)
+{
+ char *id_name, *ch;
+ struct stat sb;
+
+ id_name = dso__build_id_filename(dso, bf, size);
+ if (!id_name)
+ goto err;
+ if (access(id_name, F_OK))
+ goto err;
+ if (lstat(id_name, &sb) == -1)
+ goto err;
+ if ((size_t)sb.st_size > size - 1)
+ goto err;
+ if (readlink(id_name, bf, size - 1) < 0)
+ goto err;
+
+ bf[sb.st_size] = '\0';
+
+ /*
+ * link should be:
+ * ../../lib/modules/4.4.0-rc4/kernel/net/ipv4/netfilter/nf_nat_ipv4.ko/a09fe3eb3147dafa4e3b31dbd6257e4d696bdc92
+ */
+ ch = strrchr(bf, '/');
+ if (!ch)
+ goto err;
+ if (ch - 3 < bf)
+ goto err;
+
+ return strncmp(".ko", ch - 3, 3) == 0;
+err:
+ /*
+ * If dso__build_id_filename work, get id_name again,
+ * because id_name points to bf and is broken.
+ */
+ if (id_name)
+ id_name = dso__build_id_filename(dso, bf, size);
+ pr_err("Invalid build id: %s\n", id_name ? :
+ dso->long_name ? :
+ dso->short_name ? :
+ "[unknown]");
+ return false;
+}
+
#define dsos__for_each_with_build_id(pos, head) \
list_for_each_entry(pos, head, node) \
if (!pos->has_build_id) \
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index 27a14a8..64af3e2 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -16,6 +16,7 @@ int sysfs__sprintf_build_id(const char *root_dir, char *sbuild_id);
int filename__sprintf_build_id(const char *pathname, char *sbuild_id);
char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size);
+bool dso__build_id_is_kmod(const struct dso *dso, char *bf, size_t size);
int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event,
struct perf_sample *sample, struct perf_evsel *evsel,
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 3b2de6e..d78d105 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1525,6 +1525,10 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
if (!runtime_ss && syms_ss)
runtime_ss = syms_ss;
+ if (syms_ss && syms_ss->type == DSO_BINARY_TYPE__BUILD_ID_CACHE)
+ if (dso__build_id_is_kmod(dso, name, PATH_MAX))
+ kmod = true;
+
if (syms_ss)
ret = dso__load_sym(dso, map, syms_ss, runtime_ss, filter, kmod);
else
--
1.8.3.4
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-01-11 15:10 +0100 |
| Subject | [PATCH 06/53] perf tools: Fix PowerPC native building |
| Message-ID | <qPLku-3rc-19@gated-at.bofh.it> |
| In reply to | #1306221 |
Checks BPF syscall number, turn off libbpf building on platform doesn't
correctly support sys_bpf instead of blocking compiling.
Reported-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
tools/build/feature/test-bpf.c | 20 +++++++++++++++++++-
tools/lib/bpf/bpf.c | 4 ++--
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/tools/build/feature/test-bpf.c b/tools/build/feature/test-bpf.c
index 062bac8..b389026 100644
--- a/tools/build/feature/test-bpf.c
+++ b/tools/build/feature/test-bpf.c
@@ -1,9 +1,23 @@
+#include <asm/unistd.h>
#include <linux/bpf.h>
+#include <unistd.h>
+
+#ifndef __NR_bpf
+# if defined(__i386__)
+# define __NR_bpf 357
+# elif defined(__x86_64__)
+# define __NR_bpf 321
+# elif defined(__aarch64__)
+# define __NR_bpf 280
+# error __NR_bpf not defined. libbpf does not support your arch.
+# endif
+#endif
int main(void)
{
union bpf_attr attr;
+ /* Check fields in attr */
attr.prog_type = BPF_PROG_TYPE_KPROBE;
attr.insn_cnt = 0;
attr.insns = 0;
@@ -14,5 +28,9 @@ int main(void)
attr.kern_version = 0;
attr = attr;
- return 0;
+ /*
+ * Test existence of __NR_bpf and BPF_PROG_LOAD.
+ * This call should fail if we run the testcase.
+ */
+ return syscall(__NR_bpf, BPF_PROG_LOAD, attr, sizeof(attr));
}
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 5bdc6ea..1f91cc9 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -14,8 +14,8 @@
#include "bpf.h"
/*
- * When building perf, unistd.h is override. Define __NR_bpf is
- * required to be defined.
+ * When building perf, unistd.h is overrided. __NR_bpf is
+ * required to be defined explicitly.
*/
#ifndef __NR_bpf
# if defined(__i386__)
--
1.8.3.4
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Wang Nan <tipbot@zytor.com> |
|---|---|
| Date | 2016-01-12 11:20 +0100 |
| Subject | [tip:perf/urgent] perf tools: Fix PowerPC native building |
| Message-ID | <qQ4dt-7Y1-11@gated-at.bofh.it> |
| In reply to | #1306260 |
Commit-ID: 8f9e05fb298f16c0cda2e7e78b603331a79f9c10
Gitweb: http://git.kernel.org/tip/8f9e05fb298f16c0cda2e7e78b603331a79f9c10
Author: Wang Nan <wangnan0@huawei.com>
AuthorDate: Mon, 11 Jan 2016 13:47:57 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 11 Jan 2016 19:22:20 -0300
perf tools: Fix PowerPC native building
Checks BPF syscall number, turn off libbpf building on platform doesn't
correctly support sys_bpf instead of blocking compiling.
Reported-and-Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1452520124-2073-7-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/build/feature/test-bpf.c | 20 +++++++++++++++++++-
tools/lib/bpf/bpf.c | 4 ++--
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/tools/build/feature/test-bpf.c b/tools/build/feature/test-bpf.c
index 062bac8..b389026 100644
--- a/tools/build/feature/test-bpf.c
+++ b/tools/build/feature/test-bpf.c
@@ -1,9 +1,23 @@
+#include <asm/unistd.h>
#include <linux/bpf.h>
+#include <unistd.h>
+
+#ifndef __NR_bpf
+# if defined(__i386__)
+# define __NR_bpf 357
+# elif defined(__x86_64__)
+# define __NR_bpf 321
+# elif defined(__aarch64__)
+# define __NR_bpf 280
+# error __NR_bpf not defined. libbpf does not support your arch.
+# endif
+#endif
int main(void)
{
union bpf_attr attr;
+ /* Check fields in attr */
attr.prog_type = BPF_PROG_TYPE_KPROBE;
attr.insn_cnt = 0;
attr.insns = 0;
@@ -14,5 +28,9 @@ int main(void)
attr.kern_version = 0;
attr = attr;
- return 0;
+ /*
+ * Test existence of __NR_bpf and BPF_PROG_LOAD.
+ * This call should fail if we run the testcase.
+ */
+ return syscall(__NR_bpf, BPF_PROG_LOAD, attr, sizeof(attr));
}
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 5bdc6ea..1f91cc9 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -14,8 +14,8 @@
#include "bpf.h"
/*
- * When building perf, unistd.h is override. Define __NR_bpf is
- * required to be defined.
+ * When building perf, unistd.h is overrided. __NR_bpf is
+ * required to be defined explicitly.
*/
#ifndef __NR_bpf
# if defined(__i386__)
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-01-11 15:10 +0100 |
| Subject | [PATCH 23/53] perf tools: Support setting different slots in a BPF map separately |
| Message-ID | <qPLkv-3rc-23@gated-at.bofh.it> |
| In reply to | #1306221 |
This patch introduces basic facilities to support config different
slots in a BPF map one by one.
array.nr_ranges and array.ranges are introduced into 'struct
parse_events_term', where ranges is an array of indices range (start,
length) which will be configured by this config term. nr_ranges
is the size of the array. The array is passed to 'struct bpf_map_priv'.
To indicate the new type of configuration, BPF_MAP_KEY_RANGES is
added as a new key type. bpf_map_config_foreach_key() is extended to
iterate over those indices instead of all possible keys.
Code in this commit will be enabled by following commit which enables
the indices syntax for array configuration.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
tools/perf/util/bpf-loader.c | 132 ++++++++++++++++++++++++++++++++++++++---
tools/perf/util/bpf-loader.h | 1 +
tools/perf/util/parse-events.c | 33 ++++++++++-
tools/perf/util/parse-events.h | 12 ++++
4 files changed, 170 insertions(+), 8 deletions(-)
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 2893b4e..6c25de8 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -17,6 +17,7 @@
#include "llvm-utils.h"
#include "probe-event.h"
#include "probe-finder.h" // for MAX_PROBES
+#include "parse-events.h"
#include "llvm-utils.h"
#define DEFINE_PRINT_FN(name, level) \
@@ -747,6 +748,7 @@ enum bpf_map_op_type {
enum bpf_map_key_type {
BPF_MAP_KEY_ALL,
+ BPF_MAP_KEY_RANGES,
};
struct bpf_map_op {
@@ -754,6 +756,9 @@ struct bpf_map_op {
enum bpf_map_op_type op_type;
enum bpf_map_key_type key_type;
union {
+ struct parse_events_array array;
+ } k;
+ union {
u64 value;
struct perf_evsel *evsel;
} v;
@@ -779,6 +784,8 @@ bpf_map_op__free(struct bpf_map_op *op)
*/
if ((list->next != LIST_POISON1) && (list->prev != LIST_POISON2))
list_del(list);
+ if (op->key_type == BPF_MAP_KEY_RANGES)
+ parse_events__clear_array(&op->k.array);
free(op);
}
@@ -794,8 +801,30 @@ bpf_map_priv__clear(struct bpf_map *map __maybe_unused,
free(priv);
}
+static int
+bpf_map_op_setkey(struct bpf_map_op *op, struct parse_events_term *term,
+ const char *map_name)
+{
+ op->key_type = BPF_MAP_KEY_ALL;
+
+ if (term->array.nr_ranges) {
+ size_t memsz = term->array.nr_ranges *
+ sizeof(op->k.array.ranges[0]);
+
+ op->k.array.ranges = memdup(term->array.ranges, memsz);
+ if (!op->k.array.ranges) {
+ pr_debug("No enough memory to alloc indices for %s\n",
+ map_name);
+ return -ENOMEM;
+ }
+ op->key_type = BPF_MAP_KEY_RANGES;
+ op->k.array.nr_ranges = term->array.nr_ranges;
+ }
+ return 0;
+}
+
static struct bpf_map_op *
-bpf_map_op__alloc(struct bpf_map *map)
+bpf_map_op__alloc(struct bpf_map *map, struct parse_events_term *term)
{
struct bpf_map_op *op;
struct bpf_map_priv *priv;
@@ -829,7 +858,12 @@ bpf_map_op__alloc(struct bpf_map *map)
return ERR_PTR(-ENOMEM);
}
- op->key_type = BPF_MAP_KEY_ALL;
+ err = bpf_map_op_setkey(op, term, map_name);
+ if (err) {
+ free(op);
+ return ERR_PTR(err);
+ }
+
list_add_tail(&op->list, &priv->ops_list);
return op;
}
@@ -872,7 +906,7 @@ bpf__obj_config_map_array_value(struct bpf_map *map,
return -BPF_LOADER_ERRNO__OBJCONF_MAP_VALUESIZE;
}
- op = bpf_map_op__alloc(map);
+ op = bpf_map_op__alloc(map, term);
if (IS_ERR(op))
return PTR_ERR(op);
op->op_type = BPF_MAP_OP_SET_VALUE;
@@ -933,7 +967,7 @@ bpf__obj_config_map_array_event(struct bpf_map *map,
return -BPF_LOADER_ERRNO__OBJCONF_MAP_TYPE;
}
- op = bpf_map_op__alloc(map);
+ op = bpf_map_op__alloc(map, term);
if (IS_ERR(op))
return PTR_ERR(op);
@@ -972,6 +1006,44 @@ struct bpf_obj_config_map_func bpf_obj_config_map_funcs[] = {
};
static int
+config_map_indices_range_check(struct parse_events_term *term,
+ struct bpf_map *map,
+ const char *map_name)
+{
+ struct parse_events_array *array = &term->array;
+ struct bpf_map_def def;
+ unsigned int i;
+ int err;
+
+ if (!array->nr_ranges)
+ return 0;
+ if (!array->ranges) {
+ pr_debug("ERROR: map %s: array->nr_ranges is %d but range array is NULL\n",
+ map_name, (int)array->nr_ranges);
+ return -BPF_LOADER_ERRNO__INTERNAL;
+ }
+
+ err = bpf_map__get_def(map, &def);
+ if (err) {
+ pr_debug("ERROR: Unable to get map definition from '%s'\n",
+ map_name);
+ return -BPF_LOADER_ERRNO__INTERNAL;
+ }
+
+ for (i = 0; i < array->nr_ranges; i++) {
+ unsigned int start = array->ranges[i].start;
+ size_t length = array->ranges[i].length;
+ unsigned int idx = start + length - 1;
+
+ if (idx >= def.max_entries) {
+ pr_debug("ERROR: index %d too large\n", idx);
+ return -BPF_LOADER_ERRNO__OBJCONF_MAP_IDX2BIG;
+ }
+ }
+ return 0;
+}
+
+static int
bpf__obj_config_map(struct bpf_object *obj,
struct parse_events_term *term,
struct perf_evlist *evlist,
@@ -1007,6 +1079,13 @@ bpf__obj_config_map(struct bpf_object *obj,
}
*key_scan_pos += map_opt - map_name;
+
+ *key_scan_pos += strlen(map_opt);
+ err = config_map_indices_range_check(term, map, map_name);
+ if (err)
+ goto out;
+ *key_scan_pos -= strlen(map_opt);
+
for (i = 0; i < ARRAY_SIZE(bpf_obj_config_map_funcs); i++) {
struct bpf_obj_config_map_func *func =
&bpf_obj_config_map_funcs[i];
@@ -1077,6 +1156,33 @@ foreach_key_array_all(map_config_func_t func,
}
static int
+foreach_key_array_ranges(map_config_func_t func, void *arg,
+ const char *name, int map_fd,
+ struct bpf_map_def *pdef,
+ struct bpf_map_op *op)
+{
+ unsigned int i, j;
+ int err;
+
+ for (i = 0; i < op->k.array.nr_ranges; i++) {
+ unsigned int start = op->k.array.ranges[i].start;
+ size_t length = op->k.array.ranges[i].length;
+
+ for (j = 0; j < length; j++) {
+ unsigned int idx = start + j;
+
+ err = func(name, map_fd, pdef, op, &idx, arg);
+ if (err) {
+ pr_debug("ERROR: failed to insert value to %s[%u]\n",
+ name, idx);
+ return err;
+ }
+ }
+ }
+ return 0;
+}
+
+static int
bpf_map_config_foreach_key(struct bpf_map *map,
map_config_func_t func,
void *arg)
@@ -1116,13 +1222,24 @@ bpf_map_config_foreach_key(struct bpf_map *map,
case BPF_MAP_TYPE_PERF_EVENT_ARRAY:
switch (op->key_type) {
case BPF_MAP_KEY_ALL:
- return foreach_key_array_all(func, arg, name,
- map_fd, &def, op);
+ err = foreach_key_array_all(func, arg, name,
+ map_fd, &def, op);
+ if (err)
+ return err;
+ break;
+ case BPF_MAP_KEY_RANGES:
+ err = foreach_key_array_ranges(func, arg, name,
+ map_fd, &def,
+ op);
+ if (err)
+ return err;
+ break;
default:
pr_debug("ERROR: keytype for map '%s' invalid\n",
name);
return -BPF_LOADER_ERRNO__INTERNAL;
- }
+ }
+ break;
default:
pr_debug("ERROR: type of '%s' incorrect\n", name);
return -BPF_LOADER_ERRNO__OBJCONF_MAP_TYPE;
@@ -1309,6 +1426,7 @@ static const char *bpf_loader_strerror_table[NR_ERRNO] = {
[ERRCODE_OFFSET(OBJCONF_MAP_EVTDIM)] = "Event dimension too large",
[ERRCODE_OFFSET(OBJCONF_MAP_EVTINH)] = "Doesn't support inherit event",
[ERRCODE_OFFSET(OBJCONF_MAP_EVTTYPE)] = "Wrong event type for map",
+ [ERRCODE_OFFSET(OBJCONF_MAP_IDX2BIG)] = "Index too large",
};
static int
diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h
index c9ce792..30ee519 100644
--- a/tools/perf/util/bpf-loader.h
+++ b/tools/perf/util/bpf-loader.h
@@ -38,6 +38,7 @@ enum bpf_loader_errno {
BPF_LOADER_ERRNO__OBJCONF_MAP_EVTDIM, /* Event dimension too large */
BPF_LOADER_ERRNO__OBJCONF_MAP_EVTINH, /* Doesn't support inherit event */
BPF_LOADER_ERRNO__OBJCONF_MAP_EVTTYPE, /* Wrong event type for map */
+ BPF_LOADER_ERRNO__OBJCONF_MAP_IDX2BIG, /* Index too large */
__BPF_LOADER_ERRNO__END,
};
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 1e0ac77..f229663 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2148,8 +2148,39 @@ void parse_events__free_terms(struct list_head *terms)
{
struct parse_events_term *term, *h;
- list_for_each_entry_safe(term, h, terms, list)
+ list_for_each_entry_safe(term, h, terms, list) {
+ if (term->array.nr_ranges)
+ free(term->array.ranges);
free(term);
+ }
+}
+
+int parse_events__merge_arrays(struct parse_events_array *dest,
+ struct parse_events_array *another)
+{
+ struct parse_events_array new;
+
+ if (!dest || !another)
+ return -EINVAL;
+
+ new.nr_ranges = dest->nr_ranges + another->nr_ranges;
+ new.ranges = malloc(sizeof(new.ranges[0]) * new.nr_ranges);
+ if (!new.ranges)
+ return -ENOMEM;
+
+ memcpy(&new.ranges[0], dest->ranges,
+ sizeof(new.ranges[0]) * dest->nr_ranges);
+ memcpy(&new.ranges[dest->nr_ranges], another->ranges,
+ sizeof(new.ranges[0]) * another->nr_ranges);
+ free(dest->ranges);
+ free(another->ranges);
+ *dest = new;
+ return 0;
+}
+
+void parse_events__clear_array(struct parse_events_array *a)
+{
+ free(a->ranges);
}
void parse_events_evlist_error(struct parse_events_evlist *data,
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 20ad3c2..c34615f 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -71,8 +71,17 @@ enum {
PARSE_EVENTS__TERM_TYPE_INHERIT
};
+struct parse_events_array {
+ size_t nr_ranges;
+ struct {
+ unsigned int start;
+ size_t length;
+ } *ranges;
+};
+
struct parse_events_term {
char *config;
+ struct parse_events_array array;
union {
char *str;
u64 num;
@@ -117,6 +126,9 @@ int parse_events_term__sym_hw(struct parse_events_term **term,
int parse_events_term__clone(struct parse_events_term **new,
struct parse_events_term *term);
void parse_events__free_terms(struct list_head *terms);
+int parse_events__merge_arrays(struct parse_events_array *dest,
+ struct parse_events_array *another);
+void parse_events__clear_array(struct parse_events_array *a);
int parse_events__modifier_event(struct list_head *list, char *str, bool add);
int parse_events__modifier_group(struct list_head *list, char *event_mod);
int parse_events_name(struct list_head *list, char *name);
--
1.8.3.4
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-01-11 15:10 +0100 |
| Subject | [PATCH 02/53] perf tools: Fix phony build target for build-test |
| Message-ID | <qPLkv-3rc-21@gated-at.bofh.it> |
| In reply to | #1306221 |
make_kernelsrc and make_kernelsrc_tools are skiped if a previous build-test is done, because 'make build-test' creates two files with same names. To avoid this, they should be included in .PHONY list. Signed-off-by: Wang Nan <wangnan0@huawei.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> --- tools/perf/tests/make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/tests/make b/tools/perf/tests/make index c1fbb8e..130be7c 100644 --- a/tools/perf/tests/make +++ b/tools/perf/tests/make @@ -280,5 +280,5 @@ all: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools out: $(run_O) @echo OK -.PHONY: all $(run) $(run_O) tarpkg clean +.PHONY: all $(run) $(run_O) tarpkg clean make_kernelsrc make_kernelsrc_tools endif # ifndef MK -- 1.8.3.4
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Wang Nan <tipbot@zytor.com> |
|---|---|
| Date | 2016-01-12 11:20 +0100 |
| Subject | [tip:perf/urgent] perf tools: Fix phony build target for build-test |
| Message-ID | <qQ4du-7Y1-25@gated-at.bofh.it> |
| In reply to | #1306262 |
Commit-ID: 3167eea27b27b29d375ee6b34dd83035c04d5da8 Gitweb: http://git.kernel.org/tip/3167eea27b27b29d375ee6b34dd83035c04d5da8 Author: Wang Nan <wangnan0@huawei.com> AuthorDate: Mon, 11 Jan 2016 13:47:53 +0000 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Mon, 11 Jan 2016 19:03:24 -0300 perf tools: Fix phony build target for build-test make_kernelsrc and make_kernelsrc_tools are skiped if a previous build-test is done, because 'make build-test' creates two files with same names. To avoid this, they should be included in .PHONY list. Signed-off-by: Wang Nan <wangnan0@huawei.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Zefan Li <lizefan@huawei.com> Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1452520124-2073-3-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/tests/make | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/tests/make b/tools/perf/tests/make index c1fbb8e..130be7c 100644 --- a/tools/perf/tests/make +++ b/tools/perf/tests/make @@ -280,5 +280,5 @@ all: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools out: $(run_O) @echo OK -.PHONY: all $(run) $(run_O) tarpkg clean +.PHONY: all $(run) $(run_O) tarpkg clean make_kernelsrc make_kernelsrc_tools endif # ifndef MK
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-01-11 15:10 +0100 |
| Subject | [PATCH 19/53] perf tools: Enable BPF object configure syntax |
| Message-ID | <qPLkv-3rc-25@gated-at.bofh.it> |
| In reply to | #1306221 |
This patch adds the final step for BPF map configuration. A new syntax
is appended into parser so user can config BPF objects through '/' '/'
enclosed config terms.
After this patch, following syntax is available:
# perf record -e ./test_bpf_map_1.c/maps:channel.value=10/ ...
It would takes effect after appling following commits.
Test result:
# cat ./test_bpf_map_1.c
/************************ BEGIN **************************/
#include <uapi/linux/bpf.h>
#define SEC(NAME) __attribute__((section(NAME), used))
struct bpf_map_def {
unsigned int type;
unsigned int key_size;
unsigned int value_size;
unsigned int max_entries;
};
static void *(*map_lookup_elem)(struct bpf_map_def *, void *) =
(void *)BPF_FUNC_map_lookup_elem;
static int (*trace_printk)(const char *fmt, int fmt_size, ...) =
(void *)BPF_FUNC_trace_printk;
struct bpf_map_def SEC("maps") channel = {
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(int),
.value_size = sizeof(int),
.max_entries = 1,
};
SEC("func=sys_nanosleep")
int func(void *ctx)
{
int key = 0;
char fmt[] = "%d\n";
int *pval = map_lookup_elem(&channel, &key);
if (!pval)
return 0;
trace_printk(fmt, sizeof(fmt), *pval);
return 0;
}
char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
/************************* END ***************************/
- Normal case:
# ./perf record -e './test_bpf_map_1.c/maps:channel.value=10/' usleep 10
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.012 MB perf.data ]
- Error case:
# ./perf record -e './test_bpf_map_1.c/maps:channel.value/' usleep 10
event syntax error: '..ps:channel:value/'
\___ Config value not set (lost '=')
Hint: Valid config term:
maps:[<arraymap>]:value=[value]
(add -v to see detail)
Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
# ./perf record -e './test_bpf_map_1.c/xmaps:channel.value=10/' usleep 10
event syntax error: '..pf_map_1.c/xmaps:channel.value=10/'
\___ Invalid object config option
[SNIP]
# ./perf record -e './test_bpf_map_1.c/maps:xchannel.value=10/' usleep 10
event syntax error: '..p_1.c/maps:xchannel.value=10/'
\___ Target map not exist
[SNIP]
# ./perf record -e './test_bpf_map_1.c/maps:channel.xvalue=10/' usleep 10
event syntax error: '..ps:channel.xvalue=10/'
\___ Invalid object maps config option
[SNIP]
# ./perf record -e './test_bpf_map_1.c/maps:channel.value=x10/' usleep 10
event syntax error: '..nnel.value=x10/'
\___ Incorrect value type for map
[SNIP]
Change BPF_MAP_TYPE_ARRAY to '1':
# ./perf record -e './test_bpf_map_1.c/maps:channel.value=10/' usleep 10
event syntax error: '..ps:channel.value=10/'
\___ Can't use this config term to this type of map
Hint: Valid config term:
maps:[<arraymap>].value=[value]
(add -v to see detail)
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
tools/perf/util/parse-events.c | 56 +++++++++++++++++++++++++++++++++++++++---
tools/perf/util/parse-events.h | 3 ++-
tools/perf/util/parse-events.l | 2 +-
tools/perf/util/parse-events.y | 23 ++++++++++++++---
4 files changed, 75 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 4f7b0ef..1c2dc5d 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -628,17 +628,64 @@ errout:
return err;
}
+static int
+parse_events_config_bpf(struct parse_events_evlist *data,
+ struct bpf_object *obj,
+ struct list_head *head_config)
+{
+ struct parse_events_term *term;
+ int error_pos;
+
+ if (!head_config || list_empty(head_config))
+ return 0;
+
+ list_for_each_entry(term, head_config, list) {
+ char errbuf[BUFSIZ];
+ int err;
+
+ if (term->type_term != PARSE_EVENTS__TERM_TYPE_USER) {
+ snprintf(errbuf, sizeof(errbuf),
+ "Invalid config term for BPF object");
+ errbuf[BUFSIZ - 1] = '\0';
+
+ data->error->idx = term->err_term;
+ data->error->str = strdup(errbuf);
+ return -EINVAL;
+ }
+
+ err = bpf__config_obj(obj, term, NULL, &error_pos);
+ if (err) {
+ bpf__strerror_config_obj(obj, term, NULL,
+ &error_pos, err, errbuf,
+ sizeof(errbuf));
+ data->error->help = strdup(
+"Hint:\tValid config term:\n"
+" \tmaps:[<arraymap>].value=[value]\n"
+" \t(add -v to see detail)");
+ data->error->str = strdup(errbuf);
+ if (err == -BPF_LOADER_ERRNO__OBJCONF_MAP_VALUE)
+ data->error->idx = term->err_val;
+ else
+ data->error->idx = term->err_term + error_pos;
+ return err;
+ }
+ }
+ return 0;
+
+}
+
int parse_events_load_bpf(struct parse_events_evlist *data,
struct list_head *list,
char *bpf_file_name,
- bool source)
+ bool source,
+ struct list_head *head_config)
{
struct bpf_object *obj;
+ int err;
obj = bpf__prepare_load(bpf_file_name, source);
if (IS_ERR(obj)) {
char errbuf[BUFSIZ];
- int err;
err = PTR_ERR(obj);
@@ -656,7 +703,10 @@ int parse_events_load_bpf(struct parse_events_evlist *data,
return err;
}
- return parse_events_load_bpf_obj(data, list, obj);
+ err = parse_events_load_bpf_obj(data, list, obj);
+ if (err)
+ return err;
+ return parse_events_config_bpf(data, obj, head_config);
}
static int
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index f1a6db1..84694f3 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -126,7 +126,8 @@ int parse_events_add_tracepoint(struct list_head *list, int *idx,
int parse_events_load_bpf(struct parse_events_evlist *data,
struct list_head *list,
char *bpf_file_name,
- bool source);
+ bool source,
+ struct list_head *head_config);
/* Provide this function for perf test */
struct bpf_object;
int parse_events_load_bpf_obj(struct parse_events_evlist *data,
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 58c5831..4387728 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -122,7 +122,7 @@ num_dec [0-9]+
num_hex 0x[a-fA-F0-9]+
num_raw_hex [a-fA-F0-9]+
name [a-zA-Z_*?][a-zA-Z0-9_*?.]*
-name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.]*
+name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
/* If you add a modifier you need to update check_modifier() */
modifier_event [ukhpPGHSDI]+
modifier_bp [rwx]{1,3}
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index ad37996..8992d16 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -64,6 +64,7 @@ static inc_group_count(struct list_head *list,
%type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT
%type <num> value_sym
%type <head> event_config
+%type <head> event_bpf_config
%type <term> event_term
%type <head> event_pmu
%type <head> event_legacy_symbol
@@ -455,27 +456,41 @@ PE_RAW
}
event_bpf_file:
-PE_BPF_OBJECT
+PE_BPF_OBJECT event_bpf_config
{
struct parse_events_evlist *data = _data;
struct parse_events_error *error = data->error;
struct list_head *list;
ALLOC_LIST(list);
- ABORT_ON(parse_events_load_bpf(data, list, $1, false));
+ ABORT_ON(parse_events_load_bpf(data, list, $1, false, $2));
+ if ($2)
+ parse_events__free_terms($2);
$$ = list;
}
|
-PE_BPF_SOURCE
+PE_BPF_SOURCE event_bpf_config
{
struct parse_events_evlist *data = _data;
struct list_head *list;
ALLOC_LIST(list);
- ABORT_ON(parse_events_load_bpf(data, list, $1, true));
+ ABORT_ON(parse_events_load_bpf(data, list, $1, true, $2));
+ if ($2)
+ parse_events__free_terms($2);
$$ = list;
}
+event_bpf_config:
+'/' event_config '/'
+{
+ $$ = $2;
+}
+|
+{
+ $$ = NULL;
+}
+
start_terms: event_config
{
struct parse_events_terms *data = _data;
--
1.8.3.4
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-01-11 15:10 +0100 |
| Subject | [PATCH 05/53] perf tools: Test correct path of perf in build-test |
| Message-ID | <qPLkv-3rc-31@gated-at.bofh.it> |
| In reply to | #1306221 |
If an 'O' is passed to 'make build-test', many 'test -x' and 'test -f'
will fail because perf resides in a different directory. Fix this by
computing PERF_OUT according to 'O' and test correct output files.
For make_kernelsrc and make_kernelsrc_tools, set KBUILD_OUTPUT_DIR
instead because the path is different from others ($(O)/perf vs
$(O)/tools/perf).
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/make | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index a32615a3..0f5afcb 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -11,10 +11,12 @@ else
endif
else
PERF := .
+PERF_OUT := $(PERF)
O_OPT :=
ifneq ($(O),)
FULL_O := $(shell readlink -f $(O) || echo $(O))
+ PERF_OUT := $(FULL_O)
ifeq ($(SET_O),1)
O_OPT := 'O=$(FULL_O)'
endif
@@ -159,11 +161,11 @@ test_make_doc := $(test_ok)
test_make_help_O := $(test_ok)
test_make_doc_O := $(test_ok)
-test_make_python_perf_so := test -f $(PERF)/python/perf.so
+test_make_python_perf_so := test -f $(PERF_OUT)/python/perf.so
-test_make_perf_o := test -f $(PERF)/perf.o
-test_make_util_map_o := test -f $(PERF)/util/map.o
-test_make_util_pmu_bison_o := test -f $(PERF)/util/pmu-bison.o
+test_make_perf_o := test -f $(PERF_OUT)/perf.o
+test_make_util_map_o := test -f $(PERF_OUT)/util/map.o
+test_make_util_pmu_bison_o := test -f $(PERF_OUT)/util/pmu-bison.o
define test_dest_files
for file in $(1); do \
@@ -230,7 +232,7 @@ test_make_perf_o_O := test -f $$TMP_O/perf.o
test_make_util_map_o_O := test -f $$TMP_O/util/map.o
test_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o
-test_default = test -x $(PERF)/perf
+test_default = test -x $(PERF_OUT)/perf
test = $(if $(test_$1),$(test_$1),$(test_default))
test_default_O = test -x $$TMP_O/perf
@@ -250,7 +252,7 @@ endif
MAKEFLAGS := --no-print-directory
-clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
+clean := @(cd $(PERF); make -s -f $(MK) O=$(PERF_OUT) clean >/dev/null; make -s -f $(MK) clean >/dev/null)
$(run):
$(call clean)
@@ -279,17 +281,22 @@ tarpkg:
( eval $$cmd ) >> $@ 2>&1 && \
rm -f $@
+KBUILD_OUTPUT_DIR := ../..
+ifneq ($(O),)
+ KBUILD_OUTPUT_DIR := $(O)
+endif
+
make_kernelsrc:
@echo "- make -C <kernelsrc> $(PARALLEL_OPT) tools/perf"
$(call clean); \
(make -C ../.. $(PARALLEL_OPT) tools/perf) > $@ 2>&1 && \
- test -x perf && rm -f $@ || (cat $@ ; false)
+ test -x $(KBUILD_OUTPUT_DIR)/tools/perf && rm -f $@ || (cat $@ ; false)
make_kernelsrc_tools:
@echo "- make -C <kernelsrc>/tools $(PARALLEL_OPT) perf"
$(call clean); \
(make -C ../../tools $(PARALLEL_OPT) perf) > $@ 2>&1 && \
- test -x perf && rm -f $@ || (cat $@ ; false)
+ test -x $(KBUILD_OUTPUT_DIR)/tools/perf && rm -f $@ || (cat $@ ; false)
all: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools
@echo OK
--
1.8.3.4
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-01-11 16:30 +0100 |
| Subject | Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test |
| Message-ID | <qPMzV-4ae-57@gated-at.bofh.it> |
| In reply to | #1306265 |
Em Mon, Jan 11, 2016 at 01:47:56PM +0000, Wang Nan escreveu: > If an 'O' is passed to 'make build-test', many 'test -x' and 'test -f' > will fail because perf resides in a different directory. Fix this by > computing PERF_OUT according to 'O' and test correct output files. > For make_kernelsrc and make_kernelsrc_tools, set KBUILD_OUTPUT_DIR > instead because the path is different from others ($(O)/perf vs > $(O)/tools/perf). Ok, applying up to this patch I now manage to almost cleanly build it using O=, see below, but seems that we have some race, as not all tests end up producing such warnings. [acme@felicio linux]$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ; make O=/tmp/build/perf -C tools/perf build-test make: Entering directory `/home/acme/git/linux/tools/perf' Testing Makefile - make_no_libperl: cd . && make -f Makefile DESTDIR=/tmp/tmp.m1nXBMqhSA NO_LIBPERL=1 find: ‘/tmp/build/perf/util/trace-event-scripting.o’: No such file or directory find: ‘/tmp/build/perf/util/build-id.o’: No such file or directory - make_no_libdw_dwarf_unwind: cd . && make -f Makefile DESTDIR=/tmp/tmp.RB7Ile9C0b NO_LIBDW_DWARF_UNWIND=1 - make_no_backtrace: cd . && make -f Makefile DESTDIR=/tmp/tmp.HeNpC0PW1O NO_BACKTRACE=1 find: ‘/tmp/build/perf/util/trace-event-scripting.o’: No such file or directory find: ‘/tmp/build/perf/util/alias.o’: No such file or directory - make_install_prefix: cd . && make -f Makefile DESTDIR=/tmp/tmp.JPK5a72h53 install prefix=/tmp/krava find: ‘/tmp/build/perf/libapi.a’: No such file or directory - make_help: cd . && make -f Makefile DESTDIR=/tmp/tmp.F3Z0qPtslS help - make_doc: cd . && make -f Makefile DESTDIR=/tmp/tmp.6a2HbvC2ej doc
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-01-11 23:10 +0100 |
| Subject | Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test |
| Message-ID | <qPSP1-7w-43@gated-at.bofh.it> |
| In reply to | #1306410 |
Em Mon, Jan 11, 2016 at 12:24:56PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Mon, Jan 11, 2016 at 01:47:56PM +0000, Wang Nan escreveu: > > If an 'O' is passed to 'make build-test', many 'test -x' and 'test -f' > > will fail because perf resides in a different directory. Fix this by > > computing PERF_OUT according to 'O' and test correct output files. > > For make_kernelsrc and make_kernelsrc_tools, set KBUILD_OUTPUT_DIR > > instead because the path is different from others ($(O)/perf vs > > $(O)/tools/perf). > > Ok, applying up to this patch I now manage to almost cleanly build it using O=, > see below, but seems that we have some race, as not all tests end up producing > such warnings. > > [acme@felicio linux]$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ; make O=/tmp/build/perf -C tools/perf build-test > make: Entering directory `/home/acme/git/linux/tools/perf' > Testing Makefile > - make_no_libperl: cd . && make -f Makefile DESTDIR=/tmp/tmp.m1nXBMqhSA NO_LIBPERL=1 > find: ‘/tmp/build/perf/util/trace-event-scripting.o’: No such file or directory Well, it is happening even without O=: [acme@felicio linux]$ perf stat make -C tools/perf build-test make: Entering directory `/home/acme/git/linux/tools/perf' Testing Makefile - make_doc: cd . && make -f Makefile DESTDIR=/tmp/tmp.H8z3S3cEJ0 doc - make_install_bin: cd . && make -f Makefile DESTDIR=/tmp/tmp.njIAPXMF7f install-bin - make_install_prefix: cd . && make -f Makefile DESTDIR=/tmp/tmp.9FEKGBoeyN install prefix=/tmp/krava - make_no_gtk2: cd . && make -f Makefile DESTDIR=/tmp/tmp.nHl593wfMP NO_GTK2=1 - make_util_map_o: cd . && make -f Makefile DESTDIR=/tmp/tmp.ZSmZP490hX util/map.o - make_no_slang: cd . && make -f Makefile DESTDIR=/tmp/tmp.7q24C1xmcu NO_SLANG=1 - make_pure: cd . && make -f Makefile DESTDIR=/tmp/tmp.R51cy8kdWl - make_no_libpython: cd . && make -f Makefile DESTDIR=/tmp/tmp.3t9tEc0e4b NO_LIBPYTHON=1 - make_no_libbionic: cd . && make -f Makefile DESTDIR=/tmp/tmp.4yYelFUaq0 NO_LIBBIONIC=1 - make_no_newt: cd . && make -f Makefile DESTDIR=/tmp/tmp.3Fg7hv3Hn1 NO_NEWT=1 - make_tags: cd . && make -f Makefile DESTDIR=/tmp/tmp.8WMgskFkOH tags - make_install: cd . && make -f Makefile DESTDIR=/tmp/tmp.YQq3wOEkyB install - make_no_libdw_dwarf_unwind: cd . && make -f Makefile DESTDIR=/tmp/tmp.WKRVFDA2ty NO_LIBDW_DWARF_UNWIND=1 find: ‘/home/acme/git/linux/tools/perf/.gtk-in.o.cmd’: No such file or directory find: ‘/home/acme/git/linux/tools/perf/builtin-script.o’: No such file or directory - make_no_libunwind: cd . && make -f Makefile DESTDIR=/tmp/tmp.SQftzGTUYf NO_LIBUNWIND=1 - make_no_auxtrace: cd . && make -f Makefile DESTDIR=/tmp/tmp.Xy2xrSCVuO NO_AUXTRACE=1 - make_no_ui: cd . && make -f Makefile DESTDIR=/tmp/tmp.ZFNEHWqQFN NO_NEWT=1 NO_SLANG=1 NO_GTK2=1 - make_no_libnuma: cd . && make -f Makefile DESTDIR=/tmp/tmp.68zRtMaEqf NO_LIBNUMA=1 - make_no_backtrace: cd . && make -f Makefile DESTDIR=/tmp/tmp.5xcea8XfdC NO_BACKTRACE=1 find: ‘/home/acme/git/linux/tools/perf/arch/x86/tests/dwarf-unwind.o’: No such file or directory - make_install_prefix_slash: cd . && make -f Makefile DESTDIR=/tmp/tmp.2c5BqUKGef install prefix=/tmp/krava/ find: ‘/home/acme/git/linux/tools/perf/builtin-record.o’: No such file or directory find: ‘/home/acme/git/linux/tools/perf/builtin-inject.o’: No such file or directory find: ‘/home/acme/git/linux/tools/perf/builtin-bench.o’: No such file or directory find: ‘/home/acme/git/linux/tools/perf/.builtin-lock.o.cmd’: No such file or directory find: ‘/home/acme/git/linux/tools/perf/perf.o’: No such file or directory find: ‘/home/acme/git/linux/tools/perf/scripts/.libperf-in.o.cmd’: No such file or directory find: ‘/home/acme/git/linux/tools/perf/tests/evsel-tp-sched.o’: No such file or directory find: ‘/home/acme/git/linux/tools/perf/tests/hists_cumulate.o’: No such file or directory - make_util_pmu_bison_o: cd . && make -f Makefile DESTDIR=/tmp/tmp.aJUWyFbXsp util/pmu-bis
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-01-11 23:40 +0100 |
| Subject | Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test |
| Message-ID | <qPTi2-n6-21@gated-at.bofh.it> |
| In reply to | #1306762 |
Em Mon, Jan 11, 2016 at 07:06:18PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Mon, Jan 11, 2016 at 12:24:56PM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Mon, Jan 11, 2016 at 01:47:56PM +0000, Wang Nan escreveu: > > > If an 'O' is passed to 'make build-test', many 'test -x' and 'test -f' > > > will fail because perf resides in a different directory. Fix this by > > > computing PERF_OUT according to 'O' and test correct output files. > > > For make_kernelsrc and make_kernelsrc_tools, set KBUILD_OUTPUT_DIR > > > instead because the path is different from others ($(O)/perf vs > > > $(O)/tools/perf). > > > > Ok, applying up to this patch I now manage to almost cleanly build it using O=, > > see below, but seems that we have some race, as not all tests end up producing > > such warnings. > > > > [acme@felicio linux]$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ; make O=/tmp/build/perf -C tools/perf build-test > > make: Entering directory `/home/acme/git/linux/tools/perf' > > Testing Makefile > > - make_no_libperl: cd . && make -f Makefile DESTDIR=/tmp/tmp.m1nXBMqhSA NO_LIBPERL=1 > > find: ‘/tmp/build/perf/util/trace-event-scripting.o’: No such file or directory > > Well, it is happening even without O=: So I removed a few patches and those aren't appearing anymore, please take a look at my perf/core branch, running build-test on a few machines now, will push soon. My hunch is that build-test has issues with parallel builds, but I'm not sure... - Arnaldo > > [acme@felicio linux]$ perf stat make -C tools/perf build-test > make: Entering directory `/home/acme/git/linux/tools/perf' > Testing Makefile > - make_doc: cd . && make -f Makefile DESTDIR=/tmp/tmp.H8z3S3cEJ0 doc > - make_install_bin: cd . && make -f Makefile DESTDIR=/tmp/tmp.njIAPXMF7f install-bin > - make_install_prefix: cd . && make -f Makefile DESTDIR=/tmp/tmp.9FEKGBoeyN install prefix=/tmp/krava > - make_no_gtk2: cd . && make -f Makefile DESTDIR=/tmp/tmp.nHl593wfMP NO_GTK2=1 > - make_util_map_o: cd . && make -f Makefile DESTDIR=/tmp/tmp.ZSmZP490hX util/map.o > - make_no_slang: cd . && make -f Makefile DESTDIR=/tmp/tmp.7q24C1xmcu NO_SLANG=1 > - make_pure: cd . && make -f Makefile DESTDIR=/tmp/tmp.R51cy8kdWl > - make_no_libpython: cd . && make -f Makefile DESTDIR=/tmp/tmp.3t9tEc0e4b NO_LIBPYTHON=1 > - make_no_libbionic: cd . && make -f Makefile DESTDIR=/tmp/tmp.4yYelFUaq0 NO_LIBBIONIC=1 > - make_no_newt: cd . && make -f Makefile DESTDIR=/tmp/tmp.3Fg7hv3Hn1 NO_NEWT=1 > - make_tags: cd . && make -f Makefile DESTDIR=/tmp/tmp.8WMgskFkOH tags > - make_install: cd . && make -f Makefile DESTDIR=/tmp/tmp.YQq3wOEkyB install > - make_no_libdw_dwarf_unwind: cd . && make -f Makefile DESTDIR=/tmp/tmp.WKRVFDA2ty NO_LIBDW_DWARF_UNWIND=1 > find: ‘/home/acme/git/linux/tools/perf/.gtk-in.o.cmd’: No such file or directory > find: ‘/home/acme/git/linux/tools/perf/builtin-script.o’: No such file or directory > - make_no_libunwind: cd . && make -f Makefile DESTDIR=/tmp/tmp.SQftzGTUYf NO_LIBUNWIND=1 > - make_no_auxtrace: cd . && make -f Makefile DESTDIR=/tmp/tmp.Xy2xrSCVuO NO_AUXTRACE=1 > - make_no_ui: cd . && make -f Makefile DESTDIR=/tmp/tmp.ZFNEHWqQFN NO_NEWT=1 NO_SLANG=1 NO_GTK2=1 > - make_no_libnuma: cd . && make -f Makefile DESTDIR=/tmp/tmp.68zRtMaEqf NO_LIBNUMA=1 > - make_no_backtrace: cd . && make -f Makefile DESTDIR=/tmp/tmp.5xcea8XfdC NO_BACKTRACE=1 > find: ‘/home/acme/git/linux/tools/perf/arch/x86/tests/dwarf-unwind.o’: No such file or directory > - make_install_prefix_slash: cd . && make -f Makefile DESTDIR=/tmp/tmp.2c5BqUKGef install prefix=/tmp/krava/ > find: ‘/home/acme/git/linux/tools/perf/builtin-record.o’: No such file or directory > find: ‘/home/acme/git/linux/tools/perf/builtin-inject.o’: No such file or directory > find: ‘/home/acme/git/linux/tools/perf/builtin-bench.o’: No such file or directory > find: ‘/home/acme/git/linux/tools/perf/.builtin-lock.o.cmd’: No such file or directory > find: ‘/home/acme/git/linux/tools/perf/perf.o’: No such file or directory > find: ‘/home/acme/git/linux/tools/perf/scripts/.libperf-in.o.cmd’: No such file or directory > find: ‘/home/acme/git/linux/tools/perf/tests/evsel-tp-sched.o’: No such file or directory > find: ‘/home/acme/git/linux/tools/perf/tests/hists_cumulate.o’: No such file or directory > - make_util_pmu_bison_o: cd . && make -f Makefile DESTDIR=/tmp/tmp.aJUWyFbXsp util/pmu-bis
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-01-11 23:50 +0100 |
| Subject | Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test |
| Message-ID | <qPTrI-rQ-9@gated-at.bofh.it> |
| In reply to | #1306784 |
Em Mon, Jan 11, 2016 at 07:39:04PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Mon, Jan 11, 2016 at 07:06:18PM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Mon, Jan 11, 2016 at 12:24:56PM -0300, Arnaldo Carvalho de Melo escreveu: > > > Em Mon, Jan 11, 2016 at 01:47:56PM +0000, Wang Nan escreveu: > > > > If an 'O' is passed to 'make build-test', many 'test -x' and 'test -f' > > > > will fail because perf resides in a different directory. Fix this by > > > > computing PERF_OUT according to 'O' and test correct output files. > > > > For make_kernelsrc and make_kernelsrc_tools, set KBUILD_OUTPUT_DIR > > > > instead because the path is different from others ($(O)/perf vs > > > > $(O)/tools/perf). > > > > > > Ok, applying up to this patch I now manage to almost cleanly build it using O=, > > > see below, but seems that we have some race, as not all tests end up producing > > > such warnings. > > > > > > [acme@felicio linux]$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ; make O=/tmp/build/perf -C tools/perf build-test > > > make: Entering directory `/home/acme/git/linux/tools/perf' > > > Testing Makefile > > > - make_no_libperl: cd . && make -f Makefile DESTDIR=/tmp/tmp.m1nXBMqhSA NO_LIBPERL=1 > > > find: ‘/tmp/build/perf/util/trace-event-scripting.o’: No such file or directory > > > > Well, it is happening even without O=: > > So I removed a few patches and those aren't appearing anymore, please > take a look at my perf/core branch, running build-test on a few machines > now, will push soon. > > My hunch is that build-test has issues with parallel builds, but I'm not > sure... Good: - make_perf_o_O: cd . && make -f Makefile O=/tmp/tmp.oLeg8aUaOo DESTDIR=/tmp/tmp.16WP4HTQJs perf.o - make_util_pmu_bison_o_O: cd . && make -f Makefile O=/tmp/tmp.xNRV0pCXfD DESTDIR=/tmp/tmp.8dyU9uEbHe util/pmu-bison.o - make_no_libdw_dwarf_unwind_O: cd . && make -f Makefile O=/tmp/tmp.pHH4HExHcH DESTDIR=/tmp/tmp.Wo0m8fF5cp NO_LIBDW_DWARF_UNWIND=1 - make_no_demangle_O: cd . && make -f Makefile O=/tmp/tmp.yWNsd4jOsI DESTDIR=/tmp/tmp.Q7eA4kCvwL NO_DEMANGLE=1 - tarpkg: ./tests/perf-targz-src-pkg . - make -C <kernelsrc> tools/perf - make -C <kernelsrc>/tools perf OK
[toc] | [prev] | [next] | [standalone]
| From | "Wangnan (F)" <wangnan0@huawei.com> |
|---|---|
| Date | 2016-01-12 08:20 +0100 |
| Subject | Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test |
| Message-ID | <qQ1pg-61J-19@gated-at.bofh.it> |
| In reply to | #1306788 |
On 2016/1/12 6:39, Arnaldo Carvalho de Melo wrote: > Em Mon, Jan 11, 2016 at 07:39:04PM -0300, Arnaldo Carvalho de Melo escreveu: >> Em Mon, Jan 11, 2016 at 07:06:18PM -0300, Arnaldo Carvalho de Melo escreveu: >>> Em Mon, Jan 11, 2016 at 12:24:56PM -0300, Arnaldo Carvalho de Melo escreveu: >>>> Em Mon, Jan 11, 2016 at 01:47:56PM +0000, Wang Nan escreveu: >>>>> If an 'O' is passed to 'make build-test', many 'test -x' and 'test -f' >>>>> will fail because perf resides in a different directory. Fix this by >>>>> computing PERF_OUT according to 'O' and test correct output files. >>>>> For make_kernelsrc and make_kernelsrc_tools, set KBUILD_OUTPUT_DIR >>>>> instead because the path is different from others ($(O)/perf vs >>>>> $(O)/tools/perf). >>>> Ok, applying up to this patch I now manage to almost cleanly build it using O=, >>>> see below, but seems that we have some race, as not all tests end up producing >>>> such warnings. >>>> >>>> [acme@felicio linux]$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ; make O=/tmp/build/perf -C tools/perf build-test >>>> make: Entering directory `/home/acme/git/linux/tools/perf' >>>> Testing Makefile >>>> - make_no_libperl: cd . && make -f Makefile DESTDIR=/tmp/tmp.m1nXBMqhSA NO_LIBPERL=1 >>>> find: ‘/tmp/build/perf/util/trace-event-scripting.o’: No such file or directory This can happen when you parallelly run find and rm on one directory. However, I've never seen this message in build-test before. >>> Well, it is happening even without O=: >> So I removed a few patches and those aren't appearing anymore, please >> take a look at my perf/core branch, running build-test on a few machines >> now, will push soon. >> >> My hunch is that build-test has issues with parallel builds, but I'm not >> sure... > > Good: > > - make_perf_o_O: cd . && make -f Makefile O=/tmp/tmp.oLeg8aUaOo DESTDIR=/tmp/tmp.16WP4HTQJs perf.o > - make_util_pmu_bison_o_O: cd . && make -f Makefile O=/tmp/tmp.xNRV0pCXfD DESTDIR=/tmp/tmp.8dyU9uEbHe util/pmu-bison.o > - make_no_libdw_dwarf_unwind_O: cd . && make -f Makefile O=/tmp/tmp.pHH4HExHcH DESTDIR=/tmp/tmp.Wo0m8fF5cp NO_LIBDW_DWARF_UNWIND=1 > - make_no_demangle_O: cd . && make -f Makefile O=/tmp/tmp.yWNsd4jOsI DESTDIR=/tmp/tmp.Q7eA4kCvwL NO_DEMANGLE=1 > - tarpkg: ./tests/perf-targz-src-pkg . > - make -C <kernelsrc> tools/perf > - make -C <kernelsrc>/tools perf > OK Glad to see this. Thank you.
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-01-12 15:10 +0100 |
| Subject | Re: [PATCH 05/53] perf tools: Test correct path of perf in build-test |
| Message-ID | <qQ7O1-1Z5-13@gated-at.bofh.it> |
| In reply to | #1307047 |
Em Tue, Jan 12, 2016 at 03:16:08PM +0800, Wangnan (F) escreveu: > > > On 2016/1/12 6:39, Arnaldo Carvalho de Melo wrote: > >Em Mon, Jan 11, 2016 at 07:39:04PM -0300, Arnaldo Carvalho de Melo escreveu: > >>Em Mon, Jan 11, 2016 at 07:06:18PM -0300, Arnaldo Carvalho de Melo escreveu: > >>>Em Mon, Jan 11, 2016 at 12:24:56PM -0300, Arnaldo Carvalho de Melo escreveu: > >>>>Em Mon, Jan 11, 2016 at 01:47:56PM +0000, Wang Nan escreveu: > >>>>>If an 'O' is passed to 'make build-test', many 'test -x' and 'test -f' > >>>>>will fail because perf resides in a different directory. Fix this by > >>>>>computing PERF_OUT according to 'O' and test correct output files. > >>>>>For make_kernelsrc and make_kernelsrc_tools, set KBUILD_OUTPUT_DIR > >>>>>instead because the path is different from others ($(O)/perf vs > >>>>> $(O)/tools/perf). > >>>>Ok, applying up to this patch I now manage to almost cleanly build it using O=, > >>>>see below, but seems that we have some race, as not all tests end up producing > >>>>such warnings. > >>>> > >>>>[acme@felicio linux]$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ; make O=/tmp/build/perf -C tools/perf build-test > >>>>make: Entering directory `/home/acme/git/linux/tools/perf' > >>>>Testing Makefile > >>>>- make_no_libperl: cd . && make -f Makefile DESTDIR=/tmp/tmp.m1nXBMqhSA NO_LIBPERL=1 > >>>>find: ‘/tmp/build/perf/util/trace-event-scripting.o’: No such file or directory > > This can happen when you parallelly run find and rm on one directory. > However, > I've never seen this message in build-test before. I'll leave this in the backburner for now, there are other, more important patches to process, we should revisit this as soon as we process the other eBPF patches :-\ > >>>Well, it is happening even without O=: > >>So I removed a few patches and those aren't appearing anymore, please > >>take a look at my perf/core branch, running build-test on a few machines > >>now, will push soon. > >> > >>My hunch is that build-test has issues with parallel builds, but I'm not > >>sure... > > > >Good: > > > >- make_perf_o_O: cd . && make -f Makefile O=/tmp/tmp.oLeg8aUaOo DESTDIR=/tmp/tmp.16WP4HTQJs perf.o > >- make_util_pmu_bison_o_O: cd . && make -f Makefile O=/tmp/tmp.xNRV0pCXfD DESTDIR=/tmp/tmp.8dyU9uEbHe util/pmu-bison.o > >- make_no_libdw_dwarf_unwind_O: cd . && make -f Makefile O=/tmp/tmp.pHH4HExHcH DESTDIR=/tmp/tmp.Wo0m8fF5cp NO_LIBDW_DWARF_UNWIND=1 > >- make_no_demangle_O: cd . && make -f Makefile O=/tmp/tmp.yWNsd4jOsI DESTDIR=/tmp/tmp.Q7eA4kCvwL NO_DEMANGLE=1 > >- tarpkg: ./tests/perf-targz-src-pkg . > >- make -C <kernelsrc> tools/perf > >- make -C <kernelsrc>/tools perf > >OK > Glad to see this. > > Thank you.
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-01-11 15:10 +0100 |
| Subject | [PATCH 20/53] perf record: Apply config to BPF objects before recording |
| Message-ID | <qPLkw-3rc-33@gated-at.bofh.it> |
| In reply to | #1306221 |
bpf__apply_obj_config() is introduced as the core API to apply object
config options to all BPF objects. This patch also does the real work
for setting values for BPF_MAP_TYPE_PERF_ARRAY maps by inserting value
stored in map's private field into the BPF map.
This patch is required because we are not always able to set all
BPF config during parsing. Further patch will set events created
by perf to BPF_MAP_TYPE_PERF_EVENT_ARRAY maps, which is not exist
until perf_evsel__open().
bpf_map_foreach_key() is introduced to iterate over each key
needs to be configured. This function would be extended to support
more map types and different key settings.
In perf record, before start recording, call bpf__apply_config() to
turn on all BPF config options.
Test result:
# cat ./test_bpf_map_1.c
/************************ BEGIN **************************/
#include <uapi/linux/bpf.h>
#define SEC(NAME) __attribute__((section(NAME), used))
struct bpf_map_def {
unsigned int type;
unsigned int key_size;
unsigned int value_size;
unsigned int max_entries;
};
static void *(*map_lookup_elem)(struct bpf_map_def *, void *) =
(void *)BPF_FUNC_map_lookup_elem;
static int (*trace_printk)(const char *fmt, int fmt_size, ...) =
(void *)BPF_FUNC_trace_printk;
struct bpf_map_def SEC("maps") channel = {
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(int),
.value_size = sizeof(int),
.max_entries = 1,
};
SEC("func=sys_nanosleep")
int func(void *ctx)
{
int key = 0;
char fmt[] = "%d\n";
int *pval = map_lookup_elem(&channel, &key);
if (!pval)
return 0;
trace_printk(fmt, sizeof(fmt), *pval);
return 0;
}
char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
/************************* END ***************************/
# echo "" > /sys/kernel/debug/tracing/trace
# ./perf record -e './test_bpf_map_1.c/maps:channel.value=11/' usleep 10
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.012 MB perf.data ]
# cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 1/1 #P:8
[SNIP]
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
usleep-18593 [007] d... 2394714.395539: : 11
# ./perf record -e './test_bpf_map.c/maps:channel.value=101/' usleep 10
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.012 MB perf.data ]
# cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 1/1 #P:8
[SNIP]
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
usleep-18593 [007] d... 2394714.395539: : 11
usleep-19000 [006] d... 2394831.057840: : 101
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
tools/perf/builtin-record.c | 11 +++
tools/perf/util/bpf-loader.c | 180 +++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/bpf-loader.h | 15 ++++
3 files changed, 206 insertions(+)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index dc4e0ad..bd1692c 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -32,6 +32,7 @@
#include "util/parse-branch-options.h"
#include "util/parse-regs-options.h"
#include "util/llvm-utils.h"
+#include "util/bpf-loader.h"
#include <unistd.h>
#include <sched.h>
@@ -526,6 +527,16 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
goto out_child;
}
+ err = bpf__apply_obj_config();
+ if (err) {
+ char errbuf[BUFSIZ];
+
+ bpf__strerror_apply_obj_config(err, errbuf, sizeof(errbuf));
+ pr_err("ERROR: Apply config to BPF failed: %s\n",
+ errbuf);
+ goto out_child;
+ }
+
/*
* Normally perf_session__new would do this, but it doesn't have the
* evlist.
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 7d361aa..96fd18b 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -7,6 +7,7 @@
#include <linux/bpf.h>
#include <bpf/libbpf.h>
+#include <bpf/bpf.h>
#include <linux/err.h>
#include <linux/string.h>
#include "perf.h"
@@ -984,6 +985,178 @@ out:
}
+typedef int (*map_config_func_t)(const char *name, int map_fd,
+ struct bpf_map_def *pdef,
+ struct bpf_map_op *op,
+ void *pkey, void *arg);
+
+static int
+foreach_key_array_all(map_config_func_t func,
+ void *arg, const char *name,
+ int map_fd, struct bpf_map_def *pdef,
+ struct bpf_map_op *op)
+{
+ unsigned int i;
+ int err;
+
+ for (i = 0; i < pdef->max_entries; i++) {
+ err = func(name, map_fd, pdef, op, &i, arg);
+ if (err) {
+ pr_debug("ERROR: failed to insert value to %s[%u]\n",
+ name, i);
+ return err;
+ }
+ }
+ return 0;
+}
+
+static int
+bpf_map_config_foreach_key(struct bpf_map *map,
+ map_config_func_t func,
+ void *arg)
+{
+ int err, map_fd;
+ const char *name;
+ struct bpf_map_op *op;
+ struct bpf_map_def def;
+ struct bpf_map_priv *priv;
+
+ name = bpf_map__get_name(map);
+
+ err = bpf_map__get_private(map, (void **)&priv);
+ if (err) {
+ pr_debug("ERROR: failed to get private from map %s\n", name);
+ return -BPF_LOADER_ERRNO__INTERNAL;
+ }
+ if (!priv || list_empty(&priv->ops_list)) {
+ pr_debug("INFO: nothing to config for map %s\n", name);
+ return 0;
+ }
+
+ err = bpf_map__get_def(map, &def);
+ if (err) {
+ pr_debug("ERROR: failed to get definition from map %s\n", name);
+ return -BPF_LOADER_ERRNO__INTERNAL;
+ }
+ map_fd = bpf_map__get_fd(map);
+ if (map_fd < 0) {
+ pr_debug("ERROR: failed to get fd from map %s\n", name);
+ return map_fd;
+ }
+
+ list_for_each_entry(op, &priv->ops_list, list) {
+ switch (def.type) {
+ case BPF_MAP_TYPE_ARRAY:
+ switch (op->key_type) {
+ case BPF_MAP_KEY_ALL:
+ return foreach_key_array_all(func, arg, name,
+ map_fd, &def, op);
+ default:
+ pr_debug("ERROR: keytype for map '%s' invalid\n",
+ name);
+ return -BPF_LOADER_ERRNO__INTERNAL;
+ }
+ default:
+ pr_debug("ERROR: type of '%s' incorrect\n", name);
+ return -BPF_LOADER_ERRNO__OBJCONF_MAP_TYPE;
+ }
+ }
+
+ return 0;
+}
+
+static int
+apply_config_value_for_key(int map_fd, void *pkey,
+ size_t val_size, u64 val)
+{
+ int err = 0;
+
+ switch (val_size) {
+ case 1: {
+ u8 _val = (u8)(val);
+ err = bpf_map_update_elem(map_fd, pkey, &_val, BPF_ANY);
+ break;
+ }
+ case 2: {
+ u16 _val = (u16)(val);
+ err = bpf_map_update_elem(map_fd, pkey, &_val, BPF_ANY);
+ break;
+ }
+ case 4: {
+ u32 _val = (u32)(val);
+ err = bpf_map_update_elem(map_fd, pkey, &_val, BPF_ANY);
+ break;
+ }
+ case 8: {
+ err = bpf_map_update_elem(map_fd, pkey, &val, BPF_ANY);
+ break;
+ }
+ default:
+ pr_debug("ERROR: invalid value size\n");
+ return -BPF_LOADER_ERRNO__OBJCONF_MAP_VALUESIZE;
+ }
+ if (err && errno)
+ err = -errno;
+ return err;
+}
+
+static int
+apply_obj_config_map_for_key(const char *name, int map_fd,
+ struct bpf_map_def *pdef __maybe_unused,
+ struct bpf_map_op *op,
+ void *pkey, void *arg __maybe_unused)
+{
+ int err;
+
+ switch (op->op_type) {
+ case BPF_MAP_OP_SET_VALUE:
+ err = apply_config_value_for_key(map_fd, pkey,
+ pdef->value_size,
+ op->v.value);
+ break;
+ default:
+ pr_debug("ERROR: unknown value type for '%s'\n", name);
+ err = -BPF_LOADER_ERRNO__INTERNAL;
+ }
+ return err;
+}
+
+static int
+apply_obj_config_map(struct bpf_map *map)
+{
+ return bpf_map_config_foreach_key(map,
+ apply_obj_config_map_for_key,
+ NULL);
+}
+
+static int
+apply_obj_config_object(struct bpf_object *obj)
+{
+ struct bpf_map *map;
+ int err;
+
+ bpf_map__for_each(map, obj) {
+ err = apply_obj_config_map(map);
+ if (err)
+ return err;
+ }
+ return 0;
+}
+
+int bpf__apply_obj_config(void)
+{
+ struct bpf_object *obj, *tmp;
+ int err;
+
+ bpf_object__for_each_safe(obj, tmp) {
+ err = apply_obj_config_object(obj);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
#define ERRNO_OFFSET(e) ((e) - __BPF_LOADER_ERRNO__START)
#define ERRCODE_OFFSET(c) ERRNO_OFFSET(BPF_LOADER_ERRNO__##c)
#define NR_ERRNO (__BPF_LOADER_ERRNO__END - __BPF_LOADER_ERRNO__START)
@@ -1138,3 +1311,10 @@ int bpf__strerror_config_obj(struct bpf_object *obj __maybe_unused,
bpf__strerror_end(buf, size);
return 0;
}
+
+int bpf__strerror_apply_obj_config(int err, char *buf, size_t size)
+{
+ bpf__strerror_head(err, buf, size);
+ bpf__strerror_end(buf, size);
+ return 0;
+}
diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h
index 2464db9..db3c34c 100644
--- a/tools/perf/util/bpf-loader.h
+++ b/tools/perf/util/bpf-loader.h
@@ -71,6 +71,8 @@ int bpf__strerror_config_obj(struct bpf_object *obj,
struct perf_evlist *evlist,
int *error_pos, int err, char *buf,
size_t size);
+int bpf__apply_obj_config(void);
+int bpf__strerror_apply_obj_config(int err, char *buf, size_t size);
#else
static inline struct bpf_object *
bpf__prepare_load(const char *filename __maybe_unused,
@@ -111,6 +113,12 @@ bpf__config_obj(struct bpf_object *obj __maybe_unused,
}
static inline int
+bpf__apply_obj_config(void)
+{
+ return 0;
+}
+
+static inline int
__bpf_strerror(char *buf, size_t size)
{
if (!size)
@@ -156,5 +164,12 @@ bpf__strerror_config_obj(struct bpf_object *obj __maybe_unused,
{
return __bpf_strerror(buf, size);
}
+
+static inline int
+bpf__strerror_apply_obj_config(int err __maybe_unused,
+ char *buf, size_t size)
+{
+ return __bpf_strerror(buf, size);
+}
#endif
#endif
--
1.8.3.4
[toc] | [prev] | [next] | [standalone]
| From | Wang Nan <wangnan0@huawei.com> |
|---|---|
| Date | 2016-01-11 15:10 +0100 |
| Subject | [PATCH 14/53] perf test: Check environment before start real BPF test |
| Message-ID | <qPLkw-3rc-35@gated-at.bofh.it> |
| In reply to | #1306221 |
Copying perf to old kernel system results:
# perf test bpf
37: Test BPF filter :
37.1: Test basic BPF filtering : FAILED!
37.2: Test BPF prologue generation : Skip
However, in case when kernel doesn't support a test case it should
return 'Skip', 'FAILED!' should be reserved for kernel tests for when
the kernel supports a feature that then fails to work as advertised.
This patch checks environment before real testcase.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/bpf.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index 33689a0..826b4b3 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -1,7 +1,11 @@
#include <stdio.h>
#include <sys/epoll.h>
+#include <util/util.h>
#include <util/bpf-loader.h>
#include <util/evlist.h>
+#include <linux/bpf.h>
+#include <linux/filter.h>
+#include <bpf/bpf.h>
#include "tests.h"
#include "llvm.h"
#include "debug.h"
@@ -227,6 +231,36 @@ const char *test__bpf_subtest_get_desc(int i)
return bpf_testcase_table[i].desc;
}
+static int check_env(void)
+{
+ int err;
+ unsigned int kver_int;
+ char license[] = "GPL";
+
+ struct bpf_insn insns[] = {
+ BPF_MOV64_IMM(BPF_REG_0, 1),
+ BPF_EXIT_INSN(),
+ };
+
+ err = fetch_kernel_version(&kver_int, NULL, 0);
+ if (err) {
+ pr_debug("Unable to get kernel version\n");
+ return err;
+ }
+
+ err = bpf_load_program(BPF_PROG_TYPE_KPROBE, insns,
+ sizeof(insns) / sizeof(insns[0]),
+ license, kver_int, NULL, 0);
+ if (err < 0) {
+ pr_err("Missing basic BPF support, skip this test: %s\n",
+ strerror(errno));
+ return err;
+ }
+ close(err);
+
+ return 0;
+}
+
int test__bpf(int i)
{
int err;
@@ -239,6 +273,9 @@ int test__bpf(int i)
return TEST_SKIP;
}
+ if (check_env())
+ return TEST_SKIP;
+
err = __test__bpf(i);
return err;
}
--
1.8.3.4
[toc] | [prev] | [next] | [standalone]
Page 3 of 5 — ← Prev page 1 2 [3] 4 5 Next page →
Back to top | Article view | linux.kernel
csiph-web