Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp957923pxb; Fri, 13 Aug 2021 10:03:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBi0BNIOoHUNfUo8nfffQJf2VW1k6WMKdgitkPJaU+xkMOo64m6nTtPvW3ieo8WvrShByQ X-Received: by 2002:a02:5bc5:: with SMTP id g188mr3293499jab.136.1628874186439; Fri, 13 Aug 2021 10:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628874186; cv=none; d=google.com; s=arc-20160816; b=fxY7vja9hpp5KzJVoQ6x2UHTEiYbwl//GMHuO7zFnKZEyGbgpZhZnRArAMpRiZ7R9U vJj5w02IuEH2VZ3wZihomO1nOG+S3Qa9UHZBn6dcFajYbuqtFmzbN3gZ1ArpJEMiyKn9 HOvrN+VCh99YfJTRz31N9KSotwyhLGDIqGust44AbMm7zsNRY/GkTSgYtEtvjQa584c6 55HKUtFVLNezLpM+M1r/v+uWmKS+ScxR+oakualI0zrWSDepHbIrgd8z3ZON/ldETZE/ mta0UHWuVvAtZSbZZA8jwMDQ/nKPjJNEoVnthmw2Kv2rYCCnEHHpy1B29hBO3Z+5gE+g 99pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=zdWV5RvLzxGzbYCFFz4h8nNmO1RV4Mpqj1lsUYzu0Lk=; b=fbKrb15grLslkMzRcPOS5FGHddMSkK23sF0org3/bsoXvR2rg/SPKzZlQtNq3O8g38 sLF6qQn0XUsgupJEv2QLAfEBroKBkYjyNpjpIxYQc3I5TCtuMW4lBm36KbH9sbeMAq0V GJiXXAxrF2jzhlplScpszpfSO/V+sECpiJ0gWIs0T3netl7ATn0uQAwvo6BOeIQK9xeR YdD1eDMpb5DWiq7b5U3yG1AGEpuzEcxExom2TGRQ5jgKl0UwUDaDSOjb9bVuNQP3yzot uYJt9q75lqbtbeL3jKz9zc8YiYgqmti5/NopTJ5kaP+Ui3devn7NLXgl1cMoDhyxuE/U YPXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oSCyvDo4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z21si2086568jao.126.2021.08.13.10.02.54; Fri, 13 Aug 2021 10:03:06 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oSCyvDo4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240028AbhHMOk7 (ORCPT + 99 others); Fri, 13 Aug 2021 10:40:59 -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