Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1356815ybj; Thu, 7 May 2020 22:38:55 -0700 (PDT) X-Google-Smtp-Source: APiQypLzadiJCT+dz6gZAEiMXCxE1+d50joBzSGXMvOOvtbbnodJvyx+q/74thtVkXUsfZsElarv X-Received: by 2002:aa7:c453:: with SMTP id n19mr757984edr.218.1588916334929; Thu, 07 May 2020 22:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588916334; cv=none; d=google.com; s=arc-20160816; b=K3ASuNilNolD5O7DWKckNm0lGDXR4XlTEhTaDDnUJ2Y6PK5uqW8MczhDpLeR26GhTP UXHQ9HQ/K9BZBOpEcxbRki8SOY4oMLdU4mZfjDYrsvHOIjBn7vDERg0V6D6zyEk7Bk0g nSu6I8nchOlxGcU+/7acm4Kusl0Y4BPfbeqWxZH/bPwG3JBG0V8c9x/kagu3ZbtAvJN7 aDcdVhnrIWr8Rm/KIpt6Rjj8ZNkDKr7X6ow4fbU8T8VECRfc7QFwR9mG3Vyc5gtG1N/f +pPM3s5nCoRSVQDgaPdtAzPMwmcqkCM8hdE67nRXnIleGBIsnWPZ0v2ESyo3DHGxYBZh jaWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=8mTjY5Q7uhlsrEjhBpa42c8dBQy8FzN3v/FyAmB9p0U=; b=zDeLP9eBUUhPizHcsWZcpczCEc98O7Xla8zdd/yZM84/CaYKd+UvOhrgSc2CXMIvRZ jhKXbQPOcU6oPyjpCPIm9Y1uqwMMYU7Bh1lGYYVev6Miu9U/Lk4GcNwsw3v3OJ9HG6lh JRxOiW0wrvl1EiTVK1b5/bT1OYtnv0ZFqDv99c+5CQHO2EsASD6o9YIR4PsVZZW7WiDM +67S1kuUV37tPgrQDLgrnLiYn/uF8JuPCILu4zrQYf4g5rXzXZ98OQsGP1866pZ/oppz VlK4TEGPb+WN249wXSqEU4lXNn0/LP6pJL826rdje92sO6KBvkEsPoSz5CWBgV/isidV aIUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=U0N9gD16; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si348437ejr.55.2020.05.07.22.38.28; Thu, 07 May 2020 22:38:54 -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=@google.com header.s=20161025 header.b=U0N9gD16; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727795AbgEHFgz (ORCPT + 99 others); Fri, 8 May 2020 01:36:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727114AbgEHFgt (ORCPT ); Fri, 8 May 2020 01:36:49 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3433BC05BD09 for ; Thu, 7 May 2020 22:36:49 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id h185so774723ybg.6 for ; Thu, 07 May 2020 22:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=8mTjY5Q7uhlsrEjhBpa42c8dBQy8FzN3v/FyAmB9p0U=; b=U0N9gD16UqP7ggUJ2BXHcDcYbFnXrHHk2W/wpDJdwshXylLUUsmQ2lXTCxBNvUnXYs 5uM+y6GVF3wt9WnW6XHGpMyjH1Av492UKkTjrOApESVWEjWjAyb2X2vD+wKPLCTgttlb AbRmttl3quYEeXgYE3qHriWaDoHIU4TGYnzp9g3kKImXUUinzNq61VFjgWP3/znke2TZ xjO5onI0M6QbZUjnL96Kamm1IqPhIs/dnpDhgpJGQqqB54qSekXLZDQGziHuIpa5qH4H MSImdPjv+p3Akv8mvKh8zjTR/NIeijnmkEt+6JvfuM38UuK7rl4TNnjlZXPiX3gl8zld L9Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8mTjY5Q7uhlsrEjhBpa42c8dBQy8FzN3v/FyAmB9p0U=; b=Yv3yQt5FK6sx9ZKj9+C3NU+WtJ6GnmrUExZbGoiedT9BGwGFtIVbnSiyaMDI6Vn8iS VLKXT2Qw0nz0d9nLGmgOwMzL+kmhve/L2fenDuNxqMSJ46TXimMAlWGnilMZzTZieK5O nZOPTSVOPH0dgMCccIRIGY74QdsaZCb8KLWLeZaMMwyKqougER0utQf0T/ujkl+jOOap Zjq8iGPEjsrE4OLCC5nvhuG3U+nAJ4AwaXCWWzNcrlcCSG0zuFqI4Lmd2OQwZ4oqFH6l wy64sQFUvWWccdm2CbwfNrUtmE2L0zJppb80zUEbSGa7/8mYHU2CE3aiLZjloa6sXzdI 8gFg== X-Gm-Message-State: AGi0Puah0gLXlHS+S93Q7eO1VfGEbeeBjgHgpkUNPitqiaaKlMTaa32D arCNRZnnQVLY6KXCboMtLtHgRRMWgJ8m X-Received: by 2002:a25:be81:: with SMTP id i1mr1962944ybk.184.1588916208391; Thu, 07 May 2020 22:36:48 -0700 (PDT) Date: Thu, 7 May 2020 22:36:23 -0700 In-Reply-To: <20200508053629.210324-1-irogers@google.com> Message-Id: <20200508053629.210324-9-irogers@google.com> Mime-Version: 1.0 References: <20200508053629.210324-1-irogers@google.com> X-Mailer: git-send-email 2.26.2.645.ge9eca65c58-goog Subject: [RFC PATCH v3 08/14] perf metricgroup: change evlist_used to a bitmap From: Ian Rogers To: 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 , Andi Kleen , John Garry , Jin Yao , Kan Liang , Cong Wang , Kim Phillips , linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, Vince Weaver , Stephane Eranian , Ian Rogers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use a bitmap rather than an array of bools. Signed-off-by: Ian Rogers --- tools/perf/util/metricgroup.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 37be5a368d6e..4f7e36bc49d9 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -95,7 +95,7 @@ struct egroup { static struct evsel *find_evsel_group(struct evlist *perf_evlist, struct expr_parse_ctx *pctx, struct evsel **metric_events, - bool *evlist_used) + unsigned long *evlist_used) { struct evsel *ev; bool leader_found; @@ -105,7 +105,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, double *val_ptr; evlist__for_each_entry (perf_evlist, ev) { - if (evlist_used[j++]) + if (test_bit(j++, evlist_used)) continue; if (hashmap__find(&pctx->ids, ev->name, (void **)&val_ptr)) { if (!metric_events[i]) @@ -150,7 +150,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, j++; } ev = metric_events[i]; - evlist_used[ev->idx] = true; + set_bit(ev->idx, evlist_used); } return metric_events[0]; @@ -166,13 +166,11 @@ static int metricgroup__setup_events(struct list_head *groups, int ret = 0; struct egroup *eg; struct evsel *evsel; - bool *evlist_used; + unsigned long *evlist_used; - evlist_used = calloc(perf_evlist->core.nr_entries, sizeof(bool)); - if (!evlist_used) { - ret = -ENOMEM; - return ret; - } + evlist_used = bitmap_alloc(perf_evlist->core.nr_entries); + if (!evlist_used) + return -ENOMEM; list_for_each_entry (eg, groups, nd) { struct evsel **metric_events; @@ -210,7 +208,7 @@ static int metricgroup__setup_events(struct list_head *groups, list_add(&expr->nd, &me->head); } - free(evlist_used); + bitmap_free(evlist_used); return ret; } -- 2.26.2.645.ge9eca65c58-goog