Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756284AbdCGUmO (ORCPT ); Tue, 7 Mar 2017 15:42:14 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51845 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756265AbdCGUmK (ORCPT ); Tue, 7 Mar 2017 15:42:10 -0500 Subject: [PATCH v8 4/6] perf tools: Add print support for namespace events From: Hari Bathini To: ast@fb.com, peterz@infradead.org, lkml , acme@kernel.org, alexander.shishkin@linux.intel.com, mingo@redhat.com Cc: daniel@iogearbox.net, rostedt@goodmis.org, Ananth N Mavinakayanahalli , ebiederm@xmission.com, sargun@sargun.me, Aravinda Prasad , brendan.d.gregg@gmail.com, jolsa@redhat.com Date: Wed, 08 Mar 2017 02:11:59 +0530 In-Reply-To: <148891921533.25309.8328657213311313206.stgit@hbathini.in.ibm.com> References: <148891921533.25309.8328657213311313206.stgit@hbathini.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable x-cbid: 17030720-0012-0000-0000-000003C6A4E6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030720-0013-0000-0000-00001B4BF961 Message-Id: <148891931914.25309.9322505014996282758.stgit@hbathini.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-07_16:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703070162 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3207 Lines: 84 Add print support for events of type PERF_RECORD_NAMESPACES. Acked-by: Jiri Olsa Signed-off-by: Hari Bathini --- tools/perf/util/event.c | 30 ++++++++++++++++++++++++++++++ tools/perf/util/event.h | 1 + tools/perf/util/machine.c | 3 +++ 3 files changed, 34 insertions(+) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 5a99af8..022587e 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1108,6 +1108,33 @@ size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp) return fprintf(fp, "%s: %s:%d/%d\n", s, event->comm.comm, event->comm.pid, event->comm.tid); } +size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp) +{ + size_t ret = 0; + struct perf_ns_link_info *ns_link_info; + u32 nr_namespaces, idx; + + ns_link_info = event->namespaces.link_info; + nr_namespaces = event->namespaces.nr_namespaces; + + ret += fprintf(fp, " %d/%d - nr_namespaces: %u\n\t\t[", + event->namespaces.pid, + event->namespaces.tid, + nr_namespaces); + + for (idx = 0; idx < nr_namespaces; idx++) { + if (idx && (idx % 4 == 0)) + ret += fprintf(fp, "\n\t\t "); + + ret += fprintf(fp, "%u/%s: %lu/0x%lx%s", idx, + perf_ns__name(idx), (u64)ns_link_info[idx].dev, + (u64)ns_link_info[idx].ino, + ((idx + 1) != nr_namespaces) ? ", " : "]\n"); + } + + return ret; +} + int perf_event__process_comm(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, @@ -1304,6 +1331,9 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp) case PERF_RECORD_MMAP: ret += perf_event__fprintf_mmap(event, fp); break; + case PERF_RECORD_NAMESPACES: + ret += perf_event__fprintf_namespaces(event, fp); + break; case PERF_RECORD_MMAP2: ret += perf_event__fprintf_mmap2(event, fp); break; diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index a46a1b4..e1d8166 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -671,6 +671,7 @@ size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp); size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp); size_t perf_event__fprintf_thread_map(union perf_event *event, FILE *fp); size_t perf_event__fprintf_cpu_map(union perf_event *event, FILE *fp); +size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp); size_t perf_event__fprintf(union perf_event *event, FILE *fp); u64 kallsyms__get_function_start(const char *kallsyms_filename, diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 16e7325..dfc6004 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -519,6 +519,9 @@ int machine__process_namespaces_event(struct machine *machine __maybe_unused, "\nWARNING: perf tool seems to support more namespaces than" " the kernel.\nTry updating the kernel..\n\n"); + if (dump_trace) + perf_event__fprintf_namespaces(event, stdout); + if (thread == NULL || thread__set_namespaces(thread, sample->time, &event->namespaces)) { dump_printf("problem processing PERF_RECORD_NAMESPACES, skipping event.\n");