linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Andrey Vagin <avagin@openvz.org>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 16/19] perf trace beauty: Implement pid_fd beautifier
Date: Fri,  3 Nov 2017 10:55:00 -0300	[thread overview]
Message-ID: <20171103135503.4921-17-acme@kernel.org> (raw)
In-Reply-To: <20171103135503.4921-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

One that given a pid and a fd, will try to get the path for that fd.
Will be used in the upcoming kcmp's KCMP_FILE beautifier.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andrey Vagin <avagin@openvz.org>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-7ketygp2dvs9h13wuakfncws@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-trace.c       | 17 +++++++++++++++++
 tools/perf/trace/beauty/beauty.h |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index c373f9a3e4a9..0c1461416ef1 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -988,6 +988,23 @@ size_t syscall_arg__scnprintf_fd(char *bf, size_t size, struct syscall_arg *arg)
 	return printed;
 }
 
+size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_t size)
+{
+        size_t printed = scnprintf(bf, size, "%d", fd);
+	struct thread *thread = machine__find_thread(trace->host, pid, pid);
+
+	if (thread) {
+		const char *path = thread__fd_path(thread, fd, trace);
+
+		if (path)
+			printed += scnprintf(bf + printed, size - printed, "<%s>", path);
+
+		thread__put(thread);
+	}
+
+        return printed;
+}
+
 static size_t syscall_arg__scnprintf_close_fd(char *bf, size_t size,
 					      struct syscall_arg *arg)
 {
diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h
index b29f94ef5d6a..365bb6fecc1c 100644
--- a/tools/perf/trace/beauty/beauty.h
+++ b/tools/perf/trace/beauty/beauty.h
@@ -3,6 +3,7 @@
 
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <sys/types.h>
 
 struct strarray {
 	int	    offset;
@@ -26,6 +27,8 @@ size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const cha
 struct trace;
 struct thread;
 
+size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_t size);
+
 /**
  * @val: value of syscall argument being formatted
  * @args: All the args, use syscall_args__val(arg, nth) to access one
-- 
2.13.6

  parent reply	other threads:[~2017-11-03 13:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03 13:54 [GIT PULL 00/19] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 01/19] perf script: Add a few missing conversions to fprintf style Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 02/19] perf script: Use pr_debug where appropriate Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 03/19] perf script: Use event_format__fprintf() Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 04/19] perf evsel: Restore evsel->priv as a tool private area Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 05/19] perf script: Allow creating per-event dump files Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 06/19] tools include uapi: Grab a copy of linux/prctl.h Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 07/19] perf trace beauty prctl: Generate 'option' string table from kernel headers Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 08/19] perf script: Print information about per-event-dump files Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 09/19] perf tools: Rename struct perf_data_file to perf_data Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 10/19] perf tools: Add struct perf_data_file Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 11/19] perf tools: Add perf_data_file__write function Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 12/19] perf stat: Move the shadow stats scale computation in perf_stat__update_shadow_stats Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 13/19] perf stat: Make --per-thread update shadow stats to show metrics Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 14/19] perf callchain: Fix double mapping al->addr for children without self period Arnaldo Carvalho de Melo
2017-11-03 13:54 ` [PATCH 15/19] tools include uapi: Grab a copy of linux/kcmp.h Arnaldo Carvalho de Melo
2017-11-03 13:55 ` Arnaldo Carvalho de Melo [this message]
2017-11-03 13:55 ` [PATCH 17/19] perf trace beauty kcmp: Beautify arguments Arnaldo Carvalho de Melo
2017-11-03 13:55 ` [PATCH 18/19] perf srcline: Fix memory leak in addr2inlines() Arnaldo Carvalho de Melo
2017-11-03 13:55 ` [PATCH 19/19] perf srcline: Show correct function name for srcline of callchains Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171103135503.4921-17-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=avagin@openvz.org \
    --cc=dsahern@gmail.com \
    --cc=gorcunov@openvz.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).