Received: by 10.223.185.116 with SMTP id b49csp3563007wrg; Tue, 13 Feb 2018 04:21:48 -0800 (PST) X-Google-Smtp-Source: AH8x225CH2BIMiqQD9tzP36aB+0lETIIZWPG/8ys6VitNQkX+nULcDcwQNR/K9eDkYwrsYqhAwI+ X-Received: by 10.101.102.3 with SMTP id w3mr876910pgv.326.1518524507882; Tue, 13 Feb 2018 04:21:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518524507; cv=none; d=google.com; s=arc-20160816; b=QWQR1/DtBYGLplRJvVMP6B7+x525jn6eFsIX7nlcmmAV7qG1ro0th83BqXJCPHugxs X+zp2hgI0G/NodVnc6CSmdu7xIFYePslEvIwY1cKAqD5uU8OeeqQGKcW+Uq1ViH0lWbU AvfIsVL/iTQR+h2fzsb/oqYspkVZLZY3v1vlWMWyP8XHAyCuHAkB7tIPFR8AjYbeU1z3 2gRUwigI+X5EsFIfb0Z5casGNfOICN1wGC6hnpfSUmfiD4ZEko6doFxUR3uyu1dqEoR9 xzRqh37XChXQrdGQzoJhGKEL5q6dwBMbtA68b/C7KO7iyePRQcotw10fvgr2wBskMKRh MUNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=Hs+IIqjZjd5Ts93ih1Ua/8b/2XvV6rwnSigxWvlcIs0=; b=IrWS54fKCWmv5vj7SWAPKEon0lpd0JjwWrLJa/1n1BGtqw8TrrN86GtGf/3YoFqr+T vGnIf1GB9ARcj88kCEtzgV3FVskeyswsYlJohli6ycH3wlJi7RumP5wzcqsMkWc6eTLR 9ynFSeIuraNqINoYxpP2LXNj5rbv/wdIh5g2xo0af6jojK/b4+p9YX1Li3FDQQIeJu1J 0vN7ZX9yt0r5lh9oWBbmaBooI/NzZ1c0xFG6n+Zu3150lUEzxwheWHVRWQlwTlG6QTS9 sKasUk7KTgp8O3/utTFdqfCVXMDsMyMpCwAu4eZpiAzgNwiP3GT+WeZFLladzGrqqCY0 Sk2w== 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 j23-v6si1262137pli.127.2018.02.13.04.21.33; Tue, 13 Feb 2018 04:21:47 -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 S935118AbeBMMUC (ORCPT + 99 others); Tue, 13 Feb 2018 07:20:02 -0500 Received: from terminus.zytor.com ([198.137.202.136]:51419 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934827AbeBMMUA (ORCPT ); Tue, 13 Feb 2018 07:20:00 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1DC9ap2029322; Tue, 13 Feb 2018 04:09:36 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1DC9aCF029318; Tue, 13 Feb 2018 04:09:36 -0800 Date: Tue, 13 Feb 2018 04:09:36 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Kan Liang Message-ID: Cc: acme@redhat.com, jolsa@kernel.org, hpa@zytor.com, ak@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, wangnan0@huawei.com, kan.liang@intel.com, linux-kernel@vger.kernel.org, peterz@infradead.org, yao.jin@linux.intel.com, mingo@kernel.org Reply-To: linux-kernel@vger.kernel.org, yao.jin@linux.intel.com, peterz@infradead.org, wangnan0@huawei.com, kan.liang@intel.com, namhyung@kernel.org, mingo@kernel.org, hpa@zytor.com, jolsa@kernel.org, acme@redhat.com, ak@linux.intel.com, tglx@linutronix.de In-Reply-To: <1516310792-208685-14-git-send-email-kan.liang@intel.com> References: <1516310792-208685-14-git-send-email-kan.liang@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf top: Add overwrite fall back Git-Commit-ID: 6a669091c0d93cc1ac4a0de7af722d1359bfe98f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 6a669091c0d93cc1ac4a0de7af722d1359bfe98f Gitweb: https://git.kernel.org/tip/6a669091c0d93cc1ac4a0de7af722d1359bfe98f Author: Kan Liang AuthorDate: Thu, 18 Jan 2018 13:26:28 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 6 Feb 2018 10:11:51 -0300 perf top: Add overwrite fall back 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 Acked-by: Jiri Olsa Cc: Andi Kleen Cc: Jin Yao Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1516310792-208685-14-git-send-email-kan.liang@intel.com [ Use perf_missing_features.write_backward instead of the non merged is_write_backward_fail() ] Signed-off-by: Arnaldo Carvalho de Melo --- 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 1778379..ee4bba1 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 (perf_missing_features.write_backward && + 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);