Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp361121iof; Mon, 6 Jun 2022 05:03:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSRotuQETnsRi0Zghil6pMyJ9YZKlhuRj7jKN9PCZ53of4S43hu8AnzA5IqIqUD3nkoMSs X-Received: by 2002:a62:1a90:0:b0:51c:24cf:b9af with SMTP id a138-20020a621a90000000b0051c24cfb9afmr3339094pfa.7.1654517025133; Mon, 06 Jun 2022 05:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654517025; cv=none; d=google.com; s=arc-20160816; b=EVei1AHoLH7F9R+Eq8t2qqSQmqrSf0fm4inNdmyjgb2m9qE0zstaKy5N0juhERx4+0 07OAAUYICSPLZe7INKvIoKOQQoWYbgt7L4dsS/7IQLEa3jkCU3qSAvdYGGhh3kNFH2pc Oe1DpDq+r8XmhDmGhUd2SwxsA7cyB4R8Ud2rOmc3emG8OGxfSZQuzKQJPH8mn6JwRQLu B/n5ehDNxX4n0dwVx7GLRZIzllSGMyq/fctweME9Q84YLpM8ac6nnhGSTowzW0WaxfHV I2/ZRGILBGgo/W6pAmEDK5SgouG8Z4qxT0U0GmO6TiQ67P+Hwgoy/ZM96irVjCZE8pyt oBWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0nOnCdssev6JJqQkvEtW17fs6Zm/ziIo/+5Mn+nTS40=; b=cwveXtVudDeBaw5HLbYqQ30FO80fA2N91U4NeE8WxVD++DNRMfJ39BTPg6UOyLj3lZ NpxwqblKo6yJFZgdklLpwd2jKUAVTs8skmS7P6FKpYEoBCMf08Tq6oB2+inQV9d2PkZc lQBff7VDdWW9efWHZFDIuZkF9Gf3aZv8DNzK3DX/rxRPE0fLFIn2hIeruW4GBKbNpmnN ZjTMaewiiScUYf8KXzRVkWWQk4Hifxapa/m/TkjBfwf6SElWuYFFhRREM7ifh3w9P+/y 2KQbJBVknQpbYSVg1y8Q+lC4LkreXUdJbAqhqkxuzI+lvFgd3m6CJiGqOk2PbdaBQs4m zx1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 8-20020a631648000000b003fc19708048si22078570pgw.318.2022.06.06.05.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 05:03:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 382DABBCFE; Mon, 6 Jun 2022 04:58:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236023AbiFFL6N (ORCPT + 99 others); Mon, 6 Jun 2022 07:58:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235952AbiFFL5V (ORCPT ); Mon, 6 Jun 2022 07:57:21 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 746E7DF; Mon, 6 Jun 2022 04:57:09 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LGsPr4XfZzjXX8; Mon, 6 Jun 2022 19:55:44 +0800 (CST) Received: from localhost.localdomain (10.67.164.66) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 6 Jun 2022 19:57:01 +0800 From: Yicong Yang To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 4/8] perf tool: arm: Refactor event list iteration in auxtrace_record__init() Date: Mon, 6 Jun 2022 19:55:51 +0800 Message-ID: <20220606115555.41103-5-yangyicong@hisilicon.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220606115555.41103-1-yangyicong@hisilicon.com> References: <20220606115555.41103-1-yangyicong@hisilicon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.164.66] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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