From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755694AbdIGR4f (ORCPT ); Thu, 7 Sep 2017 13:56:35 -0400 Received: from mga09.intel.com ([134.134.136.24]:13892 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755591AbdIGR4c (ORCPT ); Thu, 7 Sep 2017 13:56:32 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,359,1500966000"; d="scan'208";a="149347725" From: kan.liang@intel.com To: acme@kernel.org, peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: jolsa@kernel.org, namhyung@kernel.org, adrian.hunter@intel.com, lukasz.odzioba@intel.com, ak@linux.intel.com, Kan Liang Subject: [PATCH RFC 04/10] petf tools: introduce a new function to set namespaces id Date: Thu, 7 Sep 2017 10:55:48 -0700 Message-Id: <1504806954-150842-5-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1504806954-150842-1-git-send-email-kan.liang@intel.com> References: <1504806954-150842-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang Finish the namespaces id setting job in thread.c. Signed-off-by: Kan Liang --- tools/perf/util/hist.c | 6 +----- tools/perf/util/thread.c | 10 ++++++++++ tools/perf/util/thread.h | 2 ++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 0f00dd9..1f467cc 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -584,14 +584,9 @@ __hists__add_entry(struct hists *hists, bool sample_self, struct hist_entry_ops *ops) { - struct namespaces *ns = thread__namespaces(al->thread); struct hist_entry entry = { .thread = al->thread, .comm_str = thread__comm_str(al->thread), - .cgroup_id = { - .dev = ns ? ns->link_info[CGROUP_NS_INDEX].dev : 0, - .ino = ns ? ns->link_info[CGROUP_NS_INDEX].ino : 0, - }, .ms = { .map = al->map, .sym = al->sym, @@ -617,6 +612,7 @@ __hists__add_entry(struct hists *hists, .ops = ops, }; + thread__namespaces_id(al->thread, &entry.cgroup_id.dev, &entry.cgroup_id.ino); return hists__findnew_entry(hists, &entry, al, sample_self); } diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index aee9a42..b7957da 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -149,6 +149,16 @@ int thread__set_namespaces(struct thread *thread, u64 timestamp, return 0; } +void thread__namespaces_id(const struct thread *thread, + u64 *dev, u64 *ino) +{ + struct namespaces *ns; + + ns = thread__namespaces(thread); + *dev = ns ? ns->link_info[CGROUP_NS_INDEX].dev : 0; + *ino = ns ? ns->link_info[CGROUP_NS_INDEX].ino : 0; +} + struct comm *thread__comm(const struct thread *thread) { if (list_empty(&thread->comm_list)) diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index cb1a5dd..fd7bd41 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h @@ -68,6 +68,8 @@ static inline void thread__exited(struct thread *thread) struct namespaces *thread__namespaces(const struct thread *thread); int thread__set_namespaces(struct thread *thread, u64 timestamp, struct namespaces_event *event); +void thread__namespaces_id(const struct thread *thread, + u64 *dev, u64 *ino); int __thread__set_comm(struct thread *thread, const char *comm, u64 timestamp, bool exec); -- 2.5.5