Received: by 10.213.65.68 with SMTP id h4csp3551453imn; Tue, 10 Apr 2018 00:19:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx495X4Fa4JKNYn7EZI5zywrc0JsGkgIUFm56bIODKzcL8Twhp4n0VQPXLvGITqEQOZywStDB X-Received: by 10.98.133.28 with SMTP id u28mr1797590pfd.190.1523344792786; Tue, 10 Apr 2018 00:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523344792; cv=none; d=google.com; s=arc-20160816; b=WXPH1IFOT7uzDVKSrMw86ePnJ2M0t3ja/giqbuWyNDDxAVYYG5ztpNJjoSwSpDt/OW THkPjRiVbHF3KBO8tKkA/krKErtjkyXnsYEwDpiuqDpTKCZmnWoowAKg6mW9AbWGAF8C 4fXIKOzL2qeaoCoImbrWUM8HhDSHv3rtOj7ThhjbXFuu4NTV9k85cRnLS4d2gOGT7HK9 aL0PC4VZtFiJkytyqmp0EFa/AW9WnGGNQ0+vO+1h+HperX970zl1XqsbzxfgP4QwxEqP xoI/jEjeJvs9MfAPHEmcd0D6q24CHXwLkl60a66wmaa7iynbF+NlCaJMKnH6fn8UzQJw sEHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :organization:from:references:cc:to:subject :arc-authentication-results; bh=zdYcAzrQu46KJkrAbf+YdCtRNgBE009eHfWOXRmFt4g=; b=vsFoLmBsU46x8BbdizBNvxFbJ1Ef6wr+5Hvqe1Mklp3rHEUpojGHHOrYok5ooLo/Bh ZfUsILERetcppxzD5fEug9yVfREB7OuRZFNUl8+RYFgu4BHfwshPKCoyMccU4+X30xD3 w8fGcC8JgbVWiFlVXADmp3rOOrBpWJlzZIpxWxgXtSwrSYRWe11gugtrqGBcdPPvgNOX NMTZUW8mNo9zVtEPPaK80/VwvBVZNqHihLleObF5C0z6i6Y1GykA+vsAtSEaPc7v7w3U GC5kVb3wZ54FhzITebaKV5TVCyyoARkmxKs1uUK7k85DPVgpBrUe8QndeF5QNUKNLv1l veaw== 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 g8si1395522pgs.69.2018.04.10.00.19.15; Tue, 10 Apr 2018 00:19:52 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752137AbeDJHQb (ORCPT + 99 others); Tue, 10 Apr 2018 03:16:31 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48108 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751771AbeDJHQa (ORCPT ); Tue, 10 Apr 2018 03:16:30 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3A7G5gM092512 for ; Tue, 10 Apr 2018 03:16:29 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2h8njypwsn-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 10 Apr 2018 03:16:21 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Apr 2018 08:15:12 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 10 Apr 2018 08:15:09 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3A7F9gC14156120; Tue, 10 Apr 2018 07:15:09 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 905BEAE058; Tue, 10 Apr 2018 08:05:06 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36B37AE045; Tue, 10 Apr 2018 08:05:06 +0100 (BST) Received: from oc3784624756.ibm.com (unknown [9.152.212.50]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 10 Apr 2018 08:05:06 +0100 (BST) Subject: Re: [PATCH] perf list: Add s390 support for detailed/verbose pmu event description To: Mark Rutland Cc: Thomas Richter , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org, brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com References: <20180409110015.20793-1-tmricht@linux.ibm.com> <20180409113732.6k3plpp6pqdcbzrh@lakrids.cambridge.arm.com> <975962f2-3d85-2325-da31-b74951863cbe@linux.vnet.ibm.com> <20180409141811.eaynqn53nxavcjo2@lakrids.cambridge.arm.com> From: Thomas-Mich Richter Organization: IBM LTC Date: Tue, 10 Apr 2018 09:15:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180409141811.eaynqn53nxavcjo2@lakrids.cambridge.arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-IE Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 18041007-0008-0000-0000-000004E8AB8C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041007-0009-0000-0000-00001E7BD30C Message-Id: <987a8f41-525b-0918-61b9-0593899e7c16@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-10_02:,, 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-1804100075 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/09/2018 04:18 PM, Mark Rutland wrote: > On Mon, Apr 09, 2018 at 03:03:32PM +0200, Thomas-Mich Richter wrote: >> On 04/09/2018 01:37 PM, Mark Rutland wrote: >>> On Mon, Apr 09, 2018 at 01:00:15PM +0200, Thomas Richter wrote: >>>> @@ -562,6 +562,12 @@ static int is_pmu_core(const char *name) >>>> if (stat(path, &st) == 0) >>>> return 1; >>>> >>>> + /* Look for cpu sysfs (specific to s390) */ >>>> + scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s", >>>> + sysfs, name); >>>> + if (stat(path, &st) == 0) >>>> + return 1; >>> >>> IIUC here we return true if the PMU has a sysfs directory, but all PMUs >>> (including uncore PMUs) should have such a directory, so this will make >>> is_pmu_core() always return true. >>> >>> Can you match the "cpum_" prefix specifically, instead? >>> >>> Thanks, >>> Mark. >> >> I am sorry, I don't follow you. >> >> When I look at the code function sequence >> >> perf_pmu__scan() >> +---> pmu_read_sysfs() >> This functions scans directory /sys/bus/event_source/devices/ >> and calls for each entry in this directory. For s390 these entries exist: >> cpum_sf cpum_cf tracepoint and software > > ... and we want is: > > is_pmu_core("cpum_sf") == true > is_pmu_core("cpum_cf") == true > is_pmu_core("tracepoint") == false > is_pmu_core("software") == false > >> +---> perf_pmu__find(); >> +---> pmu_lookup() > >> +---> pmu_add_cpu_aliases() adds the list of aliases such as cpum_sf/SF_CYCLES_BASIC/ >> to the global list of aliases. But ths happens only when >> +---> is_pmu_core() >> function returns true. >> And for s390 it needs to test for /sys/bus/event_source/devices/cpum_sf/ and >> /sys/bus/event_source/devices/cpum_cf/ >> directories. >> These directories are used to read the alias names in function >> pmu_aliases() above. > > However, your code also returns true for "tracepoint" and "software". > > You check if there's a directory under event_source/devices/ for the PMU > name, and every PMU should have such a directory. > > For example, on my x86 box I have > > [mark@lakrids:~]% ls /sys/bus/event_source/devices > breakpoint power uncore_cbox_13 uncore_cbox_9 uncore_qpi_0 > cpu software uncore_cbox_2 uncore_ha_0 uncore_qpi_1 > cstate_core tracepoint uncore_cbox_3 uncore_ha_1 uncore_r2pcie > cstate_pkg uncore_cbox_0 uncore_cbox_4 uncore_imc_0 uncore_r3qpi_0 > intel_bts uncore_cbox_1 uncore_cbox_5 uncore_imc_1 uncore_r3qpi_1 > intel_cqm uncore_cbox_10 uncore_cbox_6 uncore_imc_4 uncore_ubox > intel_pt uncore_cbox_11 uncore_cbox_7 uncore_imc_5 > msr uncore_cbox_12 uncore_cbox_8 uncore_pcu > > > ... and with your patch and the below hack applied: > > ---- > diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c > index bd0a32b03523..cec6bf551fe3 100644 > --- a/tools/perf/util/pmu.c > +++ b/tools/perf/util/pmu.c > @@ -675,6 +675,12 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu) > break; > } > > + if (is_pmu_core(name)) { > + printf ("is_pmu_core(\"%s\") is true\n", name); > + } else { > + printf ("is_pmu_core(\"%s\") is false\n", name); > + } > + > if (!is_pmu_core(name)) { > /* check for uncore devices */ > if (pe->pmu == NULL) > ---- > > ... is_pmu_core() returns true for every PMU: > > [mark@lakrids:~/src/linux/tools/perf]% ./perf list | grep 'is true' | uniq > is_pmu_core("uncore_imc_4") is true > is_pmu_core("uncore_cbox_5") is true > is_pmu_core("uncore_ha_0") is true > is_pmu_core("uncore_cbox_3") is true > is_pmu_core("uncore_qpi_0") is true > is_pmu_core("cstate_pkg") is true > is_pmu_core("breakpoint") is true > is_pmu_core("uncore_imc_0") is true > is_pmu_core("uncore_ubox") is true > is_pmu_core("uncore_pcu") is true > is_pmu_core("uncore_cbox_1") is true > is_pmu_core("uncore_r3qpi_0") is true > is_pmu_core("uncore_cbox_13") is true > is_pmu_core("intel_cqm") is true > is_pmu_core("power") is true > is_pmu_core("cpu") is true > is_pmu_core("intel_pt") is true > is_pmu_core("uncore_cbox_11") is true > is_pmu_core("uncore_cbox_8") is true > is_pmu_core("uncore_imc_5") is true > is_pmu_core("software") is true > is_pmu_core("uncore_cbox_6") is true > is_pmu_core("uncore_ha_1") is true > is_pmu_core("uncore_r2pcie") is true > is_pmu_core("uncore_cbox_4") is true > is_pmu_core("intel_bts") is true > is_pmu_core("uncore_qpi_1") is true > is_pmu_core("uncore_imc_1") is true > is_pmu_core("uncore_cbox_2") is true > is_pmu_core("uncore_r3qpi_1") is true > is_pmu_core("uncore_cbox_0") is true > is_pmu_core("cstate_core") is true > is_pmu_core("uncore_cbox_12") is true > is_pmu_core("tracepoint") is true > is_pmu_core("uncore_cbox_9") is true > is_pmu_core("msr") is true > is_pmu_core("uncore_cbox_10") is true > is_pmu_core("uncore_cbox_7") is true > > [mark@lakrids:~/src/linux/tools/perf]% ./perf list | grep 'is false' | wc -l > 0 > > > ... whereas previously this was only the case for the CPU PMU: > > [mark@lakrids:~/src/linux/tools/perf]% ./perf list | grep 'is true' | uniq > is_pmu_core("cpu") is true > > [mark@lakrids:~/src/linux/tools/perf]% ./perf list | grep 'is false' | uniq > is_pmu_core("uncore_imc_4") is false > is_pmu_core("uncore_cbox_5") is false > is_pmu_core("uncore_ha_0") is false > is_pmu_core("uncore_cbox_3") is false > is_pmu_core("uncore_qpi_0") is false > is_pmu_core("cstate_pkg") is false > is_pmu_core("breakpoint") is false > is_pmu_core("uncore_imc_0") is false > is_pmu_core("uncore_ubox") is false > is_pmu_core("uncore_pcu") is false > is_pmu_core("uncore_cbox_1") is false > is_pmu_core("uncore_r3qpi_0") is false > is_pmu_core("uncore_cbox_13") is false > is_pmu_core("intel_cqm") is false > is_pmu_core("power") is false > is_pmu_core("intel_pt") is false > is_pmu_core("uncore_cbox_11") is false > is_pmu_core("uncore_cbox_8") is false > is_pmu_core("uncore_imc_5") is false > is_pmu_core("software") is false > is_pmu_core("uncore_cbox_6") is false > is_pmu_core("uncore_ha_1") is false > is_pmu_core("uncore_r2pcie") is false > is_pmu_core("uncore_cbox_4") is false > is_pmu_core("intel_bts") is false > is_pmu_core("uncore_qpi_1") is false > is_pmu_core("uncore_imc_1") is false > is_pmu_core("uncore_cbox_2") is false > is_pmu_core("uncore_r3qpi_1") is false > is_pmu_core("uncore_cbox_0") is false > is_pmu_core("cstate_core") is false > is_pmu_core("uncore_cbox_12") is false > is_pmu_core("tracepoint") is false > is_pmu_core("uncore_cbox_9") is false > is_pmu_core("msr") is false > is_pmu_core("uncore_cbox_10") is false > is_pmu_core("uncore_cbox_7") is false > > If it's fine to have a tautological is_pmu_core(), then we can remove it > entirely. > > My understanding was that we have the is_pmu_core() check to ensure that > we don't associate aliases with other PMUs in the system. > > For example, on some arm platforms the CPU PMU isn't available, and we > shouldn't add the CPU PMU aliases just because we have a software PMU. > >> Maybe I misunderstand this whole scheme, but with this patch the perf >> list commands works... > > It looks like it works on my x86 box, at least, but I do think this is > wrong in some cases. > > Thanks, > Mark. > Thank you very much for your explanation. I think I got your point and will provide a reworked patch which returns ok for the s390 PMUs named cpum_cf and cpum_sf. -- Thomas Richter, Dept 3303, IBM LTC Boeblingen Germany -- Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294