Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964875AbcKWRp0 (ORCPT ); Wed, 23 Nov 2016 12:45:26 -0500 Received: from mga14.intel.com ([192.55.52.115]:11497 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938518AbcKWRpD (ORCPT ); Wed, 23 Nov 2016 12:45:03 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,539,1473145200"; d="scan'208";a="1072652993" From: kan.liang@intel.com To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org Cc: alexander.shishkin@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com, wangnan0@huawei.com, mark.rutland@arm.com, andi@firstfloor.org, Kan Liang Subject: [PATCH 13/14] perf tools: warn on high overhead Date: Wed, 23 Nov 2016 04:44:51 -0500 Message-Id: <1479894292-16277-14-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1479894292-16277-1-git-send-email-kan.liang@intel.com> References: <1479894292-16277-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 Content-Length: 1930 Lines: 57 From: Kan Liang The rough overhead rate can be caculated by the sum of all kinds of overhead / elapsed time. If the overhead rate is higher than 10%, warning the user. Signed-off-by: Kan Liang --- tools/perf/util/session.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index e84808f..decfc48 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1559,6 +1559,30 @@ perf_session__warn_order(const struct perf_session *session) ui__warning("%u out of order events recorded.\n", oe->nr_unordered_events); } +static void +perf_session__warn_overhead(const struct perf_session *session) +{ + const struct events_stats *stats = &session->evlist->stats; + double overhead_rate; + u64 overhead; + int i; + + for (i = 0; i < session->header.env.nr_cpus_online; i++) { + overhead = stats->total_nmi_overhead[i][1]; + overhead += stats->total_mux_overhead[i][1]; + overhead += stats->total_sb_overhead[i][1]; + overhead += stats->total_user_write_overhead[i][1]; + + overhead_rate = (double)overhead / (double)stats->elapsed_time; + + if (overhead_rate > 0.1) { + ui__warning("Perf overhead is high! The overhead rate is %3.2f%% on CPU %d\n\n" + "Please consider reducing the number of events, or increasing the period, or decrease the frequency.\n\n", + overhead_rate * 100.0, i); + } + } +} + static void perf_session__warn_about_errors(const struct perf_session *session) { const struct events_stats *stats = &session->evlist->stats; @@ -1632,6 +1656,8 @@ static void perf_session__warn_about_errors(const struct perf_session *session) "Increase it by --proc-map-timeout\n", stats->nr_proc_map_timeout); } + + perf_session__warn_overhead(session); } static int perf_session__flush_thread_stack(struct thread *thread, -- 2.5.5