Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp757902ybk; Fri, 15 May 2020 12:43:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEnbBFEp9bokDRsSR28rzfktOIYnTyoL10c6fOzcmQeII/bo53lS0aqRm6AAu4lOloKxLl X-Received: by 2002:a50:fb09:: with SMTP id d9mr4188337edq.129.1589571813873; Fri, 15 May 2020 12:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589571813; cv=none; d=google.com; s=arc-20160816; b=eIFoE+s4npB5bVu1pis/R/7bYbBXCFv62HcdI82a6gBxmRAGR8sMq8dmgi0CartOev 7MJMYDFTZ18sxFbnWLCiXAbtuPEzcVS0f+bMd3X/O3xNcw6ngpdJVlglPkDIDaP6W1L4 R40f/F9Cr7F3tWemXJW85vL18ohhKdqixDgBNwz+zMswr8CMGxoZ4C2bMAhXN0hOM0Na sBtw7iAX+jYAeNUjC36Yp4abwRWAhu1bZ8xSk1iHBPBYuNhCGD+UkfG18qvdOLoShsEm i+MhBXY26EqioCusUl3UGX+cE4LpSmWEicLWrCmP5ZdSA7V2aXTwm4w9SiS+r4ocLp+Q Y8Yw== 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 :dkim-signature; bh=OUOZlTx+NnYcTtCx+Ldkfxstccp83o8CLEeza083+h4=; b=MJxmz7AU/t4OfbE3E9YZdJRPmb3jjUyFano0VKNvTpr4XWoxB2SsT5vYTLxQQ7oy60 UNcSI+96kxYv+BnDuc4ejYWnkIQ649NslnPjjYfYcnVvPau+iv4Pyph1Pn5L5twu7QEh VJyrdH7HLS19ZtIrXXI2sM4QgRqpmhIIMx+9bIpZBKK2Mf2Ff0uHp5N8ygl5e8G1X0N6 H34MnbuFRTFhtR7Dr1kRITR0NtHaPW52mJ2/nlTWiqGPZ1RzieCDXpO2Z//c2JGp7YP3 cnfreoac9yTF79WWx9WL7mkcFQj7lrplCkkTvs4k9tOXTm8gCvNVdJE5gRcNCMIc75b0 tFsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VWRdhHya; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bz27si1638230ejc.475.2020.05.15.12.43.11; Fri, 15 May 2020 12:43:33 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VWRdhHya; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726266AbgEOTld (ORCPT + 99 others); Fri, 15 May 2020 15:41:33 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:52533 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726718AbgEOTlc (ORCPT ); Fri, 15 May 2020 15:41:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589571691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OUOZlTx+NnYcTtCx+Ldkfxstccp83o8CLEeza083+h4=; b=VWRdhHyax0yMPxv0e63mv9I3pIpNQ1D0/zZ09oTPVgHVoCtlIp+fRJ/PoIBMQeMpQtZ2hQ ZbZ8+7EElPZD1JT8gvr8oFDKqsoR5AoqVqK9vrYRmyaF4VHKTA1nEMhHqKPG+L5BFn6pP1 wab3oeHbSFMjWckz9ldiAP4XrPgGSWQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-372-5h7CuIQlMNSSU3X4nvjb1Q-1; Fri, 15 May 2020 15:41:27 -0400 X-MC-Unique: 5h7CuIQlMNSSU3X4nvjb1Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A2411030986; Fri, 15 May 2020 19:41:23 +0000 (UTC) Received: from krava (unknown [10.40.192.69]) by smtp.corp.redhat.com (Postfix) with SMTP id 4CA7462971; Fri, 15 May 2020 19:41:16 +0000 (UTC) Date: Fri, 15 May 2020 21:41:15 +0200 From: Jiri Olsa To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Kajol Jain , Andi Kleen , John Garry , Jin Yao , Kan Liang , Cong Wang , Kim Phillips , Adrian Hunter , Leo Yan , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Stephane Eranian Subject: Re: [PATCH v2 7/7] perf expr: Migrate expr ids table to a hashmap Message-ID: <20200515194115.GA3577540@krava> References: <20200515165007.217120-1-irogers@google.com> <20200515165007.217120-8-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200515165007.217120-8-irogers@google.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 09:50:07AM -0700, Ian Rogers wrote: SNIP > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > index b071df373f8b..37be5a368d6e 100644 > --- a/tools/perf/util/metricgroup.c > +++ b/tools/perf/util/metricgroup.c > @@ -85,8 +85,7 @@ static void metricgroup__rblist_init(struct rblist *metric_events) > > struct egroup { > struct list_head nd; > - int idnum; > - const char **ids; > + struct expr_parse_ctx pctx; > const char *metric_name; > const char *metric_expr; > const char *metric_unit; > @@ -94,19 +93,21 @@ struct egroup { > }; > > static struct evsel *find_evsel_group(struct evlist *perf_evlist, > - const char **ids, > - int idnum, > + struct expr_parse_ctx *pctx, > struct evsel **metric_events, > bool *evlist_used) > { > struct evsel *ev; > - int i = 0, j = 0; > bool leader_found; > + const size_t idnum = hashmap__size(&pctx->ids); > + size_t i = 0; > + int j = 0; > + double *val_ptr; > > evlist__for_each_entry (perf_evlist, ev) { > if (evlist_used[j++]) > continue; > - if (!strcmp(ev->name, ids[i])) { > + if (hashmap__find(&pctx->ids, ev->name, (void **)&val_ptr)) { hum, you sure it's doing the same thing as before? hashmap__find will succede all the time in here, while the previous code was looking for the start of the group ... the logic in here is little convoluted, so maybe I'm missing some point in here ;-) jirka > if (!metric_events[i]) > metric_events[i] = ev; > i++; > @@ -118,7 +119,8 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, > memset(metric_events, 0, > sizeof(struct evsel *) * idnum); > > - if (!strcmp(ev->name, ids[i])) { > + if (hashmap__find(&pctx->ids, ev->name, > + (void **)&val_ptr)) { > if (!metric_events[i]) > metric_events[i] = ev; SNIP