Received: by 10.223.185.116 with SMTP id b49csp3754268wrg; Tue, 13 Feb 2018 07:16:49 -0800 (PST) X-Google-Smtp-Source: AH8x224sDTDkoaY9b3ZX/cV/faVcWbG5a/fCAxqO5G4KWYeriX8s7tXuUkuB1xBrvVUGaMrq/ILM X-Received: by 2002:a17:902:b406:: with SMTP id x6-v6mr1453772plr.150.1518535009603; Tue, 13 Feb 2018 07:16:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518535009; cv=none; d=google.com; s=arc-20160816; b=X3+U85z6SHg6GP4eXeRhyUhXKFizIyoIUsoottWQp3hsJiSj73MWJpJn/J0BUL8/eI 0gbrgvpl1rE9R4sRyP3s5Db3vPxYvSTqEUUvTNyHn1wRtLPTTltQ9b+6SNHmuXYAMsp5 agI3SDJyByPZ4ILIQeUS1p9tb1hHvJz1ZcPzOvRXHW9PfgJlnoQvwqJwZ0sqXt4+8gNO h+knmRSV0iTYt9oQmcSMPJ0I78fDz61Bh+as8eeJkSQxcZA7WIxRErJnf4ypOG4N99L7 RLhHlwxLnHzINj+lHQvsAS7/FVbRJ9rguOnZxE5/INYznMYyVqSA/LPwmKbZMK1VML3m +zxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=zX/S2H8L+prFSmfoQgZjZ/IqLIfgN+Sbgeb3UXm2K/o=; b=S3zYWnexzv7px+1ZNEnqdMkkbNeDavPAPy+XPPH8A1mZ3LQ95pJ5pXQJ9r7Zao7ngv k578ReBKXM+mU5OhRs8RyOxpHq+d/dzNn2kq69WjZd31PF/+iCc8ZZf0wtABBlm3dUxr auwQe0OwO5ODaMA8wmBz7F0mDiwu2xn148NatIRRcryCmD/YphIYgPm6BsVumq63Iqu8 FvrGn1bfYAWuH+MnLVkXsl8Nokk1SoCdrjdLIdpdRSjPBIvCc25+bt6cdqaGYsOnml2z ucTOXajx3CqCRecDTKDkKZpj/sAyuwBqn28DqvjKcp68WJD7P0JrbgzgChs4g+LTI4ui d2EQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13-v6si1490821plq.435.2018.02.13.07.16.35; Tue, 13 Feb 2018 07:16:49 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965242AbeBMPOl (ORCPT + 99 others); Tue, 13 Feb 2018 10:14:41 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55078 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965054AbeBMPOj (ORCPT ); Tue, 13 Feb 2018 10:14:39 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1DFA6a7044219 for ; Tue, 13 Feb 2018 10:14:39 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g428nrup0-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 13 Feb 2018 10:14:38 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Feb 2018 15:14:37 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 13 Feb 2018 15:14:35 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1DFEZHM41550024; Tue, 13 Feb 2018 15:14:35 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45F7A11C054; Tue, 13 Feb 2018 15:07:49 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 02AB311C058; Tue, 13 Feb 2018 15:07:49 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 13 Feb 2018 15:07:48 +0000 (GMT) From: Thomas Richter To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org Cc: brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, Thomas Richter Subject: [PATCH 4/4] perf test: Fix test case 23 for s390 z/VM or KVM guests Date: Tue, 13 Feb 2018 16:14:19 +0100 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180213151419.80737-1-tmricht@linux.vnet.ibm.com> References: <20180213151419.80737-1-tmricht@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18021315-0020-0000-0000-000003F53CCF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021315-0021-0000-0000-00004287C8DF Message-Id: <20180213151419.80737-4-tmricht@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-13_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802130180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 3bf7b145b826..c7115d369511 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) { -- 2.14.3