Can any one tell me why cond_resched in do_select?

2008-01-23 Thread Wang Nan
Hi, everyone. I have a question regarding to select system call's code. In do_select() function, after check each fd in the set, do_select() call cond_resched(). That line, according to my view, is to reduce the system freeze time when do the busy querying. But before the call, when entering into t

[PATCH] perf record: Fix segfault when running with suid and kptr_restrict is 1

2016-09-20 Thread Wang Nan
and euid. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo --- tools/perf/util/symbol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 19c9c55..9528702 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/

[PATCH] perf record: Fix segfault when running with suid and kptr_restrict is 1

2016-09-20 Thread Wang Nan
and euid. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo --- Resend with a meanless blank like removed. --- tools/perf/util/symbol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 19c9c55..c55e781 100644 --- a/tools/p

[PATCH v8 1/8] perf tools: Fix write_backwards fallback

2016-06-20 Thread Wang Nan
ward. [1] http://lkml.kernel.org/r/20160616214724.gi13...@kernel.org Signed-off-by: Wang Nan Signed-off-by: Arnaldo Carvalho de Melo Cc: He Kuang Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3or...@163.com --- tools/perf/util/evsel.c | 23 ++- 1 file chan

[PATCH v8 7/8] perf tools: Don't warn about out of order event if write_backward is used

2016-06-20 Thread Wang Nan
] Signed-off-by: Wang Nan Signed-off-by: He Kuang Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3or...@163.com --- tools/perf/util/session.c | 22 +++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/

[PATCH v8 6/8] perf tools: Enable overwrite settings

2016-06-20 Thread Wang Nan
, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, write_backward: 1 # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events Signed-off-by: Wang Nan Signed-off-by: He Kuang Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa

[PATCH v8 5/8] perf record: Toggle overwrite ring buffer for reading

2016-06-20 Thread Wang Nan
state to help us recording what we have done to the ring buffer. Signed-off-by: Wang Nan Signed-off-by: He Kuang Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3or...@163.com --- tools/perf/builti

[PATCH v8 8/8] perf tools: Add --tail-synthesize option

2016-06-20 Thread Wang Nan
s empty. However this is a cheaper choice. To complete solve this problem we need to continously output non-sample events. To satisify the requirement of daemonization, we need to merge them periodically. It is possible but requires much more code and cycles. Automatically select --tail-synthesize whe

[PATCH v8 2/8] perf evlist: Introduce aux evlist

2016-06-20 Thread Wang Nan
creating aux evlist from another aux evlist. Improve perf_evlist__munmap_filtered(), so when recording, if an event is terminated, unmap mmaps, from parent and children. Signed-off-by: Wang Nan Cc: He Kuang Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3or...@163.com -

[PATCH v8 3/8] perf tests: Add testcase for auxiliary evlist

2016-06-20 Thread Wang Nan
Improve test backward-ring-buffer, trace both enter and exit event of prctl() syscall, utilize auxiliary evlist to mmap enter and exit event into separated mmaps. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: He

[PATCH v8 4/8] perf record: Introduce rec->overwrite_evlist for overwritable events

2016-06-20 Thread Wang Nan
an event goes to either rec->evlist or rec->overwrite_evlist. Signed-off-by: Wang Nan Cc: He Kuang Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3or...@163.com --- tools/perf/builtin-record.c | 132 +++

[PATCH v8 0/8] perf tools: Support overwritable ring buffer

2016-06-20 Thread Wang Nan
v5 -> v6: Improve filter pollfd related code. v6 -> v7: Rebase to newest perf/core. v7 -> v8: Unmap mmaps from parent and children in perf_evlist__munmap_filtered(), hide more detail of aux evlist. Add --tail-synthesize, do synthesize at the end of perf.data. Wang N

[PATCH 01/14] tools build: Support compiling C++ source file

2016-09-23 Thread Wang Nan
Add new rule to compile .cpp file to .o use g++. C++ support is required for built-in clang and LLVM support. Linker side support will be introduced by following commits. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build

[PATCH 12/14] perf bpf: Compile BPF script use builtin cflags support

2016-09-23 Thread Wang Nan
ipt-example.c >> ./test.c $ ./perf record -v --dry-run -e ./test.c 2>&1 | grep builtin bpf: builtin compiling successful Can't pass cflags so unable to include kernel headers now. Will be fixed by following commits. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Star

[PATCH 06/14] perf clang: Add builtin clang support ant test case

2016-09-23 Thread Wang Nan
Add basic clang support in clang.cpp and test__clang() testcase. The first testcase checks if builtin clang is able to generate LLVM IR. tests/clang.c is a proxy. Real testcase resides in utils/c++/clang-test.cpp in c++ and exports C interface to perf test subsystem. Signed-off-by: Wang Nan Cc

[PATCH 11/14] perf tools: Extract kernel build option detector as utils

2016-09-23 Thread Wang Nan
Following commits will use builtin clang to compile BPF script. llvm__get_kbuild_opts() is extracted to help it detect kbuild dir and include options. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/util/llvm-utils.c | 44

[PATCH 00/14] perf clang: Support compiling BPF script use builtin clang

2016-09-23 Thread Wang Nan
test clang'. Patch 11 - 14 fixes missing features like kbuild detection and some default macros. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa Wang Nan (14): tools build: Support compiling C++ source file perf tools: Add feature

[PATCH 02/14] perf tools: Add feature detection for g++

2016-09-23 Thread Wang Nan
Check if g++ is available. The result will be used by builtin clang and LLVM support. Since LLVM requires C++11, this feature detector checks std::move(). Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build/Makefile.feature

[PATCH 07/14] perf clang: Use real file system for #include

2016-09-23 Thread Wang Nan
Utilize clang's OverlayFileSystem facility to enable VFS passed to CompilerInstance can access files in real file system, so '#include' directive can be used. Add a new getModuleFromSource for real file. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoito

[PATCH 09/14] perf clang: Update test case to use real BPF script

2016-09-23 Thread Wang Nan
Allow C++ code to use util.h and tests/llvm.h. Let perf test to compile a real BPF script. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/Makefile.config | 27 +++ tools/perf/tests/llvm

[PATCH 08/14] perf clang: Allow passing CFLAGS to builtin clang

2016-09-23 Thread Wang Nan
Improve getModuleFromSource() API to accept a cflags list. This feature will be used to pass LINUX_VERSION_CODE and -I flags. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/util/c++/clang-test.cpp | 5 +++-- tools/perf

[PATCH 14/14] perf clang: Pass correct CFLAGS to builtin clang

2016-09-23 Thread Wang Nan
Pass CFLAGS detected by kbuild detector to builtin clang so BPF scripts can use kernel headers like external clang compiler. Test: # perf record --dry-run -e tools/perf/tests/bpf-script-test-kbuild.c ls 2>&1 | grep built bpf: builtin compiling successful Signed-off-by: Wang Nan Cc:

[PATCH 04/14] perf tools: Add feature detection for clang

2016-09-23 Thread Wang Nan
d new clang breaking libraries ordering, use --start-group and --end-group. In this test case, manually identify required clang libs and hope it to be stable. Putting all clang libraries here is possible (use make's wildcard), but then feature checking becomes very slow. Signed-off-by: Wang

[PATCH 10/14] perf clang: Support compile IR to BPF object and add testcase

2016-09-23 Thread Wang Nan
getBPFObjectFromModule() is introduced to use LLVM to convert Module (LLVM IR) to BPF object code. Add new testcase for it. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/tests/clang.c | 6 - tools/perf

[PATCH 05/14] perf build: Add clang and llvm compile and linking support

2016-09-23 Thread Wang Nan
Add necessary c++ flags and link libraries to support builtin clang and LLVM. Add all llvm and clang libraries, so don't need to worry about clang changes its libraries setting. However, linking perf would take much longer than usual. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Mel

[PATCH 13/14] perf clang: Pass fill path compiler

2016-09-23 Thread Wang Nan
If clang changes its working directory, filename passed to perf_clang__compile_bpf() becomes invalid. Before running clang, convert it to absolute path so file can be found even working directory is different. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He

[PATCH 03/14] perf tools: Add feature detection for LLVM

2016-09-23 Thread Wang Nan
rement that LLVM should be new enough. Old LLVM doesn't support BPF backend. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build/feature/Makefile | 8 tools/build/feature/test-llvm.cpp | 8 2 files cha

[PATCH v2 08/18] perf clang: Allow passing CFLAGS to builtin clang

2016-09-26 Thread Wang Nan
Improve getModuleFromSource() API to accept a cflags list. This feature will be used to pass LINUX_VERSION_CODE and -I flags. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/util/c++/clang-test.cpp | 5 +++-- tools/perf

[PATCH v2 03/18] perf tools: Add feature detection for LLVM

2016-09-26 Thread Wang Nan
rement that LLVM should be new enough. Old LLVM doesn't support BPF backend. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build/feature/Makefile | 8 tools/build/feature/test-llvm.cpp | 8 2 files cha

[PATCH v2 04/18] perf tools: Add feature detection for clang

2016-09-26 Thread Wang Nan
d new clang breaking libraries ordering, use --start-group and --end-group. In this test case, manually identify required clang libs and hope it to be stable. Putting all clang libraries here is possible (use make's wildcard), but then feature checking becomes very slow. Signed-off-by: Wang

[PATCH v2 18/18] perf clang: Define PERF_BUILTIN_CLANG for builtin clang compiling

2016-09-26 Thread Wang Nan
By this macro BPF script knows what compiler it is being built with. Scripts prefer external clang can force fall back to it by: #ifdef PERF_BUILTIN_CLANG # error I prefer external clang compiler #endif Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He

[PATCH v2 15/18] perf clang: Link BPF functions declaration into perf

2016-09-26 Thread Wang Nan
Use a shell script to generate BPF functions declarations from kernel source code, embedded the generated header into a C string. Following commits will utilizes clang's virtual file system to automatically include this header to all BPF scripts. Signed-off-by: Wang Nan Cc: Arnaldo Carval

[PATCH v2 05/18] perf build: Add clang and llvm compile and linking support

2016-09-26 Thread Wang Nan
Add necessary c++ flags and link libraries to support builtin clang and LLVM. Add all llvm and clang libraries, so don't need to worry about clang changes its libraries setting. However, linking perf would take much longer than usual. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Mel

[PATCH v2 00/18] perf clang: Support compiling BPF script on the fly

2016-09-26 Thread Wang Nan
und at: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1238358.html (should be http://lkml.kernel.org/g/1474635001-153850-1-git-send-email-wangn...@huawei.com but the link is broken) Wang Nan (18): tools build: Support compiling C++ source file perf tools: Add feature detec

[PATCH v2 17/18] perf clang: Include helpers to BPF scripts

2016-09-26 Thread Wang Nan
Automatically include common used macros and struct definitions into BPF scripts. Script writers are no longer required to define 'SEC' and 'struct bpf_map_def' in each of their scripts. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He

[PATCH v2 02/18] perf tools: Add feature detection for g++

2016-09-26 Thread Wang Nan
Check if g++ is available. The result will be used by builtin clang and LLVM support. Since LLVM requires C++11, this feature detector checks std::move(). Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build/Makefile.feature

[PATCH v2 10/18] perf clang: Support compile IR to BPF object and add testcase

2016-09-26 Thread Wang Nan
getBPFObjectFromModule() is introduced to use LLVM to convert Module (LLVM IR) to BPF object code. Add new testcase for it. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/tests/clang.c | 6 - tools/perf

[PATCH v2 12/18] perf bpf: Compile BPF script use builtin clang support

2016-09-26 Thread Wang Nan
ipt-example.c >> ./test.c $ ./perf record -v --dry-run -e ./test.c 2>&1 | grep builtin bpf: builtin compiling successful Can't pass cflags so unable to include kernel headers now. Will be fixed by following commits. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Star

[PATCH v2 11/18] perf tools: Extract helpers in llvm-utils.c

2016-09-26 Thread Wang Nan
Following commits will use builtin clang to compile BPF script. llvm__get_kbuild_opts() and llvm__get_nr_cpus() are extracted to help building '-DKERNEL_VERSION_CODE' and '-D__NR_CPUS__' macros. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc

[PATCH v2 13/18] perf clang: Pass full path to builtin clang

2016-09-26 Thread Wang Nan
If clang changes its working directory, filename passed to perf_clang__compile_bpf() becomes invalid. Before running clang, convert it to absolute path so file can be found even working directory is changed. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He

[PATCH v2 16/18] perf clang: Declare BPF functions for BPF scripts automatically

2016-09-26 Thread Wang Nan
Use Clang's OverlayFileSystem, add '-include' options to make builtin clang define BPF functions. After this patch BPF script writer needn't define BPF functions by their own. Test cases are updated to avoid redefine these functions. Signed-off-by: Wang Nan Cc: Arnaldo

[PATCH v2 14/18] perf clang: Pass CFLAGS to builtin clang

2016-09-26 Thread Wang Nan
ls 2>&1 | grep built bpf: builtin compiling successful Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/util/c++/clang.cpp| 105 +-- tools/perf/util/llvm-utils-cxx.

[PATCH v2 01/18] tools build: Support compiling C++ source file

2016-09-26 Thread Wang Nan
Add new rule to compile .cpp file to .o use g++. C++ support is required for built-in clang and LLVM support. Linker side support will be introduced by following commits. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/build

[PATCH v2 07/18] perf clang: Use real file system for #include

2016-09-26 Thread Wang Nan
Utilize clang's OverlayFileSystem facility to enable VFS passed to CompilerInstance can access files in real file system, so '#include' directive can be used. Add a new getModuleFromSource for real file. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoito

[PATCH v2 06/18] perf clang: Add builtin clang support ant test case

2016-09-26 Thread Wang Nan
Add basic clang support in clang.cpp and test__clang() testcase. The first testcase checks if builtin clang is able to generate LLVM IR. tests/clang.c is a proxy. Real testcase resides in utils/c++/clang-test.cpp in c++ and exports C interface to perf test subsystem. Signed-off-by: Wang Nan Cc

[PATCH v2 09/18] perf clang: Update test case to use real BPF script

2016-09-26 Thread Wang Nan
Allow C++ code to use util.h and tests/llvm.h. Let perf test to compile a real BPF script. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: He Kuang Cc: Jiri Olsa --- tools/perf/Makefile.config | 27 +++ tools/perf/tests/llvm

[PATCH 0/2] tools include: Fix uapi mman.h for each architecture

2016-09-14 Thread Wang Nan
Naveen reports a building failure on powerpc because powerpc doesn't define MMAP_32BIT. Fix it by ensure all macros required by perf is defined. Wang Nan (2): perf trace beauty mmap: Add missing MADV_FREE tools include: Add mman macros needed by perf for all arch tools/arch/alpha/in

[PATCH 1/2] perf trace beauty mmap: Add missing MADV_FREE

2016-09-14 Thread Wang Nan
tools/perf/trace/beauty/mmap.c forgets to check MADV_FREE. This patch fixes it. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Naveen N. Rao --- tools/perf/trace/beauty/mmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/trace/beauty/mmap.c b/tools/perf/trace

[PATCH 2/2] tools include: Add mman macros needed by perf for all arch

2016-09-14 Thread Wang Nan
MADV_SEQUENTIAL MADV_SOFT_OFFLINE MADV_UNMERGEABLE MADV_WILLNEED MAP_32BIT MAP_ANONYMOUS MAP_DENYWRITE MAP_EXECUTABLE MAP_FILE MAP_FIXED MAP_GROWSDOWN MAP_HUGETLB MAP_LOCKED MAP_NONBLOCK MAP_NORESERVE MAP_POPULATE MAP_PRIVATE MAP_SHARED MAP_STACK MAP_UNINITIALIZED MREMAP_FIXED MR

[PATCH 2/3] tools lib api fs: Add hugetlbfs filesystem detector

2016-09-02 Thread Wang Nan
Detect hugetlbfs. hugetlbfs__mountpoint() will be used during recording to help recorder identifying hugetlb mmaps: which should be recognized as anon mapping. Signed-off-by: Wang Nan Cc: Hou Pengyang Cc: He Kuang Cc: Arnaldo Carvalho de Melo --- tools/lib/api/fs/fs.c | 15

[PATCH 0/3] perf report: Recognize hugetlb mapping as anon mapping

2016-09-02 Thread Wang Nan
recognize hugetlbfs mapping as anon mapping. Before this 3 patches user has no chance to use his/her own .map file to resolve symbols because perf tries to use hugetlbfs file. Wang Nan (3): perf tools: Recognize hugetlb mapping as anon mapping tools lib api fs: Add hugetlbfs filesystem detec

[PATCH 3/3] perf record: Mark MAP_HUGETLB during synthesizing mmap events

2016-09-02 Thread Wang Nan
During synthesizing mmap events, add MAP_HUGETLB map flag if the source of mapping is file in hugetlbfs. After this patch, perf can identify hugetlb mapping even if perf is started after the mapping of huge pages (like perf top). Signed-off-by: Wang Nan Cc: Hou Pengyang Cc: He Kuang Cc

[PATCH 1/3] perf tools: Recognize hugetlb mapping as anon mapping

2016-09-02 Thread Wang Nan
hugetlb mapping as anon mapping. Signed-off-by: Wang Nan Signed-off-by: Hou Pengyang Cc: He Kuang Cc: Arnaldo Carvalho de Melo --- tools/perf/util/map.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 728129a

[PATCH 1/2] perf mmap: Fix perf backward recording

2017-10-31 Thread Wang Nan
1 (1, 12cc330, 4, 7fc237280370, 7fc2373d0700, 2c7b0) python 2545 [000] 11079.280850: raw_syscalls:sys_exit: NR 1 = 4 Signed-off-by: Wang Nan --- tools/perf/util/evlist.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evl

[PATCH 2/2] perf record: Replace 'overwrite' by 'flightrecorder' for better naming

2017-10-31 Thread Wang Nan
er, wraps them into a record mode. In flight recorder mode, perf only dumps data before something happen. Signed-off-by: Wang Nan --- tools/perf/Documentation/perf-record.txt | 8 tools/perf/builtin-record.c | 4 ++-- tools/perf/perf.h| 2 +- to

[PATCH 0/2] perf record: Fix --overwrite and clarify concepts

2017-10-31 Thread Wang Nan
by introducing the concept of 'flightrecorder' and convert many 'overwrite' to it to clarify that what we really want is a perf record flightrecorder mode, not only mapping the ring buffer overwritable. Wang Nan (2): perf mmap: Fix perf backward recording perf record: Replace 'o

[PATCH 6/7] perf tools: Remove 'overwrite' concept from code level

2017-11-12 Thread Wang Nan
s no 'overwrite' concept. Each evlist has two ringbuffer groups. One is read-write/forward, another is readonly/backward. Don't support read-write/backward and readonly/forward. 2. In user interface, we keep '--overwrite' and translate it into write_backward i

[PATCH 4/7] perf tests: Set evlist of test__basic_mmap() to !overwrite

2017-11-12 Thread Wang Nan
In this test, a large ring buffer is required so all events can feed into, so overwrite or not is meaningless. Change to !overwrite so following commits can remove this argument. Signed-off-by: Wang Nan --- tools/perf/tests/mmap-basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion

[PATCH 2/7] perf tests: Set evlist of test__backward_ring_buffer() to !overwrite

2017-11-12 Thread Wang Nan
Setting overwrite in perf_evlist__mmap() is meaningless because the event in this evlist is already have 'overwrite' postfix and goes to backward ring buffer automatically. Pass 'false' to perf_evlist__mmap() to make it similar to others. Signed-off-by: Wang Nan --- tools

[PATCH 3/7] perf tests: Set evlist of test__sw_clock_freq() to !overwrite

2017-11-12 Thread Wang Nan
Unsetting overwrite when calling perf_evlist__mmap is harmless. This commit passes false to it, makes following commits eliminate the overwrite argument easier. Signed-off-by: Wang Nan --- tools/perf/tests/sw-clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf

[PATCH 5/7] perf tests: Set evlist of test__task_exit() to !overwrite

2017-11-12 Thread Wang Nan
Changing ringbuffer to !overwrite in this task is harmless because this test uses a very low frequency (1) and using a very simple program (true). There should have only 3 events in the whole test. Overwriting is impossible to happen. Signed-off-by: Wang Nan --- tools/perf/tests/task-exit.c | 2

[PATCH 1/7] perf mmap: Fix perf backward recording

2017-11-12 Thread Wang Nan
30, 4, 7fc237280370, 7fc2373d0700, 2c7b0) python 2545 [000] 11079.280850: raw_syscalls:sys_exit: NR 1 = 4 Signed-off-by: Wang Nan --- tools/perf/util/evlist.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c

[PATCH 0/7] perf tools: Clarify overwrite and backward, bugfix

2017-11-12 Thread Wang Nan
Based on previous discussion, perf needs to support only two types of ringbuffer: read-write + forward, readonly + backward. This patchset completly removes the concept of 'overwrite' from code level, controls mapping permission using write_backward instead. Wang Nan (7): perf mmap

[PATCH 7/7] perf tools: Remove prot field in mmap param

2017-11-12 Thread Wang Nan
After removing the concept of 'overwrite' in code level, now the prot is determinated by write_backward. There's no need to pass prot from perf_evlist__mmap_ex(). Signed-off-by: Wang Nan --- tools/perf/util/evlist.c | 17 ++--- tools/perf/util/mmap.c | 4 ++--

[RFC PATCH] mm, oom_reaper: gather each vma to prevent leaking TLB entry

2017-11-05 Thread Wang Nan
mm is not true. The behavior of oom reaper become similar to munmapping before do_exit, which should be safe for all archs. Signed-off-by: Wang Nan Cc: Bob Liu Cc: Michal Hocko Cc: Andrew Morton Cc: Michal Hocko Cc: David Rientjes Cc: Ingo Molnar Cc: Roman Gushchin Cc: Konstantin Khle

[GIT PULL 00/22] perf tools: filtering events using eBPF programs

2015-10-08 Thread Wang Nan
: Test BPF prologue (2015-10-08 07:23:33 +) EBPF support for perf - Rebase to newest perf/core - Fix a document problem in Makefile.perf: NO_BPF -> NO_LIBBPF Signed-off-by: Wang

[PATCH 04/22] perf record, bpf: Create probe points for BPF programs

2015-10-08 Thread Wang Nan
rf quit through exit() bpf__clear() is still called, so probing points are cleared. strerror style error reporting scaffold is created by this patch. bpf__strerror_probe() is the first error reporting function in bpf-loader.c. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc:

[PATCH 13/22] bpf tools: Load a program with different instances using preprocessor

2015-10-08 Thread Wang Nan
llback should return instructions arrays for each instances. fd field in bpf_programs is replaced by instance, which has an nr field and fds array. bpf_program__nth_fd() is introduced for read fd of instances. Old interface bpf_program__fd() is reimplemented by returning the first fd. Signed-off-by: Wang Na

[PATCH 01/22] perf tools: Make perf depend on libbpf

2015-10-08 Thread Wang Nan
his code to an old kernel. Error messages are also updated to notify users about the disable of BPF support of 'perf record' if libelf is missed or BPF API check failed. tools/lib/bpf is added into TAG_FOLDERS to allow us to navigate on libbpf files when working on perf using tools/

[PATCH 02/22] perf ebpf: Add the libbpf glue

2015-10-08 Thread Wang Nan
The 'bpf-loader.[ch]' files are introduced in this patch. Which will be the interface between perf and libbpf. bpf__prepare_load() resides in bpf-loader.c. Following patches will enrich these two files. Signed-off-by: Wang Nan Signed-off-by: Arnaldo Carvalho de Melo Acked-by: Alexei S

[PATCH 05/22] perf record: Load eBPF object into kernel

2015-10-08 Thread Wang Nan
This patch utilizes bpf_object__load() provided by libbpf to load all objects into kernel. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Paul

[PATCH 12/22] perf probe: Reset args and nargs for probe_trace_event when failure

2015-10-08 Thread Wang Nan
When failure occures in add_probe_trace_event(), args in probe_trace_event is incomplete. Since information in it may be used in futher, this patch frees the allocated memory and set it to NULL to avoid dangling pointer. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc

[PATCH 21/22] perf test: Enforce LLVM test, add kbuild test

2015-10-08 Thread Wang Nan
kbuild testcase to check whether kernel headers can be correctly found. For example: # perf test LLVM 38: Test LLVM searching and compiling: (llvm.kbuild-dir can be fixed) Ok Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Brendan Gregg

[PATCH 16/22] perf tools: Add prologue for BPF programs for fetching arguments

2015-10-08 Thread Wang Nan
-kernel function, and exit value for eBPF program * r1 - r5 - arguments from eBPF program to in-kernel function * r6 - r9 - callee saved registers that in-kernel function will preserve * r10 - read-only frame pointer to access stack Signed-off-by: He

[PATCH 15/22] perf tools: Compile dwarf-regs.c if CONFIG_BPF_PROLOGUE is on

2015-10-08 Thread Wang Nan
regs_query_register_offset() in dwarf-regs.c is required by BPF prologue. Make it be compiled if CONFIG_BPF_PROLOGUE is on to avoid building failure when CONFIG_BPF_PROLOGUE is on but CONFIG_DWARF is not set. Signed-off-by: Wang Nan Signed-off-by: He Kuang Acked-by: Masami Hiramatsu Cc: Alexei

[PATCH 19/22] perf record: Support custom vmlinux path

2015-10-08 Thread Wang Nan
7;. This patch skips the short option name and use '--vmlinux' for vmlinux path. Signed-off-by: He Kuang Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Nam

[PATCH 18/22] perf tools: Use same BPF program if arguments are identical

2015-10-08 Thread Wang Nan
This patch utilizes qsort to sort tevs. After sorting, tevs with identical argument list will be grouped together. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Na

[PATCH 22/22] perf test: Test BPF prologue

2015-10-08 Thread Wang Nan
ns. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Zefan Li Cc: pi3or...@163.com Link: http://lkml

[PATCH 20/22] perf tools: Allow BPF program attach to uprobe events

2015-10-08 Thread Wang Nan
fore the main config string, we can use 'key=value' style options. Now the only option key "target" is for uprobe probing. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc

[PATCH 14/22] perf tools: Add BPF_PROLOGUE config options for further patches

2015-10-08 Thread Wang Nan
of a register to its offset in 'struct pt_regs'. Without this support, BPF_PROLOGUE should be turned off. HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET is introduced as the corresponding CFLAGS of PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Bre

[PATCH 06/22] perf tools: Collect perf_evsel in BPF object files

2015-10-08 Thread Wang Nan
.c will not be built if libbpf is turned off, an empty bpf__foreach_tev() is defined in bpf-loader.h to avoid compiling error. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramat

[PATCH 08/22] perf record: Add clang options for compiling BPF scripts

2015-10-08 Thread Wang Nan
Although previous patch allows setting BPF compiler related options in perfconfig, on some ad-hoc situation it still requires passing options through cmdline. This patch introduces 2 options to 'perf record' for this propose: --clang-path and --clang-opt. Signed-off-by: Wang Nan

[PATCH 03/22] perf tools: Enable passing bpf object file to --event

2015-10-08 Thread Wang Nan
events are possible to be extracted, to avoid perf report error because of empty evsel list, this patch link a dummy evsel. The dummy event related code will be removed when probing and extracting code is ready. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Arnaldo Carvalho de Melo Cc: Brendan

[PATCH 11/22] perf test: Add 'perf test BPF'

2015-10-08 Thread Wang Nan
times of it, so the resule should contains 56 samples. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc:

[PATCH 09/22] perf tools: Compile scriptlets to BPF objects when passing '.c' to --event

2015-10-08 Thread Wang Nan
t: # perf record --clang-opt "-DLINUX_VERSION_CODE=0x40200" --event ./bpf-script-example.c sleep 1 Note that '--clang-opt' must put before '--event'. Futher patches will merge it into a testcase so can be tested automatically. Signed-off-by: Wang Nan Signed-off-by: He Kuang Acked-by

[PATCH 10/22] perf test: Enforce LLVM test for BPF test

2015-10-08 Thread Wang Nan
7; method to tests, and makes test__llvm() create a MAP_SHARED memory array to hold the resulting object. Signed-off-by: He Kuang Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: Jiri Olsa Cc: Kaixu Xia Cc

[PATCH 07/22] perf tools: Attach eBPF program to perf event

2015-10-08 Thread Wang Nan
r one kprobe events for different CPUs. In this case, when trying to call the ioctl, EEXIST will be return. This patch doesn't treat it as an error. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu X

[PATCH 17/22] perf tools: Generate prologue for BPF programs

2015-10-08 Thread Wang Nan
rgument, simply skip preprocessor hooking. For those who prologue is required, calls bpf__gen_prologue() and paste original instruction after prologue. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia

[PATCH 0/4] perf tools: Allow adding --filter to BPF object

2015-08-27 Thread Wang Nan
This 4 patches will be appended into my next perf BPF pull request. Without them, current perf BPF implementation has a small problem that, if passing '--filter' after '--event test_bpf.o' event selection, the filter won't be correctly applied. Patch 1/4 append a new function to libbpf which allow

[PATCH 02/32] perf tools: Don't set cmdline_group_boundary if no evsel is collected

2015-08-27 Thread Wang Nan
checking number of entries, check data.list instead, so we can add dummy evsel here. [1]: http://lkml.kernel.org/n/1436445342-1402-19-git-send-email-wangn...@huawei.com Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3or...@163.com Cc

[PATCH 01/32] bpf tools: New API to get name from a BPF object

2015-08-27 Thread Wang Nan
ng is for each object. API of bpf_object__open_buffer() is changed to allow passing a name. Fortunately, at this time there's only one user of it (perf test LLVM), so we change it together. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuan

[PATCH 03/32] perf tools: Introduce dummy evsel

2015-08-27 Thread Wang Nan
purge_dummy() must be called right after parse_options(). This patch adds it to record, top, trace and stat builtin commands. Further patch moves it down after real BPF events are processed with. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Bor

[PATCH 12/32] perf tools: Allow filter option to be applied to bof object

2015-08-27 Thread Wang Nan
is appended to evlist. This patch fixes this by utilizing the dummy event linked during parse_events(). Filter settings goes to dummy event, and be synced with real events in add_bpf_event(). Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Aher

[GIT PULL 00/32] perf tools: filtering events using eBPF programs

2015-08-28 Thread Wang Nan
: - Call bpf__clear() in command 'record, top, stat and trace' to ensure release BPF related resources. - Correct --filter option when try to apply filter to BPF object. Signed-off-by: Wang Nan He Kuang (5): pe

[PATCH 01/32] bpf tools: New API to get name from a BPF object

2015-08-28 Thread Wang Nan
ng is for each object. API of bpf_object__open_buffer() is changed to allow passing a name. Fortunately, at this time there's only one user of it (perf test LLVM), so we change it together. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuan

[PATCH 20/32] perf tools: Fix probe-event.h include

2015-08-28 Thread Wang Nan
Commit 7b6ff0bdbf4f7f429c2116cca92a6d171217449e ("perf probe ppc64le: Fixup function entry if using kallsyms lookup") adds 'struct map' into probe-event.h but not include "util/map.h" in it. This patch fixes it. Signed-off-by: Wang Nan Cc: Alexei Starovoitov

[PATCH 06/32] perf tools: Enable passing bpf object file to --event

2015-08-28 Thread Wang Nan
foo.o' Run 'perf list' for a list of valid events usage: perf record [] [] or: perf record [] -- [] -e, --eventevent selector. use 'perf list' to list available events [root@felicio ~]# Yes, it does this time around. Signed-off-by: Wang Nan

[PATCH 23/32] perf tools: Add BPF_PROLOGUE config options for further patches

2015-08-28 Thread Wang Nan
register to its offset in 'struct pt_regs'. Without this support, BPF_PROLOGUE should be turned off. Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Namhyung Kim

[PATCH 25/32] perf tools: Add prologue for BPF programs for fetching arguments

2015-08-28 Thread Wang Nan
xit value for eBPF program * r1 - r5 - arguments from eBPF program to in-kernel function * r6 - r9 - callee saved registers that in-kernel function will preserve * r10 - read-only frame pointer to access stack Signed-off-by: He Kuang Signed-off

[PATCH 32/32] bpf: Introduce function for outputing data to perf event

2015-08-28 Thread Wang Nan
Ingo Molnar Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Steven Rostedt Cc: pi3or...@163.com Signed-off-by: Wang Nan Link: http://lkml.kernel.org/n/1437448130-134621-3-git-send-email-heku...@huawei.com --- include/trace/events/bpf.h

  1   2   3   4   5   6   7   8   9   10   >