All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Krister Johansen <kjlx@templeofstupid.com>,
	Hari Bathini <hbathini@linux.vnet.ibm.com>
Subject: [PATCH 2/3] perf tools: Add missing swap ops for namespace events
Date: Wed, 22 May 2019 14:32:49 +0900	[thread overview]
Message-ID: <20190522053250.207156-3-namhyung@kernel.org> (raw)
In-Reply-To: <20190522053250.207156-1-namhyung@kernel.org>

In case it's recorded from other arch.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/session.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 2310a1752983..54cf163347f7 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -647,6 +647,26 @@ static void perf_event__throttle_swap(union perf_event *event,
 		swap_sample_id_all(event, &event->throttle + 1);
 }
 
+static void perf_event__namespaces_swap(union perf_event *event,
+					bool sample_id_all)
+{
+	u64 i;
+
+	event->namespaces.pid		= bswap_32(event->namespaces.pid);
+	event->namespaces.tid		= bswap_32(event->namespaces.tid);
+	event->namespaces.nr_namespaces	= bswap_64(event->namespaces.nr_namespaces);
+
+	for (i = 0; i < event->namespaces.nr_namespaces; i++) {
+		struct perf_ns_link_info *ns = &event->namespaces.link_info[i];
+
+		ns->dev = bswap_64(ns->dev);
+		ns->ino = bswap_64(ns->ino);
+	}
+
+	if (sample_id_all)
+		swap_sample_id_all(event, &event->namespaces.link_info[i]);
+}
+
 static u8 revbyte(u8 b)
 {
 	int rev = (b >> 4) | ((b & 0xf) << 4);
@@ -887,6 +907,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
 	[PERF_RECORD_LOST_SAMPLES]	  = perf_event__all64_swap,
 	[PERF_RECORD_SWITCH]		  = perf_event__switch_swap,
 	[PERF_RECORD_SWITCH_CPU_WIDE]	  = perf_event__switch_swap,
+	[PERF_RECORD_NAMESPACES]	  = perf_event__namespaces_swap,
 	[PERF_RECORD_HEADER_ATTR]	  = perf_event__hdr_attr_swap,
 	[PERF_RECORD_HEADER_EVENT_TYPE]	  = perf_event__event_type_swap,
 	[PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap,
-- 
2.21.0.1020.gf2820cf01a-goog


  parent reply	other threads:[~2019-05-22  5:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22  5:32 [PATCH 0/3] perf tools: Assorted fixes and cleanups for namespace events Namhyung Kim
2019-05-22  5:32 ` [PATCH 1/3] perf tools: Protect reading thread's namespace Namhyung Kim
2019-05-22 13:18   ` Arnaldo Carvalho de Melo
2019-05-23  2:36     ` Namhyung Kim
2019-05-27  6:11       ` [PATCH 4/3] perf tools: Remove const from thread read accessors Namhyung Kim
2019-05-27 14:15         ` Arnaldo Carvalho de Melo
2019-05-30  8:07         ` [tip:perf/core] " tip-bot for Namhyung Kim
2019-05-28 21:27   ` [tip:perf/urgent] perf namespace: Protect reading thread's namespace tip-bot for Namhyung Kim
2019-05-22  5:32 ` Namhyung Kim [this message]
2019-05-22 13:23   ` [PATCH 2/3] perf tools: Add missing swap ops for namespace events Arnaldo Carvalho de Melo
2019-05-28 21:28   ` [tip:perf/urgent] perf session: " tip-bot for Namhyung Kim
2019-05-22  5:32 ` [PATCH 3/3] perf top: Enable --namespaces option Namhyung Kim
2019-05-22 13:24   ` Arnaldo Carvalho de Melo
2019-05-23  2:42     ` Namhyung Kim
2019-05-30  8:06   ` [tip:perf/core] perf top: Add " tip-bot for Namhyung Kim

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=20190522053250.207156-3-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=hbathini@linux.vnet.ibm.com \
    --cc=jolsa@redhat.com \
    --cc=kjlx@templeofstupid.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.