From patchwork Sat Aug 29 04:21:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 52820 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 540C122FE2 for ; Sat, 29 Aug 2015 04:23:58 +0000 (UTC) Received: by lbcli1 with SMTP id li1sf22485722lbc.2 for ; Fri, 28 Aug 2015 21:23:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=vsc2YtK8ySRUrcroq2/+z6PiBKxIGzkEviIZZOCZcXY=; b=d2VNqFG0AmATz+lzd3XD8Ife7cxsF+8y6ae42lSzVtirqPlvpyNXeoc4vvKwczba5+ 3+l3jeuSOJoXyc1peSsdvEsBeHzud1rLH641z8T9bDDKeGwJ5ua5nQWcb9p2hfcNDadk wmjdvXuet9kYUMjXXHyXfM1Xd6gDc2b7AFqk+ppugqyoDgRxCjgLET1ih9HIBymyHw04 wOAhBFUNSdgJX5UHFCNXUrXg2JNhyoMTj6x5h8x95caUfAX3i8byvLloMP0ISCg5Qos3 ury/OHpXLu+WgO/GgJ5myKkq9HDyegfSuZaaqdwGMv0bGCrBxkLsQSvvRqvgVlDOD6HX yy9A== X-Gm-Message-State: ALoCoQmvkwrimonZOmsDg8u3t2mgrS2+/xe842x/pdUEaay+oKApYVnsn1pgK2Vk+8mAFyJ8takt X-Received: by 10.112.148.101 with SMTP id tr5mr3555584lbb.13.1440822237327; Fri, 28 Aug 2015 21:23:57 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.219.4 with SMTP id pk4ls284927lac.90.gmail; Fri, 28 Aug 2015 21:23:57 -0700 (PDT) X-Received: by 10.152.44.232 with SMTP id h8mr6135209lam.104.1440822237166; Fri, 28 Aug 2015 21:23:57 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id l6si7671513lbm.27.2015.08.28.21.23.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Aug 2015 21:23:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbsx3 with SMTP id sx3so39519476lbb.0 for ; Fri, 28 Aug 2015 21:23:57 -0700 (PDT) X-Received: by 10.152.36.102 with SMTP id p6mr6116503laj.19.1440822237046; Fri, 28 Aug 2015 21:23:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.151.194 with SMTP id us2csp267460lbb; Fri, 28 Aug 2015 21:23:56 -0700 (PDT) X-Received: by 10.67.8.40 with SMTP id dh8mr19970462pad.129.1440822235868; Fri, 28 Aug 2015 21:23:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fl4si13359526pdb.129.2015.08.28.21.23.54; Fri, 28 Aug 2015 21:23:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752538AbbH2EXp (ORCPT + 28 others); Sat, 29 Aug 2015 00:23:45 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:39754 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752344AbbH2EXl (ORCPT ); Sat, 29 Aug 2015 00:23:41 -0400 Received: from 172.24.1.47 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.47]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CTY94460; Sat, 29 Aug 2015 12:23:12 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Sat, 29 Aug 2015 12:23:06 +0800 From: Wang Nan To: , , CC: , , , Wang Nan , Brendan Gregg , Daniel Borkmann , David Ahern , "He Kuang" , Jiri Olsa , Kaixu Xia , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra Subject: [PATCH 14/31] perf tools: Suppress probing messages when probing by BPF loading Date: Sat, 29 Aug 2015 04:21:48 +0000 Message-ID: <1440822125-52691-15-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1440822125-52691-1-git-send-email-wangnan0@huawei.com> References: <1440822125-52691-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangnan0@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch suppresses message output by add_perf_probe_events() and del_perf_probe_events() if they are triggered by BPF loading. Before this patch, when using 'perf record' with BPF object/source as event selector, following message will be output: Added new event: perf_bpf_probe:lock_page_ret (on __lock_page%return) You can now use it in all perf tools, such as: perf record -e perf_bpf_probe:lock_page_ret -aR sleep 1 ... Removed event: perf_bpf_probe:lock_page_ret Which is misleading, especially 'use it in all perf tools' because they will be removed after 'pref record' exit. In this patch, a 'silent' field is appended into probe_conf to control output. bpf__{,un}probe() set it to true when calling {add,del}_perf_probe_events(). Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Brendan Gregg Cc: Daniel Borkmann Cc: David Ahern Cc: He Kuang Cc: Jiri Olsa Cc: Kaixu Xia Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/n/1440151770-129878-12-git-send-email-wangnan0@huawei.com --- tools/perf/util/bpf-loader.c | 6 ++++++ tools/perf/util/probe-event.c | 17 ++++++++++++----- tools/perf/util/probe-event.h | 1 + tools/perf/util/probe-file.c | 5 ++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index c3bc0a8..77eeb99 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -188,6 +188,7 @@ static bool is_probed; int bpf__unprobe(void) { struct strfilter *delfilter; + bool old_silent = probe_conf.silent; int ret; if (!is_probed) @@ -199,7 +200,9 @@ int bpf__unprobe(void) return -ENOMEM; } + probe_conf.silent = true; ret = del_perf_probe_events(delfilter); + probe_conf.silent = old_silent; strfilter__delete(delfilter); if (ret < 0 && is_probed) pr_debug("Error: failed to delete events: %s\n", @@ -215,6 +218,7 @@ int bpf__probe(void) struct bpf_object *obj, *tmp; struct bpf_program *prog; struct perf_probe_event *pevs; + bool old_silent = probe_conf.silent; pevs = calloc(MAX_PROBES, sizeof(pevs[0])); if (!pevs) @@ -235,9 +239,11 @@ int bpf__probe(void) } } + probe_conf.silent = true; probe_conf.max_probes = MAX_PROBES; /* Let add_perf_probe_events generates probe_trace_event (tevs) */ err = add_perf_probe_events(pevs, nr_events, false); + probe_conf.silent = old_silent; /* add_perf_probe_events return negative when fail */ if (err < 0) { diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 57a7bae..e720913 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -52,7 +52,9 @@ #define PERFPROBE_GROUP "probe" bool probe_event_dry_run; /* Dry run flag */ -struct probe_conf probe_conf; +struct probe_conf probe_conf = { + .silent = false, +}; #define semantic_error(msg ...) pr_err("Semantic error :" msg) @@ -2192,10 +2194,12 @@ static int show_perf_probe_event(const char *group, const char *event, ret = perf_probe_event__sprintf(group, event, pev, module, &buf); if (ret >= 0) { - if (use_stdout) + if (use_stdout && !probe_conf.silent) printf("%s\n", buf.buf); - else + else if (!probe_conf.silent) pr_info("%s\n", buf.buf); + else + pr_debug("%s\n", buf.buf); } strbuf_release(&buf); @@ -2418,7 +2422,10 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, } ret = 0; - pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":"); + if (!probe_conf.silent) + pr_info("Added new event%s\n", (ntevs > 1) ? "s:" : ":"); + else + pr_debug("Added new event%s\n", (ntevs > 1) ? "s:" : ":"); for (i = 0; i < ntevs; i++) { tev = &tevs[i]; /* Skip if the symbol is out of .text or blacklisted */ @@ -2454,7 +2461,7 @@ static int __add_probe_trace_events(struct perf_probe_event *pev, warn_uprobe_event_compat(tev); /* Note that it is possible to skip all events because of blacklist */ - if (ret >= 0 && event) { + if (ret >= 0 && event && !probe_conf.silent) { /* Show how to use the event. */ pr_info("\nYou can now use it in all perf tools, such as:\n\n"); pr_info("\tperf record -e %s:%s -aR sleep 1\n\n", group, event); diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h index 915f0d8..3ab9c3e 100644 --- a/tools/perf/util/probe-event.h +++ b/tools/perf/util/probe-event.h @@ -13,6 +13,7 @@ struct probe_conf { bool force_add; bool no_inlines; int max_probes; + bool silent; }; extern struct probe_conf probe_conf; extern bool probe_event_dry_run; diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index bbb2437..db7bd4c 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -267,7 +267,10 @@ static int __del_trace_probe_event(int fd, struct str_node *ent) goto error; } - pr_info("Removed event: %s\n", ent->s); + if (!probe_conf.silent) + pr_info("Removed event: %s\n", ent->s); + else + pr_debug("Removed event: %s\n", ent->s); return 0; error: pr_warning("Failed to delete event: %s\n",