Re: S390 support to be removed from next oprofile release
Andreas Arnez <[email protected]>
| Newsgroups | gmane.linux.oprofile |
|---|---|
| Organization | IBM Deutschland Research & Development GmbH |
| Message-ID | <[email protected]> |
On Tue, Aug 05 2014, Maynard Johnson wrote: > Andreas, those changes in the patch below look fine, but could you > please just add a "Signed-off-by:" line to make it official. Well, the patch was intended for illustration only since operf still failed. Nevertheless, I'm attaching a revised version of the patch (broken up into a 3-part series), because it is certainly needed for s390. Additional fixes may have to come on top. >> [root@p23lp54 arnez]# operf --verbose=all -s >> Using samples dir /root/arnez/oprofile_data/samples >> kernel_start = 0; kernel_end = 778848 >> operf_record ctor using output fd 7 >> calling sigaction >> calling setup >> operf_record::setup() for system-wide profiling >> op_get_process_info >> calling perf_event_open for pid -1 on 24 cpus >> perf_event_open failed: No such file or directory > This is the perf_event_open syscall failing with ENOENT when we pass "-1" for both > 'pid' and 'cpu' arguments for when we want to do system-wide profiling. You'd have > to look at the kernel to see why it fails (probably start with arch/s390/kernel/perf_cpum_sf.c). > I would bet a non-system-wide profile would work OK (e.g., 'operf /bin/true'). No, I tried that as well, with the same result. After some more digging, here's what I found out for s390: * First, back to the linker's complaint at a C++ static string initializer when linking ocount with -lrt and without -lpthread. Now I realized that removing -lrt works as well. It seems that ocount doesn't actually need librt (anymore), right? * With "-e HWSAMPLING", ocount fails at perf_event_open. This is because the s390 kernel forbids PERF_TYPE_RAW in combination with the exclude_hv attribute field being set. Without "-e", ocount doesn't set the flag and seems to work. -- Why does ocount behave differently in these cases? * operf always fails at perf_event_open, because it specifies the wrong combination of "type" and "config" fields. The combinations supported by the kernel are: type | config -------------------+---------------------------------- PERF_TYPE_RAW | PERF_EVENT_CPUM_SF (0xb0000) PERF_TYPE_RAW | PERF_EVENT_CPUM_SF_DIAG (0xbd000) PERF_TYPE_HARDWARE | PERF_COUNT_HW_CPU_CYCLES (0) But operf provides type=PERF_TYPE_RAW and config=0. If the s390-specific event definition file contains "event:0xB0000" instead of "event:0", operf works, but then ocount fails. The combinations supported by the kernel obviously differ between counting and profiling. -- How should we go about reflecting this in oprofile? So, while the patches below are certainly needed, oprofile still fails on s390. Any ideas how to fix the problems above? -- >8 -- >From f7178d46f4c9126fe77ed313a4d27eeede971f49 Mon Sep 17 00:00:00 2001 From: Andreas Arnez <[email protected]> Date: Thu, 7 Aug 2014 17:37:07 +0000 Subject: [PATCH 1/3] No longer link ocount with librt. Linking with librt but without libpthread may cause linker errors on certain platforms, and it seems that nothing from librt is used at all (anymore). Signed-off-by: Andreas Arnez <[email protected]> --- pe_counting/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pe_counting/Makefile.am b/pe_counting/Makefile.am index c46fd74..3565d65 100644 --- a/pe_counting/Makefile.am +++ b/pe_counting/Makefile.am @@ -19,7 +19,7 @@ AM_CXXFLAGS = @OP_CXXFLAGS@ AM_LDFLAGS = @OP_LDFLAGS@ bin_PROGRAMS = ocount -ocount_LDADD = -lrt ../libpe_utils/libpe_utils.a \ +ocount_LDADD = ../libpe_utils/libpe_utils.a \ ../libpe_utils/libpe_utils.a \ ../libop/libop.a \ ../libutil/libutil.a \ -- 1.8.4.2 >From f9f60052e27fb805418a22aef9c1ab3e886a5765 Mon Sep 17 00:00:00 2001 From: Andreas Arnez <[email protected]> Date: Thu, 7 Aug 2014 17:40:44 +0000 Subject: [PATCH 2/3] oprofile: Accept zero as a valid kernel start address. Signed-off-by: Andreas Arnez <[email protected]> --- pe_profiling/operf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp index 51f55a5..efc3c65 100644 --- a/pe_profiling/operf.cpp +++ b/pe_profiling/operf.cpp @@ -1099,7 +1099,7 @@ static bool _add_kernel_entry(string start_addr_str, string end_addr_str, string return false; } - if ((start_addr == 0) || (end_addr == 0)) { + if ((start_addr == 0) && (end_addr == 0)) { no_vmlinux = true; cerr << "Kernel profiling is not possible with current system " << "config." << endl -- 1.8.4.2 >From cc971389de68b998cba9047d2a1c47f61b4783d1 Mon Sep 17 00:00:00 2001 From: Andreas Arnez <[email protected]> Date: Thu, 7 Aug 2014 17:45:15 +0000 Subject: [PATCH 3/3] S390: Swap logic for choosing the default event. The existing logic for choosing the default event was exactly turned around. Signed-off-by: Andreas Arnez <[email protected]> --- libop/op_events.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libop/op_events.c b/libop/op_events.c index bbeb212..33028b4 100644 --- a/libop/op_events.c +++ b/libop/op_events.c @@ -1323,14 +1323,14 @@ void op_default_event(op_cpu cpu_type, struct op_default_event_descr * descr) case CPU_S390_Z10: case CPU_S390_Z196: case CPU_S390_ZEC12: - if (op_get_nr_counters(cpu_type) > 1) { - descr->name = "HWSAMPLING"; - descr->count = 4127518; - } else { - descr->name = TIMER_EVENT_NAME; - descr->count = 10000; - } - break; + if (op_get_nr_counters(cpu_type) > 1) { + descr->name = TIMER_EVENT_NAME; + descr->count = 10000; + } else { + descr->name = "HWSAMPLING"; + descr->count = 4127518; + } + break; case CPU_TILE_TILE64: case CPU_TILE_TILEPRO: -- 1.8.4.2 ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds