Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp3048478pxy; Wed, 4 Aug 2021 00:33:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3qvQHfK50g9jyyLiIYtarnu7gamQ+Yz80zoKqVKdiiYje77vc9BvVKQ3e68vQfnzUVStq X-Received: by 2002:a05:6402:550:: with SMTP id i16mr30632024edx.177.1628062418879; Wed, 04 Aug 2021 00:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628062418; cv=none; d=google.com; s=arc-20160816; b=GtPaLZP7W9ljxAUyAdTnYwTWR/0s/R7BlqrQTbSCtOnCUEFE1OrfSLoJvR1ITsCfnN akNa7xMrqTPMb87Ml+Wj1ce+miODiFD43D8nPLgHPKa9qQU5qFIyLG2VjaxGAAKJifxP CdMuMtH4YirVqJLgH2VE+g30+GefvsoPzNgd8WhkzQHaPqHDlA1HM56cPz6+eNaRxKxj wvtRcOWd8pcySK4VOo+iP/NhFbnPp4Hn73t6kFBh2HoXPchdGlnS0Q9r7cRJE796+IGi H4ChpBn2NM0ubPTnTnOrbTE7DesgcdzM6VHNwiCTe+q5AmH4G8UMZuDKJR7EWR2IhsJZ xNHA== 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=QoTONAjPhgA/x5fW8/UAxjhQiW6LCWzJrcP/K5nUeM0=; b=kkESjU+EeUtPBj/Jm8mLaX493sUwn+nq+XH83d3uIEBz/NgmZOf/3AcyFU5q91BeI5 sSIs49Zd5yUtUTTcsVCK6qvvUllpQSDDlOHVPP3rsV1bs8conkCN/1dE9JWSnfGCggOO f9V38fbYxnsIVzk3mwBg8qRPJgHVQLYlNnYIUppzQnDIpONW3DhLWkE6Ab6RG3PJS9i6 JrHyMHlidEZsdeHaofHeRm6+7PcaQY261Pz/Owm3boYQyfcKGjXFHbtXRwhHrYZ54Aja HYQQg6fP01kSuEdhoFSBFblaVt+0jKexJ9HrhH3WG1b0OcnHMFvFRIIFWhVQ9iD+WUsp 10VQ== 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 f12si523976edx.601.2021.08.04.00.33.14; Wed, 04 Aug 2021 00:33:38 -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 S235810AbhHDHaK (ORCPT + 99 others); Wed, 4 Aug 2021 03:30:10 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:12444 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235794AbhHDHaJ (ORCPT ); Wed, 4 Aug 2021 03:30:09 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GfjwF6KckzcklS; Wed, 4 Aug 2021 15:26:21 +0800 (CST) Received: from dggema757-chm.china.huawei.com (10.1.198.199) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Wed, 4 Aug 2021 15:29:55 +0800 Received: from [127.0.0.1] (10.69.38.203) by dggema757-chm.china.huawei.com (10.1.198.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 4 Aug 2021 15:29:55 +0800 Subject: Re: [PATCH v8 2/2] drivers/perf: hisi: Add driver for HiSilicon PCIe PMU To: Will Deacon , Linuxarm CC: , , , , , References: <20210728080932.72515-1-liuqi115@huawei.com> <20210728080932.72515-3-liuqi115@huawei.com> <20210802100343.GA27282@willie-the-truck> From: "liuqi (BA)" Message-ID: Date: Wed, 4 Aug 2021 15:29:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20210802100343.GA27282@willie-the-truck> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Originating-IP: [10.69.38.203] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggema757-chm.china.huawei.com (10.1.198.199) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Will, > Hmm, I was hoping that you would expose all the events as proper perf_events > and get rid of the subevents entirely. > > Then userspace could do things like: > > // Count number of RX memory reads > $ perf stat -e hisi_pcie0_0/rx_memory_read/ > > // Count delay cycles > $ perf stat -e hisi_pcie0_0/latency/ > > // Count both of the above (events must be in the same group) > $ perf stat -g -e hisi_pcie0_0/latency/ -e hisi_pcie0_0/rx_memory_read/ > > Note that in all three of these cases the hardware will be programmed in > the same way and both HISI_PCIE_CNT and HISI_PCIE_EXT_CNT are allocated! > > So for example, doing this (i.e. without the '-g'): > > $ perf stat -e hisi_pcie0_0/latency/ -e hisi_pcie0_0/rx_memory_read/ > > would fail because the first event would allocate both of the counters. I'm confused with this situation when getting rid of subevent: $ perf stat -e hisi_pcie0_0/latency/ -e hisi_pcie0_0/rx_memory_read/ In this case, driver checks the relationship of "latency" and "rx_memory_read" in pmu->add() function and return a -EINVAL, but this seems lead to time division multiplexing. if (event->pmu->add(event, PERF_EF_START)) { perf_event_set_state(event, PERF_EVENT_STATE_INACTIVE); event->oncpu = -1; ret = -EAGAIN; goto out; } ... out: perf_pmu_enable(event->pmu); This result doesn't meet our expection, do I miss something here? How about add an array to record events and check the relationship in event_init() function? It seems that perf stat could only failed when driver return invalid value in pmu->event_init() function. Thanks, Qi > > All you need to do is check the counter scheduling constraints when > accepting an event group in the driver. No need for subevents at all. > > Does that make sense? > > Will > . >