Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3323041yba; Tue, 16 Apr 2019 09:03:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSP+g3OcLEnVuyjN/cmJmGubdGY3ZxoIzyPdNfyOycOTIMUCIpiPh7dYEbo3vApfFQZOoH X-Received: by 2002:a63:6786:: with SMTP id b128mr77976635pgc.318.1555430609528; Tue, 16 Apr 2019 09:03:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555430609; cv=none; d=google.com; s=arc-20160816; b=k0r4hNlAGAqHkGYr3XePZt7U5jmK/pivofAdLhzXNrh9Er1zmkSIGGt4j6lVpjbNgu RhLZFu2RLnruoIZ36NALxuPY8on3s49es5YEg/zahQ4QLvn67VnIqmn+zQA9bxKKcLHn tp13napd4hENJA0TXuZef5kVV3kX9JyIFxpXrJ/HCuVWDhFTzpikubyvSVp3wCeh6j+5 jn1WRph0Sp0AcW2yqoId/TNpDIw7f4Tr/D/AJRdGaKMyCxxN+A3scubi/K3Ygerdd7is gm6qo4JELtr3TCYz5G8aX50B28X/n6gXULLlKwWk1OMvYxY3uRla/5l4Vmv3rETsU3HZ GM0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=KajwjMEpaoX7nl4Mlg34PZH3296mzIWQunaW1qpUuIY=; b=06w9wsV8uWK8rUflhC0/opNhWUGrqqZCzyQ90EfB/hhz8z1giLaiYvQUrFQ0A+ETtM NftIr8+NW8Wl2LHkWSLT2o2GIxd/4n/9Z88FegwAFI125KEkVUjUXa3ArxxWU4AxaFub unyzjSBLNPzbe60cLnmDBkDVgqs2UkspbAMKK1L0u0BE/k5/0SCNRelJNJcINA8Qw9AX FQt3nCbquSBogR9x87KTwLqeXfcOoYdmzrFO3RFPXhvVKmwBv/reanGUq6cyw82wIyit RedwKRWb7CpURieGePuGFR1dZEKg1g+jZ8rZ+LWrQ9Y41WHLdrtPyfPCgI/u3Lu8izEN OgBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10si47964228plr.229.2019.04.16.09.03.13; Tue, 16 Apr 2019 09:03:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730089AbfDPQCN (ORCPT + 99 others); Tue, 16 Apr 2019 12:02:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44412 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbfDPQCL (ORCPT ); Tue, 16 Apr 2019 12:02:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 039F8308404C; Tue, 16 Apr 2019 16:02:11 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id B22745D71B; Tue, 16 Apr 2019 16:02:08 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Andi Kleen , Adrian Hunter , Song Liu , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH 12/12] perf script: Pad dso name for --call-trace Date: Tue, 16 Apr 2019 18:01:27 +0200 Message-Id: <20190416160127.30203-13-jolsa@kernel.org> In-Reply-To: <20190416160127.30203-1-jolsa@kernel.org> References: <20190416160127.30203-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 16 Apr 2019 16:02:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org so we don't have the indent screwed by different dso name lenghts, as now for kernel there's also bpf code displayed. # perf-with-kcore record pt -e intel_pt//ku -- sleep 1 # perf-core/perf-with-kcore script pt --call-trace Before: sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms]) kretprobe_perf_func sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms]) trace_call_bpf sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_get_current_pid_tgid sleep 36660 [016] 1057036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_ktime_get_ns sleep 36660 [016] 1057036.806464725: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806464725: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806465045: (bpf_prog_da4fe6b3d2c29b25_trace_return) __htab_map_lookup_elem sleep 36660 [016] 1057036.806465366: ([kernel.kallsyms]) memcmp sleep 36660 [016] 1057036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_probe_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms]) probe_kernel_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms]) __check_object_size sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms]) check_stack_object sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms]) copy_user_enhanced_fast_string sleep 36660 [016] 1057036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_probe_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms]) probe_kernel_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms]) __check_object_size sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms]) check_stack_object sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms]) copy_user_enhanced_fast_string sleep 36660 [016] 1057036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_get_current_uid_gid sleep 36660 [016] 1057036.806466008: ([kernel.kallsyms]) from_kgid sleep 36660 [016] 1057036.806466008: ([kernel.kallsyms]) from_kuid sleep 36660 [016] 1057036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_perf_event_output sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms]) perf_event_output sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms]) perf_prepare_sample sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms]) perf_misc_flags sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806466328: ([kvm]) kvm_is_in_guest sleep 36660 [016] 1057036.806466649: ([kernel.kallsyms]) __perf_event_header__init_id.isra.0 sleep 36660 [016] 1057036.806466649: ([kernel.kallsyms]) perf_output_begin After: sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms] ) kretprobe_perf_func sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms] ) trace_call_bpf sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806464404: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_get_current_pid_tgid sleep 36660 [016] 1057036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_ktime_get_ns sleep 36660 [016] 1057036.806464725: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806464725: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806465045: (bpf_prog_da4fe6b3d2c29b25_trace_return ) __htab_map_lookup_elem sleep 36660 [016] 1057036.806465366: ([kernel.kallsyms] ) memcmp sleep 36660 [016] 1057036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_probe_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) probe_kernel_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) __check_object_size sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) check_stack_object sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) copy_user_enhanced_fast_string sleep 36660 [016] 1057036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_probe_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) probe_kernel_read sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) __check_object_size sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) check_stack_object sleep 36660 [016] 1057036.806465687: ([kernel.kallsyms] ) copy_user_enhanced_fast_string sleep 36660 [016] 1057036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_get_current_uid_gid sleep 36660 [016] 1057036.806466008: ([kernel.kallsyms] ) from_kgid sleep 36660 [016] 1057036.806466008: ([kernel.kallsyms] ) from_kuid sleep 36660 [016] 1057036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return ) bpf_perf_event_output sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms] ) perf_event_output sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms] ) perf_prepare_sample sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms] ) perf_misc_flags sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 36660 [016] 1057036.806466328: ([kernel.kallsyms] ) __x86_indirect_thunk_rax Link: http://lkml.kernel.org/n/tip-99g9rg4p20a1o99vr0nkjhq8@git.kernel.org Signed-off-by: Jiri Olsa --- tools/include/linux/kernel.h | 1 + tools/lib/vsprintf.c | 19 +++++++++++++++++++ tools/perf/builtin-script.c | 1 + tools/perf/util/map.c | 6 ++++++ tools/perf/util/symbol_conf.h | 1 + 5 files changed, 28 insertions(+) diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h index 857d9e22826e..cba226948a0c 100644 --- a/tools/include/linux/kernel.h +++ b/tools/include/linux/kernel.h @@ -102,6 +102,7 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); int scnprintf(char * buf, size_t size, const char * fmt, ...); +int scnprintf_pad(char * buf, size_t size, const char * fmt, ...); #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) diff --git a/tools/lib/vsprintf.c b/tools/lib/vsprintf.c index e08ee147eab4..149a15013b23 100644 --- a/tools/lib/vsprintf.c +++ b/tools/lib/vsprintf.c @@ -23,3 +23,22 @@ int scnprintf(char * buf, size_t size, const char * fmt, ...) return (i >= ssize) ? (ssize - 1) : i; } + +int scnprintf_pad(char * buf, size_t size, const char * fmt, ...) +{ + ssize_t ssize = size; + va_list args; + int i; + + va_start(args, fmt); + i = vsnprintf(buf, size, fmt, args); + va_end(args); + + if (i < (int) size) { + for (; i < (int) size; i++) + buf[i] = ' '; + buf[i] = 0x0; + } + + return (i >= ssize) ? (ssize - 1) : i; +} diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 61cfd8f70989..7adaa6c63a0b 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3297,6 +3297,7 @@ static int parse_call_trace(const struct option *opt __maybe_unused, parse_output_fields(NULL, "-ip,-addr,-event,-period,+callindent", 0); itrace_parse_synth_opts(opt, "cewp", 0); symbol_conf.nanosecs = true; + symbol_conf.pad_output_len_dso = 50; return 0; } diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index ee71efb9db62..c3fbd6e556b0 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -405,6 +405,7 @@ size_t map__fprintf(struct map *map, FILE *fp) size_t map__fprintf_dsoname(struct map *map, FILE *fp) { + char buf[PATH_MAX]; const char *dsoname = "[unknown]"; if (map && map->dso) { @@ -414,6 +415,11 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp) dsoname = map->dso->name; } + if (symbol_conf.pad_output_len_dso) { + scnprintf_pad(buf, symbol_conf.pad_output_len_dso, "%s", dsoname); + dsoname = buf; + } + return fprintf(fp, "%s", dsoname); } diff --git a/tools/perf/util/symbol_conf.h b/tools/perf/util/symbol_conf.h index 6c55fa6fccec..382ba63fc554 100644 --- a/tools/perf/util/symbol_conf.h +++ b/tools/perf/util/symbol_conf.h @@ -69,6 +69,7 @@ struct symbol_conf { *tid_list; const char *symfs; int res_sample; + int pad_output_len_dso; }; extern struct symbol_conf symbol_conf; -- 2.17.2