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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E43CDC3DA59 for ; Mon, 22 Jul 2024 21:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ezhCS6bVmhHcSkVJ26soypIoTiindXBOvbXnfwWeghg=; b=aolxz2rbBwtjUuJmBBkBMwEZcy sh0mOtiP8/iTA7YVwsMiBn2rJwZLuTWcOCEluViVYLT3NObnv0vHJnVaq8gUX/8bUCU4p6ifTlrfy 3OR9wge6ARYAgHEwKL4M88C8l+/bgJA9X+t1sJ8kcQU2JwEBgwcjZXXA3bVeMsqXAKjirmKN4FOCc meqJdqTtO9TuvvsJI7mB0WYcYh2M8VVagGBUyY2aaNt22rZOh7KPGq2u+L1jZlQNpMeo+LD34SKrC 4qDYZE+kW7eNJAihlBI0NAxAp62YAMInn+fZ1c/ZSyVx1w3UAn+9yXMNmv1U1L/1Sr6d83iJtpEPe V1CGvayw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sW0KB-0000000Aa6z-21tw; Mon, 22 Jul 2024 21:12:03 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sW0Jn-0000000Aa3I-2ipD for linux-arm-kernel@lists.infradead.org; Mon, 22 Jul 2024 21:11:40 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BD81E139F; Mon, 22 Jul 2024 14:12:03 -0700 (PDT) Received: from [10.57.12.31] (unknown [10.57.12.31]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F0BFC3F5A1; Mon, 22 Jul 2024 14:11:35 -0700 (PDT) Message-ID: Date: Mon, 22 Jul 2024 22:11:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/6] perf pmu: Directly use evsel's PMU pointer To: Ian Rogers Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Adrian Hunter , James Clark , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Jiri Olsa , Mark Rutland , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240721202113.380750-1-leo.yan@arm.com> <20240721202113.380750-2-leo.yan@arm.com> Content-Language: en-US From: Leo Yan In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240722_141139_760905_2DE9BC28 X-CRM114-Status: GOOD ( 16.10 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 7/22/2024 5:16 PM, Ian Rogers wrote: > On Sun, Jul 21, 2024 at 1:21 PM Leo Yan wrote: >> >> Rather than iterating the whole PMU list for finding the associated PMU >> device for an evsel, this commit optimizes to directly use evsel's 'pmu' >> pointer for accessing PMU device. > > The code doesn't do that: > ``` > struct perf_pmu *evsel__find_pmu(const struct evsel *evsel) > { > struct perf_pmu *pmu = evsel->pmu; > > if (!pmu) { > pmu = perf_pmus__find_by_type(evsel->core.attr.type); > ((struct evsel *)evsel)->pmu = pmu; > } > return pmu; > } > ``` > That is, if the evsel->pmu is not NULL then just return it, otherwise > find the pmu using the type from the attribute. Any linear such should > happen at most once unless the pmu is NULL from event parsing or > perf_pmus__find_by_type. So evsel__find_pmu() is good enough. > The PMU may be NULL for legacy events and if > sysfs isn't mounted. If you are encountering that then maybe we need a > flag to say don't find the PMU for this evsel as it is known NULL. I don't see a case of the PMU pointer is NULL. So don't need this flag. My bad for misreading the code :\ Thanks a lot for pointing out. Leo