From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A34BC432BE for ; Wed, 4 Aug 2021 07:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31FDF60F14 for ; Wed, 4 Aug 2021 07:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235832AbhHDHaK (ORCPT ); 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 > . > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F930C4338F for ; Wed, 4 Aug 2021 07:32:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B76960EBC for ; Wed, 4 Aug 2021 07:32:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2B76960EBC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:CC:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+oH/9C/E6cdeYSzMRFO496HzyNe500C/06+YXk6M19A=; b=DeuDP1o0bw4GrpLZtzKFDX4uGo pVQzV+2gacuJ38gREIYdkL4LnObJ73C92XngK6zKZho801SErUns65C4SF+VUauNxT5aaXx6nZzJu vIn1+iAjeBzAo5hIPI9L+b0hff/EhX/J8LJYeUSxa8iXAHERQRP+fZbWBqnst0gx8ShRgJ3i9ZSHh hgm5UkXYmsUVBm56Lt3Xz0nSvz02KeaRe4KwX+A4nQiADll+BtAVHF08EwgWpweL6RG62LVvuKyge HH1yC50JnENPzETlRXIwr6xtOE5gXn52VchEY3ZRpSyyGm/tOpt930W+dmwgPQUwR/q0PkipVWqk7 PF/s+C7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBBLq-00524K-N7; Wed, 04 Aug 2021 07:30:06 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBBLl-00522M-Dz for linux-arm-kernel@lists.infradead.org; Wed, 04 Aug 2021 07:30:03 +0000 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-Language: en-GB 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210804_003001_755867_2EE8D487 X-CRM114-Status: GOOD ( 16.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 > . > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel