Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp759614ybk; Fri, 15 May 2020 12:46:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3EhtdAQ1/UyLuE4AJhEu9hfaZ5sA+u83TZ+aGEw99YRICq0YN7+QjfDY6/D9R9YqNt13+ X-Received: by 2002:a17:906:cd08:: with SMTP id oz8mr4370657ejb.90.1589571999315; Fri, 15 May 2020 12:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589571999; cv=none; d=google.com; s=arc-20160816; b=ZRSfivy2MGuQ2SP7KSgOYk8OJPMldIH5851wVOpFUw9iDP0vs6IJgoh/Kh83A/me6L GCVyaKRzxfOoM3s7WMFRhrIj3vn0sEex10DaClgVeNdxzgf5P8truW9L8xGpbCDKR6GF GygFSlSPPX1y18o3/zjrGpTYuWoZwDP4OYf+bseKj8f4zpD1yfMsqoh7AZpdaz6+LvSW TuaPjcYgfTPYn/TA0fvoTpb11sBC0ZaH94LD2w0huR3XLHz8RHy4uc0RzbwPRH0avWL6 wxFA2LfkV7StLuCO+TMCP7ZNdpPasGFulKEyAML8zIxx9kp1X29m8OXgVNIriTqrVwed COeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3FeZo7wxUKF5f4TtRFTT/9ikqtb4RICo/S0MwMu9vSo=; b=VAvCFn46aBixDKSlbzzymgtO1fcz3RFr22Z88d3q45c8LeqdLeSlaQT5EOSmq5sepS OrPzCc3JEJrNjCA1VouV+EpDPjsAg5SClEyKAoNh5QP+slTEnvzVuuIGUhFgEVkhNXGk +liAoG2u5Nvm9F1sWu8BkIe7T7/CzGkFe9ELrbR1uDvkLHz6CsW2MIrwILA8kHw6qcWZ B1CLT7YRMi4y7NFxIvMRZAolDruAA5F4ehB/VQ3jPhN/FShMPfidcUhxQghw/dI1ErKw qNYgrGfh7OfK/SnYZJBkGNRfl8PnqLECrtGqO597emm+7Ru+qnDz3tB+Zi+nLz5oRbdJ phSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ntWeU88/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si2015384edc.413.2020.05.15.12.46.15; Fri, 15 May 2020 12:46:39 -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=@gmail.com header.s=20161025 header.b="ntWeU88/"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726367AbgEOTm6 (ORCPT + 99 others); Fri, 15 May 2020 15:42:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726168AbgEOTm6 (ORCPT ); Fri, 15 May 2020 15:42:58 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31A9CC061A0C; Fri, 15 May 2020 12:42:58 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id i68so3015845qtb.5; Fri, 15 May 2020 12:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3FeZo7wxUKF5f4TtRFTT/9ikqtb4RICo/S0MwMu9vSo=; b=ntWeU88/ZODmBoBJzxsMHcHPQwhBwu/fsT+NjYCYj3tSizmOSPq+zKlQSL8S518Zvn FFSY2R2OrJuWcD5ry1+6WepFZBKDQ/1UMJ76idiDBu8Y2PYwv0Y6f7Fl/eotDeoow9iV nNEtFFTV0qoqsWYGRCL2wNLWlUrTAodVTnbBEsx83QY6BOSb8ittkAC27dJIOSx1T6gd /6ZEGsPYBBy/B4fBvUHffHEoP4sJfd6GwVQ0n8YPMaejW9t91Qz6uWyHwEXttgQ+AwGd faVnP8CNbSxSxsJWQBICNwMeaN7KNLZIFFSBTplH0z+fpDq9GFcmff4KD+PJLFVitnUf yCVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3FeZo7wxUKF5f4TtRFTT/9ikqtb4RICo/S0MwMu9vSo=; b=JLdPHbNk2sUPN/sWgLZUWtFXfWsQuG16k2KLkch9TfqfUYmMMpgNVLPIHE63T+VAyj sG3AKkGk6lAfP7cfptgnhrKzwNNrPmiBzc0aLKz0jUriRN/S+8PywNzdz3KXyKOZPNNW RjWtVPpIrLzyQOCer+4npz26EMbv/wk5kUUUrhpL1LQl2gMHuo3la5/fNghmhx2vxE9P DRtdbo4ccQBxPYMP9qQmNH06ElPRAN9t7DS/RCpBsG6h56CGKsmdhQs8zmUGhQThFjxo Z9mVhHYojnZd9gmo3D/vFnACVZOrg8xH4L7smqJwxHpmbADHt2PZPGYTQJt1gKK8fIRb tAPg== X-Gm-Message-State: AOAM5319D9K0i2BXv507s4zgmudqIRnH49oocWxNpVYy3yrvRsLXsXCZ owlrKy/spYXd/YaQK3kOlwgeZ2Sm/oG5EmTEN0Q= X-Received: by 2002:ac8:424b:: with SMTP id r11mr5248216qtm.171.1589571777348; Fri, 15 May 2020 12:42:57 -0700 (PDT) MIME-Version: 1.0 References: <20200515165007.217120-1-irogers@google.com> <20200515170036.GA10230@kernel.org> In-Reply-To: <20200515170036.GA10230@kernel.org> From: Andrii Nakryiko Date: Fri, 15 May 2020 12:42:46 -0700 Message-ID: Subject: Re: [PATCH v2 0/7] Copy hashmap to tools/perf/util, use in perf expr To: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov , Daniel Borkmann , Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , 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 , open list , Networking , bpf , Stephane Eranian 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 On Fri, May 15, 2020 at 10:01 AM Arnaldo Carvalho de Melo wrote: > > Em Fri, May 15, 2020 at 09:50:00AM -0700, Ian Rogers escreveu: > > Perf's expr code currently builds an array of strings then removes > > duplicates. The array is larger than necessary and has recently been > > increased in size. When this was done it was commented that a hashmap > > would be preferable. > > > > libbpf has a hashmap but libbpf isn't currently required to build > > perf. To satisfy various concerns this change copies libbpf's hashmap > > into tools/perf/util, it then adds a check in perf that the two are in > > sync. > > > > Andrii's patch to hashmap from bpf-next is brought into this set to > > fix issues with hashmap__clear. > > > > Two minor changes to libbpf's hashmap are made that remove an unused > > dependency and fix a compiler warning. > > Andrii/Alexei/Daniel, what do you think about me merging these fixes in my > perf-tools-next branch? I'm ok with the idea, but it's up to maintainers to coordinate this :) > > - Arnaldo > > > Two perf test changes are also brought in as they need refactoring to > > account for the expr API change and it is expected they will land > > ahead of this. > > https://lore.kernel.org/lkml/20200513062236.854-2-irogers@google.com/ > > > > Tested with 'perf test' and 'make -C tools/perf build-test'. > > > > The hashmap change was originally part of an RFC: > > https://lore.kernel.org/lkml/20200508053629.210324-1-irogers@google.com/ > > > > v2. moves hashmap into tools/perf/util rather than libapi, to allow > > hashmap's libbpf symbols to be visible when built statically for > > testing. > > > > Andrii Nakryiko (1): > > libbpf: Fix memory leak and possible double-free in hashmap__clear > > > > Ian Rogers (6): > > libbpf hashmap: Remove unused #include > > libbpf hashmap: Fix signedness warnings > > tools lib/api: Copy libbpf hashmap to tools/perf/util > > perf test: Provide a subtest callback to ask for the reason for > > skipping a subtest > > perf test: Improve pmu event metric testing > > perf expr: Migrate expr ids table to a hashmap > > > > tools/lib/bpf/hashmap.c | 10 +- > > tools/lib/bpf/hashmap.h | 1 - > > tools/perf/check-headers.sh | 4 + > > tools/perf/tests/builtin-test.c | 18 ++- > > tools/perf/tests/expr.c | 40 +++--- > > tools/perf/tests/pmu-events.c | 169 ++++++++++++++++++++++- > > tools/perf/tests/tests.h | 4 + > > tools/perf/util/Build | 4 + > > tools/perf/util/expr.c | 129 +++++++++-------- > > tools/perf/util/expr.h | 26 ++-- > > tools/perf/util/expr.y | 22 +-- > > tools/perf/util/hashmap.c | 238 ++++++++++++++++++++++++++++++++ > > tools/perf/util/hashmap.h | 177 ++++++++++++++++++++++++ > > tools/perf/util/metricgroup.c | 87 ++++++------ > > tools/perf/util/stat-shadow.c | 49 ++++--- > > 15 files changed, 798 insertions(+), 180 deletions(-) > > create mode 100644 tools/perf/util/hashmap.c > > create mode 100644 tools/perf/util/hashmap.h > > > > -- > > 2.26.2.761.g0e0b3e54be-goog > > > > -- > > - Arnaldo