Received: by 10.192.165.148 with SMTP id m20csp881347imm; Wed, 25 Apr 2018 09:04:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/vna7GoszrNPnepoABgXFK9Pa+9dikVN7hJXJnCvEys4Go4mXbSLoxa7zqs2BPV5YFrGEK X-Received: by 10.98.83.199 with SMTP id h190mr28451410pfb.146.1524672242199; Wed, 25 Apr 2018 09:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524672242; cv=none; d=google.com; s=arc-20160816; b=o6gzygG4Xqrxg+TVUMdLzeVK7tUI82pItrBXKCcHUXxdqxFTltPOVV7UmcCvZtatt7 /3ZT+odjflh0Rs4qa3EOs1clBOv3+bKvfY044r17Wjs7VEChu3EJARbyR6w3Qvy/zo/D bcj50XqY2b0w+fODQOXfubwLciNYtdgpIEFY3AYJYgKCOJnuJ/LC0JJxUc6fxpPVFWe4 qcvylFjzWEgau2c4ul1iKQXJYj2Y8wc00fTw3VriGKPsR1HWDY6KjegTr4p/BRzk6Xhp 8ZIR7b5GMUj/jQDpA5LFH8H4TeRSXfq++Jx4vXMGQd+rSs+KnxmF9UkF87CLicnzexxD kq/w== 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:dmarc-filter:arc-authentication-results; bh=vvJ9Uwfp7gqijyHksXdQkC0qI71hQ8PAPWJph3b5mgQ=; b=elIpOBJyxrJnIPiuMy54tag+a0pDlOfqRmPK249qjk3womwKSoaYahhmTR5+crop/j nC1hcBiwvkAWurEqvhuH59y9UaSJg4+rp4EawASd54fK0v3GJuV0JSdPtyl8dhLME4mc hoS2GnpOmLDNM+/28p35XZpEd032RHxxb76qYzLS9ANRDYtSfwr+MYf6D6Sab4DvD2ll YpOrf/E4GdYmUEZyfCIfksbyb0qnfUnqR2JS8JsYM02oJdCAa5a+ys6o+WCypMPCZ+8Q eOdyux5d9xFju/cgsBzlv7rMfx7NFyTq1rfNF31B+3P93ZIHadKEIJwcaJRYsqjejjo0 3L3g== 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 29si16126656pfj.6.2018.04.25.09.03.47; Wed, 25 Apr 2018 09:04:02 -0700 (PDT) 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 S1755753AbeDYQBE (ORCPT + 99 others); Wed, 25 Apr 2018 12:01:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:47264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755847AbeDYQAx (ORCPT ); Wed, 25 Apr 2018 12:00:53 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DE5B921789; Wed, 25 Apr 2018 16:00:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE5B921789 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Kan Liang , Agustin Vega-Frias , Ganapatrao Kulkarni , Jin Yao , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Shaokun Zhang , Will Deacon , Arnaldo Carvalho de Melo Subject: [PATCH 11/12] perf evsel: Only fall back group read for leader Date: Wed, 25 Apr 2018 13:00:07 -0300 Message-Id: <20180425160008.3407-12-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180425160008.3407-1-acme@kernel.org> References: <20180425160008.3407-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang Perf doesn't support mixed events from different PMUs (except software event) in a group. The perf stat should output / for all events, but it doesn't. For example, perf stat -e '{cycles,uncore_imc_5/umask=0xF,event=0x4/,instructions}' cycles uncore_imc_5/umask=0xF,event=0x4/ 1,024,300 instructions If perf fails to open an event, it doesn't error out directly. It will disable some features and retry, until the event is opened or all features are disabled. The disabled features will not be re-enabled. The group read is one of these features. For the example as above, the IMC event and the leader event "cycles" are from different PMUs. Opening the IMC event must fail. The group read feature must be disabled for IMC event and the followed event "instructions". The "instructions" event has the same PMU as the leader "cycles". It can be opened successfully. Since the group read feature has been disabled, the "instructions" event will be read as a single event, which definitely has a value. The group read fallback is still useful for the case which kernel doesn't support group read. It is good enough to be handled only by the leader. For the fallback request from members, it must be caused by an error. The fallback only breaks the semantics of group. Limit the group read fallback only for the leader. Committer testing: On a broadwell t450s notebook: Before: # perf stat -e '{cycles,unc_cbo_cache_lookup.read_i,instructions}' sleep 1 Performance counter stats for 'sleep 1': cycles unc_cbo_cache_lookup.read_i 818,206 instructions 1.003170887 seconds time elapsed Some events weren't counted. Try disabling the NMI watchdog: echo 0 > /proc/sys/kernel/nmi_watchdog perf stat ... echo 1 > /proc/sys/kernel/nmi_watchdog After: # perf stat -e '{cycles,unc_cbo_cache_lookup.read_i,instructions}' sleep 1 Performance counter stats for 'sleep 1': cycles unc_cbo_cache_lookup.read_i instructions 1.001380511 seconds time elapsed Some events weren't counted. Try disabling the NMI watchdog: echo 0 > /proc/sys/kernel/nmi_watchdog perf stat ... echo 1 > /proc/sys/kernel/nmi_watchdog # Reported-by: Andi Kleen Signed-off-by: Kan Liang Tested-by: Arnaldo Carvalho de Melo Cc: Agustin Vega-Frias Cc: Ganapatrao Kulkarni Cc: Jin Yao Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Shaokun Zhang Cc: Will Deacon Fixes: 82bf311e15d2 ("perf stat: Use group read for event groups") Link: http://lkml.kernel.org/r/1524594014-79243-3-git-send-email-kan.liang@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 26bdeecc0452..4cd2cf93f726 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1925,7 +1925,8 @@ int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, goto fallback_missing_features; } else if (!perf_missing_features.group_read && evsel->attr.inherit && - (evsel->attr.read_format & PERF_FORMAT_GROUP)) { + (evsel->attr.read_format & PERF_FORMAT_GROUP) && + perf_evsel__is_group_leader(evsel)) { perf_missing_features.group_read = true; pr_debug2("switching off group read\n"); goto fallback_missing_features; -- 2.14.3