Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp8006009rwn; Wed, 14 Sep 2022 07:38:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Hd69gZAXYoUAIJg26FmrZ/LQ53sHlnXrO+Cv3+w6ZyeZSQCMtku+TLOfoZbPA62WfIpKB X-Received: by 2002:a17:902:d4c9:b0:178:1e39:31f7 with SMTP id o9-20020a170902d4c900b001781e3931f7mr20544253plg.142.1663166326184; Wed, 14 Sep 2022 07:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663166326; cv=none; d=google.com; s=arc-20160816; b=z4LcqDOVPlZB5dk8zFeRrdgpJgQDG63c81ZLjbPpfpKEX+t6++kJaFgjXJSOLQs27Q lSxBcxpcPrU9IL8V+DnLfnnVj6DDmcbpjhwNuj2PkUEgNAh1xPLqxIJMf6dOX/gccn0R 5LTb1Hesdt0bVZsVhFRr/y9BPigVcmGLRGykZupzxzwWU3TUhj5++2m1kkW4pcAE8AvZ RtVqXQKA/7CiOkpS0muDxpHwioZce5Fj1ZMHCMubq6PB9V25vMtG23otOGVJNiTwOpP8 5P/On1SLyQ5PdHjUmnQ2xKIlq+Ru5/bKrx8PgpFguFicRpT3qhvSByi7uBMF9h+gW4Y+ jXXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CamYkk6hyQ6W/FkGD4SGaKOkaQ0RW1D0VrreKLd+PLg=; b=b/WWShM/EZUyH87xVv2+x+XzbVYOZGnU0zmcZ1awJuvPFwuBNItv5WpDL1/kRLsKBM YwdU6TOdNdDSowrq4fPd3h+rSv4731i6r5+9BNjXiw9jhkC/TfMZ8PvFwbtuJ2AHXNAY I83NHuVWbZ4dxjD1L34ZgnrNCrcj6mYKGa459NJ7uRh61hFKGbsBZzoH6zy/f4PjGViD 8UV5+fdjUmjrxax3NcTYPwzz2/Ijaz21lmG1O+3FGcLanaGcUwDkkhSwN7Z/wtEWopbe RcS7jYRXDGfzrf2DV9Ee7gWM8hta9gQ8IvCZ8mAAjYd3ikDir+H/vt8dCUWraBqLXywR 49Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u56wYV3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a17090322c700b00174a8d357b0si15901142plg.202.2022.09.14.07.38.33; Wed, 14 Sep 2022 07:38:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u56wYV3a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229446AbiINO1i (ORCPT + 99 others); Wed, 14 Sep 2022 10:27:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbiINO1e (ORCPT ); Wed, 14 Sep 2022 10:27:34 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 209CD264C for ; Wed, 14 Sep 2022 07:27:33 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id k21so4766819pls.11 for ; Wed, 14 Sep 2022 07:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=CamYkk6hyQ6W/FkGD4SGaKOkaQ0RW1D0VrreKLd+PLg=; b=u56wYV3aH2fK+ZrJQ7oF8346nuZfmInRSgBL9Eje8NRerq3bY8k0Jh2pJg816PYes/ wEAvIXe9IfB4nfpjkFYTFzzS4O7vwVohql7MNPbovpQOTOZqThUOAD64Zm1DBJXLnV2w LHCtank+3g29r4y919GrOShxdbBFa33PUjJ/scg3+/s22znmZTchZqmZ2xPchIM2rYPn C5NWGITdMShhMfkUPVA1Lmqy2mbB0Jp0vQLHJ8vzsCx8X9QB8Rnj6lBSwHvTArzB8yND 9MSqnSGzoADtPGHzNdVTynGMpSLm/3rvfzs/QYFIwSBu9PQPV73gA6WEjk5dfxo83y9F z21A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=CamYkk6hyQ6W/FkGD4SGaKOkaQ0RW1D0VrreKLd+PLg=; b=MAiVpz8FSitKAKca/8YdlotfO49Z4MY9eWrZwkjs+GgU22kuZidJBxiFW0Za/3Uhr8 BiKJf1Y9SBPXRM8XnTvgdNESzi/u2q1h3goWd87MBgAUlUaGArEQPBWeZGt9WMRsgBse oSGQPxKmg+J6BeQQGXAgoEkkGZJ5CNLWe5qzGiplfZza2xNbtJ51CVE2xBjnVRHq0i5K 8+gyvY4Cv88xjOHntV/iMwERMgBAYyks5dwMp3Ywm5MGx/q6zRRO7CQylKJrm/m1BM2Y AHTkhBRlhzoWQTwXLzVilLGJPdAVeauZ8V/akoSOr5ZyjMW1IKh9wzvJY4WG0huTWX3g gk+Q== X-Gm-Message-State: ACgBeo1DVhN9NAWKI9Pee6KddZMAkA9eN0oFQSR/E3CozZtg4sKAIC3O J3OAEyK16NDhuQQTzZbo3BLhMQ== X-Received: by 2002:a17:902:ecd2:b0:178:3b53:ebf7 with SMTP id a18-20020a170902ecd200b001783b53ebf7mr11608823plh.28.1663165652471; Wed, 14 Sep 2022 07:27:32 -0700 (PDT) Received: from leoy-yangtze.lan (n058152048222.netvigator.com. [58.152.48.222]) by smtp.gmail.com with ESMTPSA id c3-20020a654203000000b0042c0ffa0e62sm9857405pgq.47.2022.09.14.07.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 07:27:32 -0700 (PDT) Date: Wed, 14 Sep 2022 22:27:23 +0800 From: Leo Yan To: John Garry Cc: Yicong Yang , acme@kernel.org, peterz@infradead.org, alexander.shishkin@linux.intel.com, james.clark@arm.com, will@kernel.org, mathieu.poirier@linaro.org, mark.rutland@arm.com, suzuki.poulose@arm.com, jonathan.cameron@huawei.com, mike.leach@linaro.org, gregkh@linuxfoundation.org, helgaas@kernel.org, lorenzo.pieralisi@arm.com, shameerali.kolothum.thodi@huawei.com, 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, prime.zeng@huawei.com, zhangshaokun@hisilicon.com, linuxarm@huawei.com, yangyicong@hisilicon.com, liuqi6124@gmail.com Subject: Re: [RESEND PATCH v12 1/3] perf tool: arm: Refactor event list iteration in auxtrace_record__init() Message-ID: References: <20220914075925.48549-1-yangyicong@huawei.com> <20220914075925.48549-2-yangyicong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 On Wed, Sep 14, 2022 at 02:47:43PM +0100, John Garry wrote: [...] > > 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); > > should you break if found_etm and found_spe are set? Or, indeed, error and > return directly as we do below? Indeed, I am not sure why you even require > auxtrace_event_cnt I think this was my suggestion :) We can check if both 'found_etm' and 'found_spe' are set and directly break (and bail out) for this case. But it would introduce more complex checking if we connect with patch 2 with new flag 'found_ptt', something like: if ((found_etm && found_spe) || (found_etm && found_ptt) || (found_spe && found_ptt)) break; This is hard for later's extension if we need to support a new auxtrace event, so using auxtrace_event_cnt would be easier to extend more auxtrace event on Arm platforms. Thanks, Leo > > } > > + > > 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; > > } >