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 67403C433EF for ; Mon, 27 Jun 2022 01:21:12 +0000 (UTC) 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=tPhlm8HZCuDehUOKrmaC0BO9sy68PPXtNQhdNbPndMw=; b=e/3IRpApAwyY5h Kr2rGku6UwDLOJ8wgcSKVR1RD2W3sfigd+6rhsG5kpePIpeLOB/vFHrSS2/lKsyZSfd3jGkEOQ2B3 WXlb4Ib9tgxVGv+rPpbX6XlcFJDnC6XHfDcFphaSXySij6v5u+ES5glD3d2LbM2K3KJWxtCOkg6sh 4CNDcWTNl5UaNkBRfjp6c0nfkbXEwMLuoPc114HJ12ki5tAwKfYb8K6k64g75d8TYLb7ogRCX87oN md12j0DpN5WKA/fYeTkIHMNhFGIBvA871JKCjyd0DSwjQP9OqxU7JocoV90eutHaXdjab8FAUW0ar 7M2vUQNE8ru/4zxa2Bzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5dQ5-00ERiN-Jn; Mon, 27 Jun 2022 01:20:05 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5dQ2-00ERgn-EM for linux-arm-kernel@lists.infradead.org; Mon, 27 Jun 2022 01:20:03 +0000 Received: by mail-pl1-x632.google.com with SMTP id m2so6837876plx.3 for ; Sun, 26 Jun 2022 18:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JiM3N5evqJOowVHWeRy1BwX3FfyhynbxcUWkOm6L1ik=; b=MsSky8rDDNs+PaeJiRVQB1ywR02u//iGONyyvf7FEtTfEv4lDjV4I0s9czbxLDUlC7 hsbylmLh4lkwFDR2wcTssR4JKfGmiC0X2jbsyTQqZ8piT/seBMuw9fJg5afyGhwP6hWJ h4KVr+A/lgCTGixqzRRf/QAH3Ih2kD9CrSUYJyArsX3bkBBSeQWDmcUaIaTgp/poVGou wCELTMGy/eNdRn8wkTfLBYMviw3HKzeBKLaP4DuXF7jOANwxuL7mwKoQdphN9VwfycyL EYnKRM7gBzMgq54yzBZbT0+8WpoxkEAGhh9PIHUMCo7yarxf3rbI8yqoZGFOpq3EQwXU GTEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JiM3N5evqJOowVHWeRy1BwX3FfyhynbxcUWkOm6L1ik=; b=TCMbQEOOb17wrpQBIn5K5yLYaZRBBtUZaPsUtmOZukpG2QagvwAGHYvP/dMlmSAA/P RJB2B+hpI3svTmu+zztCz2mLsijhNzyuEVJxHzKoreKbxI4m7D02NlEOWkelgK9tugEU h53DSb6HwhTa8CU/OCSlyT5HkrMYwAIr96Z939wCFIBdnKR+DxwaYCtTOJW3APcOX51b mdi3RDfRGVbu+zGAUosRGN7phrP6U/jXfFLbQNkUNFejY4wv835Xlo7XROOoqPJ4g+Pj xy4K5A7q31FfVXRQ+5Q3sFW+bdXp2YqsJbZeINTc+rfJXziYset9sMHhAbY+JeThHSCc fp3A== X-Gm-Message-State: AJIora8QJsW7jmYUa6ZqXhe2qpNbqoCQuGzzsT12zROYQm2kZyESVm+8 fFPGRDED/s5xzhx8Nnf7JEw4qw== X-Google-Smtp-Source: AGRyM1t2oztCFYrN6uMQKxDHkXdOqDSQ8UIJhLBDVPzheHA8LqCKnazYXDAdI5hfVtGXQ8ObBUyVpQ== X-Received: by 2002:a17:903:1cf:b0:16a:605a:d58a with SMTP id e15-20020a17090301cf00b0016a605ad58amr11786381plh.37.1656292800336; Sun, 26 Jun 2022 18:20:00 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([103.135.249.206]) by smtp.gmail.com with ESMTPSA id n22-20020a17090a161600b001ecd48b80a2sm8064260pja.5.2022.06.26.18.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jun 2022 18:19:59 -0700 (PDT) Date: Mon, 27 Jun 2022 09:19:52 +0800 From: Leo Yan To: Yicong Yang Cc: gregkh@linuxfoundation.org, alexander.shishkin@linux.intel.com, james.clark@arm.com, will@kernel.org, robin.murphy@arm.com, acme@kernel.org, jonathan.cameron@huawei.com, john.garry@huawei.com, helgaas@kernel.org, lorenzo.pieralisi@arm.com, mathieu.poirier@linaro.org, suzuki.poulose@arm.com, mark.rutland@arm.com, joro@8bytes.org, shameerali.kolothum.thodi@huawei.com, peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-perf-users@vger.kernel.org, iommu@lists.linux-foundation.org, prime.zeng@huawei.com, liuqi115@huawei.com, zhangshaokun@hisilicon.com, linuxarm@huawei.com Subject: Re: [PATCH v9 4/8] perf tool: arm: Refactor event list iteration in auxtrace_record__init() Message-ID: <20220627011952.GA143063@leoy-ThinkPad-X240s> References: <20220606115555.41103-1-yangyicong@hisilicon.com> <20220606115555.41103-5-yangyicong@hisilicon.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220606115555.41103-5-yangyicong@hisilicon.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220626_182002_605159_B7DB0745 X-CRM114-Status: GOOD ( 22.23 ) 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 Mon, Jun 06, 2022 at 07:55:51PM +0800, Yicong Yang wrote: > From: Qi Liu > > Add find_pmu_for_event() and use to simplify logic in > auxtrace_record_init(). find_pmu_for_event() will be > reused in subsequent patches. > > Reviewed-by: Jonathan Cameron > Signed-off-by: Qi Liu > Signed-off-by: Yicong Yang Reviewed-by: Leo Yan > --- > tools/perf/arch/arm/util/auxtrace.c | 53 ++++++++++++++++++----------- > 1 file changed, 34 insertions(+), 19 deletions(-) > > diff --git a/tools/perf/arch/arm/util/auxtrace.c b/tools/perf/arch/arm/util/auxtrace.c > index 5fc6a2a3dbc5..384c7cfda0fd 100644 > --- a/tools/perf/arch/arm/util/auxtrace.c > +++ b/tools/perf/arch/arm/util/auxtrace.c > @@ -50,16 +50,32 @@ static struct perf_pmu **find_all_arm_spe_pmus(int *nr_spes, int *err) > return arm_spe_pmus; > } > > +static struct perf_pmu *find_pmu_for_event(struct perf_pmu **pmus, > + int pmu_nr, struct evsel *evsel) > +{ > + int i; > + > + if (!pmus) > + return NULL; > + > + for (i = 0; i < pmu_nr; i++) { > + if (evsel->core.attr.type == pmus[i]->type) > + return pmus[i]; > + } > + > + return NULL; > +} > + > struct auxtrace_record > *auxtrace_record__init(struct evlist *evlist, int *err) > { > - struct perf_pmu *cs_etm_pmu; > + struct perf_pmu *cs_etm_pmu = NULL; > + struct perf_pmu **arm_spe_pmus = NULL; > struct evsel *evsel; > - bool found_etm = false; > + struct perf_pmu *found_etm = NULL; > struct perf_pmu *found_spe = NULL; > - struct perf_pmu **arm_spe_pmus = NULL; > + int auxtrace_event_cnt = 0; > int nr_spes = 0; > - int i = 0; > > if (!evlist) > return NULL; > @@ -68,24 +84,23 @@ struct auxtrace_record > arm_spe_pmus = find_all_arm_spe_pmus(&nr_spes, err); > > evlist__for_each_entry(evlist, evsel) { > - if (cs_etm_pmu && > - evsel->core.attr.type == cs_etm_pmu->type) > - found_etm = true; > - > - if (!nr_spes || found_spe) > - continue; > - > - for (i = 0; i < nr_spes; i++) { > - if (evsel->core.attr.type == arm_spe_pmus[i]->type) { > - found_spe = arm_spe_pmus[i]; > - break; > - } > - } > + if (cs_etm_pmu && !found_etm) > + found_etm = find_pmu_for_event(&cs_etm_pmu, 1, evsel); > + > + if (arm_spe_pmus && !found_spe) > + found_spe = find_pmu_for_event(arm_spe_pmus, nr_spes, evsel); > } > + > free(arm_spe_pmus); > > - if (found_etm && found_spe) { > - pr_err("Concurrent ARM Coresight ETM and SPE operation not currently supported\n"); > + if (found_etm) > + auxtrace_event_cnt++; > + > + if (found_spe) > + auxtrace_event_cnt++; > + > + if (auxtrace_event_cnt > 1) { > + pr_err("Concurrent AUX trace operation not currently supported\n"); > *err = -EOPNOTSUPP; > return NULL; > } > -- > 2.24.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel