Received: by 10.223.176.46 with SMTP id f43csp33333wra; Thu, 18 Jan 2018 13:30:10 -0800 (PST) X-Google-Smtp-Source: ACJfBovRyLZpfdZwLtyS4Skf+YItSDIqLJ2RL4mIUDHHrJthrcBO2q41mnB8N6iMyHfiOMAH140l X-Received: by 10.101.78.207 with SMTP id w15mr15536085pgq.349.1516311010760; Thu, 18 Jan 2018 13:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516311010; cv=none; d=google.com; s=arc-20160816; b=Eh1pCKMyYOZnt7M4Cl46S9CEOmaqL85tRKCTWUkv+YKVQNod6fxd+wXjIKzOEMs2i1 aNjl9zX1GYWT1dsBrP2vSm1V+kXDm3R2xPGjNckElT2HAdFV21npYKiQrfx3wSp8q5T3 6rMl/tiB2UfcxYcxR5T22n/pYJT/Fk9h4p43uHsLhI6+jC6WjfHEekuwucUaWxawwaug /UdQqQNp+wtxszvUdhpjvUSmbse6PAMdnwg6q8HYcusA+IUc3R0Fbp+bCXREMxc3PWgd PPhODV988l/aXGPe9124r63y+bxB1040K/EI87i48nu/rmvz4yWZa3us0cQhAAtKPF+f gtOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=OMheMcHKoJpFYJ1KEyVbBcPaGWnktqsEySBY8B1iX/s=; b=wFG2QSfDa0gMWo0KfumOkQ+1mCh2AH6XDIH+P6D0Po/UkSEjnnD9aomdhMHn1XtQjC 5CwXkW4Kdu3iQv3hOS2+G9EgsyderEg6razF+zmwteccq1jbY4JvCIVhTvMzvB15e4Ei j42RQxf8NyLRe3roa5QgYvAr72wEEDht8lKisrlYF1YXTjhH6iC1ulyQdvzZzuwOIP7/ SUOqtSWkJAgCzS5tXbmxpBDppxABBf8tZTDaKApaQD/2ULsgPEGfNkk58A18wClyTyMJ vd+b8FcXO3AEGxkYhvq4OzBbL3crcSEKY3rrB2pVI/QetHtXG8ljH0uyFRowpDQ6h9sK mFJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si6745199pgp.704.2018.01.18.13.29.56; Thu, 18 Jan 2018 13:30:10 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753189AbeARV27 (ORCPT + 99 others); Thu, 18 Jan 2018 16:28:59 -0500 Received: from mga04.intel.com ([192.55.52.120]:47421 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754338AbeARV1h (ORCPT ); Thu, 18 Jan 2018 16:27:37 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2018 13:27:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,378,1511856000"; d="scan'208";a="11477281" Received: from otc-knm-01.jf.intel.com ([10.54.39.34]) by fmsmga008.fm.intel.com with ESMTP; 18 Jan 2018 13:27:36 -0800 From: kan.liang@intel.com To: acme@kernel.org, peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: wangnan0@huawei.com, jolsa@kernel.org, namhyung@kernel.org, ak@linux.intel.com, yao.jin@linux.intel.com, Kan Liang Subject: [PATCH V5 13/17] perf top: add overwrite fall back Date: Thu, 18 Jan 2018 13:26:28 -0800 Message-Id: <1516310792-208685-14-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1516310792-208685-1-git-send-email-kan.liang@intel.com> References: <1516310792-208685-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang Switch to non-overwrite mode if kernel doesnot support overwrite ringbuffer. It's only effect when overwrite mode is supported. No change to current behavior. Signed-off-by: Kan Liang --- tools/perf/builtin-top.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index c86eee4..ecba2cd 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -943,6 +943,27 @@ static int perf_top_overwrite_check(struct perf_top *top) return 0; } +static int perf_top_overwrite_fallback(struct perf_top *top, + struct perf_evsel *evsel) +{ + struct record_opts *opts = &top->record_opts; + struct perf_evlist *evlist = top->evlist; + struct perf_evsel *counter; + + if (!opts->overwrite) + return 0; + + /* only fall back when first event fails */ + if (evsel != perf_evlist__first(evlist)) + return 0; + + evlist__for_each_entry(evlist, counter) + counter->attr.write_backward = false; + opts->overwrite = false; + ui__warning("fall back to non-overwrite mode\n"); + return 1; +} + static int perf_top__start_counters(struct perf_top *top) { char msg[BUFSIZ]; @@ -967,6 +988,21 @@ static int perf_top__start_counters(struct perf_top *top) try_again: if (perf_evsel__open(counter, top->evlist->cpus, top->evlist->threads) < 0) { + + /* + * Specially handle overwrite fall back. + * Because perf top is the only tool which has + * overwrite mode by default, support + * both overwrite and non-overwrite mode, and + * require consistent mode for all events. + * + * May move it to generic code with more tools + * have similar attribute. + */ + if (is_write_backward_fail() && + perf_top_overwrite_fallback(top, counter)) + goto try_again; + if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) { if (verbose > 0) ui__warning("%s\n", msg); -- 2.5.5