Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752331AbdI2Osj (ORCPT ); Fri, 29 Sep 2017 10:48:39 -0400 Received: from mga02.intel.com ([134.134.136.20]:31321 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751975AbdI2Osg (ORCPT ); Fri, 29 Sep 2017 10:48:36 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,452,1500966000"; d="scan'208";a="905127000" 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, wangnan0@huawei.com, hekuang@huawei.com, ast@kernel.org, ak@linux.intel.com, Kan Liang Subject: [PATCH RFC V4 6/6] perf top: check the cost of perf_top__mmap_read Date: Fri, 29 Sep 2017 07:47:57 -0700 Message-Id: <1506696477-146932-7-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1506696477-146932-1-git-send-email-kan.liang@intel.com> References: <1506696477-146932-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: 1213 Lines: 37 From: Kan Liang The latency of perf_top__mmap_read should be lower than refresh time. If not, give some hints to reduce the overhead. Signed-off-by: Kan Liang --- tools/perf/builtin-top.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 03090d0..b5143c9 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -863,11 +863,20 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) static void perf_top__mmap_read(struct perf_top *top) { + unsigned long long s, e; int i; perf_evlist__toggle_bkw_mmap(top->evlist, BKW_MMAP_DATA_PENDING); + s = rdclock(); for (i = 0; i < top->evlist->nr_mmaps; i++) perf_top__mmap_read_idx(top, i); + e = rdclock(); + if ((e - s) > (unsigned long long)(top->delay_secs * NSEC_PER_SEC)) { + ui__warning("Too slow to read ring buffer.\n" + "Please try increasing the period (-c) or\n" + "decreasing the freq (-F) or\n" + "limiting the number of CPUs (-C)\n"); + } perf_evlist__toggle_bkw_mmap(top->evlist, BKW_MMAP_EMPTY); perf_evlist__toggle_bkw_mmap(top->evlist, BKW_MMAP_RUNNING); } -- 2.5.5