Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752559AbdGFBsn (ORCPT ); Wed, 5 Jul 2017 21:48:43 -0400 Received: from sub5.mail.dreamhost.com ([208.113.200.129]:58759 "EHLO homiemail-a83.g.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752803AbdGFBsl (ORCPT ); Wed, 5 Jul 2017 21:48:41 -0400 From: Krister Johansen To: Arnaldo Carvalho de Melo , Brendan Gregg Cc: Peter Zijlstra , Ingo Molnar , Alexander Shishkin , linux-kernel@vger.kernel.org, Thomas-Mich Richter , Krister Johansen Subject: [PATCH v2 tip/perf/core 5/6] perf top: support lookup of symbols in other mount namespaces. Date: Wed, 5 Jul 2017 18:48:12 -0700 Message-Id: <1499305693-1599-6-git-send-email-kjlx@templeofstupid.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499305693-1599-1-git-send-email-kjlx@templeofstupid.com> References: <20170705204511.GD29683@templeofstupid.com> <1499305693-1599-1-git-send-email-kjlx@templeofstupid.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2254 Lines: 68 The perf top command needs to unshare its fs from the helper threads in order to successfully setns(2) during its symbol lookup. It also needs to impelement a force flag to ignore ownership of perf-.map files. Signed-off-by: Krister Johansen --- tools/perf/Documentation/perf-top.txt | 4 ++++ tools/perf/builtin-top.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt index e71d638..d864ea6 100644 --- a/tools/perf/Documentation/perf-top.txt +++ b/tools/perf/Documentation/perf-top.txt @@ -237,6 +237,10 @@ Default is to monitor all CPUS. --hierarchy:: Enable hierarchy output. +--force:: + Don't do ownership validation. + + INTERACTIVE PROMPTING KEYS -------------------------- diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 6052376..ef2aef4 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -586,6 +586,13 @@ static void *display_thread_tui(void *arg) .refresh = top->delay_secs, }; + /* In order to read symbols from other namespaces perf to needs to call + * setns(2). This isn't permitted if the struct_fs has multiple users. + * unshare(2) the fs so that we may continue to setns into namespaces + * that we're observing. + */ + (void) unshare(CLONE_FS); + perf_top__sort_new_samples(top); /* @@ -627,6 +634,13 @@ static void *display_thread(void *arg) struct perf_top *top = arg; int delay_msecs, c; + /* In order to read symbols from other namespaces perf to needs to call + * setns(2). This isn't permitted if the struct_fs has multiple users. + * unshare(2) the fs so that we may continue to setns into namespaces + * that we're observing. + */ + (void) unshare(CLONE_FS); + display_setup_sig(); pthread__unblock_sigwinch(); repeat: @@ -1205,6 +1219,7 @@ int cmd_top(int argc, const char **argv) "Show raw trace event output (do not use print fmt or plugins)"), OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy, "Show entries in a hierarchy"), + OPT_BOOLEAN(0, "force", &symbol_conf.force, "don't complain, do it"), OPT_END() }; const char * const top_usage[] = { -- 2.7.4