Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp33779ybk; Fri, 8 May 2020 17:42:06 -0700 (PDT) X-Google-Smtp-Source: APiQypL8AZ6I8bXtix53c6a6LBcWCu28wAj5JwWNq0mPiV8nxdPq5TjrP+ZzL0AcfdRZDJel2dME X-Received: by 2002:a05:6402:1d1c:: with SMTP id dg28mr4497296edb.315.1588984926253; Fri, 08 May 2020 17:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588984926; cv=none; d=google.com; s=arc-20160816; b=DpTMjnkGk/px+HYC1owWWjEj6KQ3iw1V2WreseFUy8wEz+ufHzSQt0YTO2HiSKA2JI vCuPeLpdy15jqnJpYGiBM7R8LbiWP8z85f6qbvIItLJuvLVKZg3zIM1ZUK5hw9u3ur5M 0q61ab6S0+H8XU2cvjV4IAflDuvDEawBpbI5JXLWkj2JW+4tL97te2RSMu2hSrS8UcjB 8NOgGdUWClzQYTSXmqWt/rhrRfbtBNBgUR4aqMy/uFm+T88lj0szimtZNWqxje+JK251 eJHL0F0c9IGLAd4PwtzB584iWkHviyyZKKdQNFggU5DcPrYvnCG86imb+lwyGOtwF+3t gT5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=+/9Cxaf0f3LaSkfP1o6YH+iLcKHHyesZlFYjvD5wPvM=; b=GcYIxQUB0idoCqs/UN0KCTB2VsNjczawz+hxEp7c7JpSL6BUNMNarehUz2VmTz2B6V RsTfz4FL0fUEuqPURuwu2wv+9SkepjVzhB/86Z+yeH/L8N5M3oMOXA1DSMNr3YPTYemE CEr3Xf+QI1YV4uHZXHRBPWSpy3iDCMx7oss1S1pi/JsBnh1fweXSq2w2PFI8pdgBnLIY BtJB+YwhKk7zxkiRjcfLyEIGDgDWLWTKP6NTQ60u1pdIsEX5ahyJAOHZ1h8nFoGazni6 xHAlnJtKyH5MIi0ptRMHTsHwUFHYmkjfrnf1AGylQL0zBiBpeLuRvdVL8ReQ1GyiJeSu M52w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si2003334edt.286.2020.05.08.17.41.43; Fri, 08 May 2020 17:42: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728447AbgEIAic (ORCPT + 99 others); Fri, 8 May 2020 20:38:32 -0400 Received: from mga04.intel.com ([192.55.52.120]:3157 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727878AbgEIAib (ORCPT ); Fri, 8 May 2020 20:38:31 -0400 IronPort-SDR: aopw/5m44GsnUnkU1UtPtopuLYOg5xUtm14EvccOz4UiwM0pFZW+oFS8saxF4FNlGpEQy55wKv MdQkV1M55APg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2020 17:38:30 -0700 IronPort-SDR: q+sV77rbJRSonenXnHAbxIaNJcsxfDDnbUmDtOAuy5/ssIMbKCf1nWEdjdgakP2jskGvmkmC8t JWZnt/bd8Y3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,369,1583222400"; d="scan'208";a="279197066" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.21]) by orsmga002.jf.intel.com with ESMTP; 08 May 2020 17:38:30 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id 79BCB301C4C; Fri, 8 May 2020 17:38:30 -0700 (PDT) Date: Fri, 8 May 2020 17:38:30 -0700 From: Andi Kleen To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Kajol Jain , John Garry , Jin Yao , Kan Liang , Cong Wang , Kim Phillips , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, Vince Weaver , Stephane Eranian Subject: Re: [RFC PATCH v3 13/14] perf metricgroup: remove duped metric group events Message-ID: <20200509003830.GG3538@tassilo.jf.intel.com> References: <20200508053629.210324-1-irogers@google.com> <20200508053629.210324-14-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200508053629.210324-14-irogers@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > static struct evsel *find_evsel_group(struct evlist *perf_evlist, > struct expr_parse_ctx *pctx, > + bool has_constraint, > struct evsel **metric_events, > unsigned long *evlist_used) > { > - struct evsel *ev; > - bool leader_found; > - const size_t idnum = hashmap__size(&pctx->ids); > - size_t i = 0; > - int j = 0; > + struct evsel *ev, *current_leader = NULL; > double *val_ptr; > + int i = 0, matched_events = 0, events_to_match; > + const int idnum = (int)hashmap__size(&pctx->ids); BTW standard perf data structure would be a rblist or strlist I think it would be really better to do the deduping in a separate pass than trying to add it to find_evsel_group. This leads to very complicated logic. This will likely make it easier to implement more sophisticated algorithms too. -Andi