Received: by 10.223.185.116 with SMTP id b49csp1019481wrg; Fri, 16 Feb 2018 10:56:22 -0800 (PST) X-Google-Smtp-Source: AH8x226UcqYoeYZsRMz1V99jD7EbzZgzC5oLyDqhGJxPF1hQ4W9ZrD8bpSAphmlnS/XU7/qfhVEI X-Received: by 2002:a17:902:bd09:: with SMTP id p9-v6mr6129671pls.355.1518807382431; Fri, 16 Feb 2018 10:56:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518807382; cv=none; d=google.com; s=arc-20160816; b=qoiG+Zj+PmS+Y16KYJGvD7JX3ca7MbtbUsNCDsxn1s5hqUgtsCJfZPL41QtpozoSOp pCILRFAaPufiZtfuShPxl3xhK4ubCLTcvTlWk8xBNpXSEFqZ7OP0t/HA0dEN5BVLfRpR FkccP2ycuQ1YCALz9cbl8ifJllAVpjq0EWEha0irrASIiSznqVSVNFtVcuPVwdsha+T0 QrUheNHpGt027aOftFTerA4NpVA5Lzuh/UCMPZ0JrrLHxrZYqDVHvJqGhiyVD6Gjnu6T Xrh1WDcNcY1VMHuhvLckz76QRdZme79QqtsgNIzQ7mgtFt2jzq4X5dDox43j7OFTpxsy sAIQ== 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=gtwuQOm75eNiYTxRk5PB9gwAlYT+Gw6HwsHGfQx9Oso=; b=mkvvnpAm/nakZOs0SxY1W2XI82IenAQ5LD8d217qjwEtWGy8SQE2jhxRqf8IOYt9Ui qd3ygAVtdbAyfYiAO4lJ7vH60kA9LO+LPzi3ck4SkugL7r+QXkfqwqi2Pj/lpEj/h1Ek Aw/3IJBlTj/Gx/bGilAQPjX0Mb6oO1TZmN2/KAP4a4U1fpTJPh4E9g6xj1x9oTWwOq4+ TpRQI8YSZc6fdo3iD5TZRUNMlCr/Tw8uX27FpJqRNQlNZhQ7ClL7QdlwWzfCM/P/U/NW 0dCWoZskjdHoUIgPrFiXsSNzI96rESWcTE94fx8vVWvn2YBQf+uG+NuDAXbQdeeIgZlL aqpg== 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 c23si1932753pfe.336.2018.02.16.10.56.08; Fri, 16 Feb 2018 10:56:22 -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 S932658AbeBPJug (ORCPT + 99 others); Fri, 16 Feb 2018 04:50:36 -0500 Received: from terminus.zytor.com ([198.137.202.136]:38015 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932420AbeBPJue (ORCPT ); Fri, 16 Feb 2018 04:50:34 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1G9eCgX022444; Fri, 16 Feb 2018 01:40:12 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1G9eC8B022441; Fri, 16 Feb 2018 01:40:12 -0800 Date: Fri, 16 Feb 2018 01:40:12 -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: peterz@infradead.org, namhyung@kernel.org, tglx@linutronix.de, mingo@kernel.org, yao.jin@linux.intel.com, acme@redhat.com, linux-kernel@vger.kernel.org, ak@linux.intel.com, wangnan0@huawei.com, jolsa@kernel.org, kan.liang@intel.com, hpa@zytor.com Reply-To: wangnan0@huawei.com, jolsa@kernel.org, kan.liang@intel.com, hpa@zytor.com, peterz@infradead.org, tglx@linutronix.de, namhyung@kernel.org, mingo@kernel.org, yao.jin@linux.intel.com, acme@redhat.com, linux-kernel@vger.kernel.org, ak@linux.intel.com 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: 204721d7eabe6ee98aafce791ce3efdbc4715834 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: 204721d7eabe6ee98aafce791ce3efdbc4715834 Gitweb: https://git.kernel.org/tip/204721d7eabe6ee98aafce791ce3efdbc4715834 Author: Kan Liang AuthorDate: Thu, 18 Jan 2018 13:26:28 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 15 Feb 2018 09:56:14 -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);