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=-8.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 C0DE7C4320A for ; Fri, 13 Aug 2021 14:40:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A776A61042 for ; Fri, 13 Aug 2021 14:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240208AbhHMOlA (ORCPT ); Fri, 13 Aug 2021 10:41:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:37900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233567AbhHMOk7 (ORCPT ); Fri, 13 Aug 2021 10:40:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D21FB60C41; Fri, 13 Aug 2021 14:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628865632; bh=TEm9YvfBKh/4TWLPQEvxHMgFmR94Ffoma7V7+FbCf2g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oSCyvDo4v9AGN0vHNPFNmb/eBr3a05wA1I/dtDxU+F0kPtqz2V2oCZST0tF6qpSG6 F6nwfyutMDLHKGQnPOP0gRuuBST9jfg1HI0qiMdgKmWXRPHAHLggu6upXL/PepcRU0 gY9asf9N/izvW3UwDG2yAF1TMpu9+YPWS0Fl2iUJ/yOP9ZGjyzZyGqP9TASQj73iJW XW53Vli/h05uRyviNstjvjNh1KVjlG4IyRwBTgId6CiKN7XKZY/BM66MwiepaldIXV iXiL1UJdtNAAs/Iy1SgUa8qsS7ic8RS5qtD39IgxqLrFGS8PelOq8D+kgckJ3pJu8X SVCmWe/hs7/tg== Date: Fri, 13 Aug 2021 15:40:27 +0100 From: Will Deacon To: "liuqi (BA)" Cc: Linuxarm , mark.rutland@arm.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, zhangshaokun@hisilicon.com Subject: Re: [PATCH v8 2/2] drivers/perf: hisi: Add driver for HiSilicon PCIe PMU Message-ID: <20210813144026.GA8451@willie-the-truck> References: <20210728080932.72515-1-liuqi115@huawei.com> <20210728080932.72515-3-liuqi115@huawei.com> <20210802100343.GA27282@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 04, 2021 at 03:29:54PM +0800, liuqi (BA) wrote: > > 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? This is how perf works. If you don't want multiplexing, put the events in a group. What's the problem with that? 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.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,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 E4466C4338F for ; Fri, 13 Aug 2021 14:42:57 +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 A7EB460C41 for ; Fri, 13 Aug 2021 14:42:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A7EB460C41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7wK7SOEYaEPCHC0upFIQJI8aNe0dS405SUecgmJjFRM=; b=PaOGl2SE422nqj zcNG7NL9V/IKXfRFLhTUVRoyM6HJ3WMXQ6eHARWHHI2JciHVOqexbI1KPdIwpMya++dlcjT4ouO4c oos7V99Ahq676+zU0kCF6tLsNFd7mvMl14AofYv6usFroGND4jiQ5SfQNGmQseqCGMnAWLUtz4+Tz kGSsSkZinegGJGTBFjqquohyCGuOXkpR4f3EJLYI9OH8xNxzGvP4S0/6/xU3XGXZbJzMX9VGlKSjJ LGcZDJWlJJrIKqTZA1h4z0CgvX/YsBwkvb2lDZ/HDQeC1HbMpV73l1lk7NDZIym37j1FvKROTsdKf H7W8QJKa9Roi0OjNbhUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mEYMO-00CpHO-A6; Fri, 13 Aug 2021 14:40:36 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mEYMK-00CpGa-Ok for linux-arm-kernel@lists.infradead.org; Fri, 13 Aug 2021 14:40:34 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id D21FB60C41; Fri, 13 Aug 2021 14:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628865632; bh=TEm9YvfBKh/4TWLPQEvxHMgFmR94Ffoma7V7+FbCf2g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oSCyvDo4v9AGN0vHNPFNmb/eBr3a05wA1I/dtDxU+F0kPtqz2V2oCZST0tF6qpSG6 F6nwfyutMDLHKGQnPOP0gRuuBST9jfg1HI0qiMdgKmWXRPHAHLggu6upXL/PepcRU0 gY9asf9N/izvW3UwDG2yAF1TMpu9+YPWS0Fl2iUJ/yOP9ZGjyzZyGqP9TASQj73iJW XW53Vli/h05uRyviNstjvjNh1KVjlG4IyRwBTgId6CiKN7XKZY/BM66MwiepaldIXV iXiL1UJdtNAAs/Iy1SgUa8qsS7ic8RS5qtD39IgxqLrFGS8PelOq8D+kgckJ3pJu8X SVCmWe/hs7/tg== Date: Fri, 13 Aug 2021 15:40:27 +0100 From: Will Deacon To: "liuqi (BA)" Cc: Linuxarm , mark.rutland@arm.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, zhangshaokun@hisilicon.com Subject: Re: [PATCH v8 2/2] drivers/perf: hisi: Add driver for HiSilicon PCIe PMU Message-ID: <20210813144026.GA8451@willie-the-truck> References: <20210728080932.72515-1-liuqi115@huawei.com> <20210728080932.72515-3-liuqi115@huawei.com> <20210802100343.GA27282@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210813_074032_869996_05372640 X-CRM114-Status: GOOD ( 21.33 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Aug 04, 2021 at 03:29:54PM +0800, liuqi (BA) wrote: > > 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? This is how perf works. If you don't want multiplexing, put the events in a group. What's the problem with that? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel