Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1935457pxv; Sat, 26 Jun 2021 04:52:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNDQgCzJfjoM2/cIVH2821zDRuyvDG9pVNlo4io2bAAZogF7+a3lzWgzt4gbK7+I+SOQ0l X-Received: by 2002:a92:c68c:: with SMTP id o12mr501592ilg.21.1624708377556; Sat, 26 Jun 2021 04:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624708377; cv=none; d=google.com; s=arc-20160816; b=XObZjq2LQLmE6KNJ9TiGAbYy9HJPsdJoGfUUKPdqx2pMByNQdjgEJ1cpR0YorFqRHn B6EGLIkujElixpqzBbX7AX/E62lUyypOo0djbkYR2thNSfAP/bPvL8BDbZASbvR6V96O 8t4lW8OnvBpygivYaHuuN1zt4QGdvE5qkOBt9gjiABB1wrmOIAQrJmtIxD1chHxrKtPh vJfQ9Tld4vQjZ0dYM2CrMnmTPRdqF/Mla7mRsBkO+lX8Go/b2FeNyz9uIUEue3KjuxJY 1lPaZtmMBcyqT8w1UeAd+wG9mDk10mSnWbuYvjwYANke0ruUZeWdttuB2TnJB0mWPmff Vt+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Ec8T2N4rqdoHgjMx/kXtArieg1oy5QuIKUPfzH/ud6g=; b=ofYsjeNdVnRBemGZmsdIPHrHcoZuwLVFAAesnRtY92x2+ohyW+4J87FAhdlQHMdOO6 uVKIBdw5O21DaVEzfYHyhXm8OgOPZCKDJv9UdOBqK3bFdXkWWCasyx1zWLccMxWMlPlU OO8/uURKa2t6FywealztaYV6uyVnLX52nDTnhO3tog4yJ6p21vlmLE60pZ0DpNioA2Y5 mCk3qjW4WKnQ2xgQ4/kQvS5qdDSUvT/naZIx/4oE43ocv0/hRyJn6jxybBKZ+p1MKaAJ W93EtMTQu3GtP5AZSLHhkKuqA/GiDaBRM8D6yRqSqy9r5AR8L2AjI9r2SFeSbdNCEfyZ B3+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m12si8922005ild.137.2021.06.26.04.52.45; Sat, 26 Jun 2021 04:52:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229978AbhFZLxd (ORCPT + 99 others); Sat, 26 Jun 2021 07:53:33 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3321 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbhFZLxc (ORCPT ); Sat, 26 Jun 2021 07:53:32 -0400 Received: from fraeml702-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GBsL50ykLz6L4sw; Sat, 26 Jun 2021 19:37:33 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml702-chm.china.huawei.com (10.206.15.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Sat, 26 Jun 2021 13:51:08 +0200 Received: from [10.47.80.199] (10.47.80.199) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Sat, 26 Jun 2021 12:51:07 +0100 Subject: Re: [PATCH v7 2/2] drivers/perf: hisi: Add driver for HiSilicon PCIe PMU To: "liuqi (BA)" , Linuxarm , , , CC: , , , References: <1624532384-43002-1-git-send-email-liuqi115@huawei.com> <1624532384-43002-3-git-send-email-liuqi115@huawei.com> <485dcb90-01bc-766a-466a-f32563e2076f@huawei.com> <95de93f7-1618-5aa6-9a23-6445c5cb3515@huawei.com> From: John Garry Message-ID: <1b164e4b-b30b-f071-51fa-841cc76ec017@huawei.com> Date: Sat, 26 Jun 2021 12:44:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <95de93f7-1618-5aa6-9a23-6445c5cb3515@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.47.80.199] X-ClientProxiedBy: lhreml726-chm.china.huawei.com (10.201.108.77) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26/06/2021 03:13, liuqi (BA) wrote: > > > On 2021/6/25 23:53, John Garry wrote: >> On 24/06/2021 11:59, Qi Liu wrote: >>> + >>> +/* >>> + * Events with the "dl" suffix in their names count performance in >>> DL layer, >>> + * otherswise, events count performance in TL layer. >>> + */ >>> +static struct attribute *hisi_pcie_pmu_events_attr[] = { >>> +    HISI_PCIE_PMU_EVENT_ATTR(bw_rx_mwr, 0x010004), >>> +    HISI_PCIE_PMU_EVENT_ATTR(bw_rx_mrd, 0x100005), >>> +    HISI_PCIE_PMU_EVENT_ATTR(bw_tx_mwr, 0x010005), >>> +    HISI_PCIE_PMU_EVENT_ATTR(bw_tx_mrd, 0x200004), >>> +    HISI_PCIE_PMU_EVENT_ATTR(lat_rx_mwr, 0x000010), >>> +    HISI_PCIE_PMU_EVENT_ATTR(lat_rx_mrd, 0x020010), >>> +    HISI_PCIE_PMU_EVENT_ATTR(lat_tx_mrd, 0x000011), >>> +    HISI_PCIE_PMU_EVENT_ATTR(bw_rx_dl, 0x010084), >>> +    HISI_PCIE_PMU_EVENT_ATTR(bw_tx_dl, 0x030084), >>> +    NULL >>> +}; >>> + >>> +static struct attribute_group hisi_pcie_pmu_events_group = { >>> +    .name = "events", >>> +    .attrs = hisi_pcie_pmu_events_attr, >>> +}; >>> + >>> +static struct attribute *hisi_pcie_pmu_format_attr[] = { >>> +    HISI_PCIE_PMU_FORMAT_ATTR(event, "config:0-15"), >>> +    HISI_PCIE_PMU_FORMAT_ATTR(subevent, "config:16-23"), >>> +    HISI_PCIE_PMU_FORMAT_ATTR(thr_len, "config1:0-3"), >>> +    HISI_PCIE_PMU_FORMAT_ATTR(thr_mode, "config1:4"), >>> +    HISI_PCIE_PMU_FORMAT_ATTR(trig_len, "config1:5-8"), >>> +    HISI_PCIE_PMU_FORMAT_ATTR(trig_mode, "config1:9"), >>> +    HISI_PCIE_PMU_FORMAT_ATTR(port, "config2:0-15"), >>> +    HISI_PCIE_PMU_FORMAT_ATTR(bdf, "config2:16-31"), >>> +    NULL >>> +}; >> >> I am just wondering how this now works. >> >> So if the user programs the following: >> ./perf stat -v -e hisi_pcieX/lat_rx_mrd/ >> >> Then the value (incremented) in HISI_PCIE_CNT (I think that's the >> right one) is returned as the event count. But one would expect >> bandwidth from that event, while we only return here the delay cycles >> - how is the count in HISI_PCIE_CNT_EXT exposed, so userspace can do >> the calc for bw? >> > Hi Qi, > > Hardware counter and ext_counter work together for bandwidth, latency, > bus utilization and buffer occupancy events. For example, for latency > events(idx = 0x10), counter counts total delay cycles and ext_counter > counts PCIe packets number. > > As we don't want PMU driver to process these two data, "delay cycles" > can be treated as an event(id = 0x10), "packets number" as another event > (id = 0x10 << 8), and driver could export these data separately. > > if the user want to calculate latency of rx memory read, they should: > ./perf stat -v -e '{hisi_pcieX/event=0x10, > subevent=0x01/,hisi_pcieX/event=0x0400, subevent=0x01/ > > and for bandwidth event: > ./perf stat -v -e '{hisi_pcieX/event=0x4, > subevent=0x02/,hisi_pcieX/event=0x1000, subevent=0x02/ I would suggest supporting a perf metric for this then, which would be like: { "BriefDescription": "Latency for inbound traffic...", "MetricName": "hisi_pcie_lat_rx_mrd", "MetricExpr": "hisi_pcieX@event\\=0x4@subevent\\=0x02 \ hisi_pcieX@event\\=0x1000@subevent\\=0x02 \", "Unit": "hisi_pci", "Compat": "v1" }, (syntax may be incorrect - illustration only) > > Then the value in HISI_PCIE_CNT and HISI_PCIE_EXT_CNT returned > separately, and userspace could do the calculation. But I am still curious about lat_rx_mrd and the other events which we continue to advertise. They don't really provide latency or bandwidth on their own, but only half the necessary data. So I doubt their purpose. Thanks, John