Received: by 10.223.185.116 with SMTP id b49csp1708026wrg; Sat, 17 Feb 2018 03:40:26 -0800 (PST) X-Google-Smtp-Source: AH8x2278wTaME3eyvadcjrBge0NIlniOQb0SlAjMfb7lXAekIzgDKp6nz9YaWFF7AoEF2HXkjJoT X-Received: by 10.99.114.3 with SMTP id n3mr7541022pgc.225.1518867625943; Sat, 17 Feb 2018 03:40:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518867625; cv=none; d=google.com; s=arc-20160816; b=WFLlkKiFBzjv3745v67ttu4IUJa7L4WuETlJbaV41IZgxFMpWvVH/aQd9pSp72N6Uh o4GR7LeP6hr76jxShPA0IKIxlZbYY9fiGxORPTukpRfH0zKHaeYiuyjxTg+SW6oW5owC CVnlwNRXAhzgJvOp1iOQm03etiXd2nE1molU8IYasFFtgPh7kYuJCMMNpr4VRGceEYQ0 Fre2jeZsQAU2jNiTrOccCwsBk2F3rdtS/gdrxa9+K7Jvu33e82fhOzCIDX/BXrVuSNNy vUeaoA+y7pqtnoy0u7vv234g2IkHQLvUPnuFZ4iO7tpC1DklKklOMm5dhq/bPM63gR+w w1dw== 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=3IeX5/OUmQgb/4GhIrq1sKTsBDWavxlNHb+cjAjeUvw=; b=fiCgL58JYJ5AHAK6E3lBmU9209ZA4QEGywQLJFG2xhsIb3zyLObqeDJA0vTyI8PcAp ewahIUpxJT7grZOG8fE9Km4BOjPDIp35DgipZN2Qzy9XNwA6VY/2XOtF9xxFtRMJVHeT nkIXNysHH3p39RMSF4RVyQFI+cLTq5HJRg53YNPQ+r/kkT6n4YLtrkyYJo/x301wE43l Z3RYt8v6vmsW1U0WdqAH//lHcGyPfHLFwK1PjRWHyBPKx4hC0FsyvnXUA8SYsU6ICNJl OUvZayHMGmF6Tb/X6KgGboF1gmANAuRfvuCxYcxIKauex9TFlx9dSzr63C1IqFpqw0aT Yodw== 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 f12si1011698pga.22.2018.02.17.03.40.11; Sat, 17 Feb 2018 03:40:25 -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 S1751305AbeBQLi7 (ORCPT + 99 others); Sat, 17 Feb 2018 06:38:59 -0500 Received: from terminus.zytor.com ([198.137.202.136]:47019 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbeBQLi5 (ORCPT ); Sat, 17 Feb 2018 06:38:57 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1HBckgT008438; Sat, 17 Feb 2018 03:38:46 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1HBckRS008435; Sat, 17 Feb 2018 03:38:46 -0800 Date: Sat, 17 Feb 2018 03:38:46 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Thomas Richter Message-ID: Cc: tmricht@linux.vnet.ibm.com, brueckner@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, acme@redhat.com, heiko.carstens@de.ibm.com, hpa@zytor.com, schwidefsky@de.ibm.com, mingo@kernel.org Reply-To: linux-kernel@vger.kernel.org, brueckner@linux.vnet.ibm.com, tmricht@linux.vnet.ibm.com, mingo@kernel.org, schwidefsky@de.ibm.com, hpa@zytor.com, heiko.carstens@de.ibm.com, acme@redhat.com, tglx@linutronix.de In-Reply-To: <20180213151419.80737-4-tmricht@linux.vnet.ibm.com> References: <20180213151419.80737-4-tmricht@linux.vnet.ibm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf test: Fix test case 23 for s390 z/VM or KVM guests Git-Commit-ID: b3be39c51cc58eb60c698cf64987e9d465a9263a 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: b3be39c51cc58eb60c698cf64987e9d465a9263a Gitweb: https://git.kernel.org/tip/b3be39c51cc58eb60c698cf64987e9d465a9263a Author: Thomas Richter AuthorDate: Tue, 13 Feb 2018 16:14:19 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 16 Feb 2018 15:16:57 -0300 perf test: Fix test case 23 for s390 z/VM or KVM guests On s390 perf can be executed on a LPAR with support for hardware events (i. e. cycles) or on a z/VM or KVM guest where no hardware events are supported. In this environment use software event named cpu-clock for this test case. Use the cpuid infrastructure functions to determine the cpuid on s390 which contains an indication of the cpu counter facility availability. Signed-off-by: Thomas Richter Reviewed-by: Hendrik Brueckner Cc: Heiko Carstens Cc: Martin Schwidefsky Link: http://lkml.kernel.org/r/20180213151419.80737-4-tmricht@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/code-reading.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index 3bf7b14..c7115d3 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c @@ -482,6 +482,34 @@ static void fs_something(void) } } +static const char *do_determine_event(bool excl_kernel) +{ + const char *event = excl_kernel ? "cycles:u" : "cycles"; + +#ifdef __s390x__ + char cpuid[128], model[16], model_c[16], cpum_cf_v[16]; + unsigned int family; + int ret, cpum_cf_a; + + if (get_cpuid(cpuid, sizeof(cpuid))) + goto out_clocks; + ret = sscanf(cpuid, "%*[^,],%u,%[^,],%[^,],%[^,],%x", &family, model_c, + model, cpum_cf_v, &cpum_cf_a); + if (ret != 5) /* Not available */ + goto out_clocks; + if (excl_kernel && (cpum_cf_a & 4)) + return event; + if (!excl_kernel && (cpum_cf_a & 2)) + return event; + + /* Fall through: missing authorization */ +out_clocks: + event = excl_kernel ? "cpu-clock:u" : "cpu-clock"; + +#endif + return event; +} + static void do_something(void) { fs_something(); @@ -592,10 +620,7 @@ static int do_test_code_reading(bool try_kcore) perf_evlist__set_maps(evlist, cpus, threads); - if (excl_kernel) - str = "cycles:u"; - else - str = "cycles"; + str = do_determine_event(excl_kernel); pr_debug("Parsing event '%s'\n", str); ret = parse_events(evlist, str, NULL); if (ret < 0) {