Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp645969ybk; Fri, 15 May 2020 09:51:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd9odZc5lm2MZ7NKPa7I0+HbplJMyeMMlN0kRqMEcDJigVTmpJbqGk6oeQb1abRTdi8m9n X-Received: by 2002:a05:6402:154b:: with SMTP id p11mr3783986edx.355.1589561516657; Fri, 15 May 2020 09:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589561516; cv=none; d=google.com; s=arc-20160816; b=lh960sMBh4H8T078l5k89onU9yfoKU7MkRAPbBJU4UBd6fid95Mi+dG8C++mHaw3GJ lJTW6sY21PO55oUXiicL1JyGO6+ParbrlTDg5wmqxPP2Q3ktCz1jTHbEBpuwCjCzahtv BTYdxUK30L5Qti51GTstRGutiELurB3pMYZJOhAwX1z8gosLcyPoM9BM2vtl7n9R3e6G DeidkFs8qCWOJIlNsPTzG90WQmrPGTbMzYJKmHRBnyf0Rafy8A1UHi4UHsWATBdR3f2P q/dD4Ccp8G9K/UIWaxADSQPBARBR10rlksZrTgRcNDN5N/NqobnFXbGHsxVaU5If18El lehA== 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:mime-version :message-id:date:dkim-signature; bh=9wE9+uYnPyHYBqhR+xTCODqhwbytCS+WPKk2ROqoQ0g=; b=maUzOLFVnZgOPUA1pgQ2L31BRrnjqgYrgSMdpOg+6ftfbYwibxYJrjomTeuIfYm+QO sRiK3dGcOGe5Mb7eR9cz+voxrq0DnGVnw5M1CGZH8mU4e+4q8IhxR6JbcXyd7FDcXYw/ eoub2n4iIBy5XzTWeqDCUxREPsuy/fjUx0kqZaVixAvVHV8DzI1i1Ui61bWjHDHUOfyb QIKypgPhD5ak2BwWWFn0jlAoes8V/LfRxtd0dFdg2IzrTBiGGp0SlaBaUlLJZLNnCNKC zaYdy7KshhA0CzY0DqgMk6uV0c7Srdzj+7eCYxD+yaUSnEl5Nigl/863T5GAdz3xFb1u Hy6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tLqu7zzM; 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 me17si1592935ejb.410.2020.05.15.09.51.33; Fri, 15 May 2020 09:51:56 -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=tLqu7zzM; 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 S1726278AbgEOQuO (ORCPT + 99 others); Fri, 15 May 2020 12:50:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726023AbgEOQuN (ORCPT ); Fri, 15 May 2020 12:50:13 -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 32CFBC061A0C for ; Fri, 15 May 2020 09:50:13 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 186so3297661ybq.1 for ; Fri, 15 May 2020 09:50:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=9wE9+uYnPyHYBqhR+xTCODqhwbytCS+WPKk2ROqoQ0g=; b=tLqu7zzMrYW+ZkntEU0ajxzoLSG5IfNMsKggx4+Y9NmSkUGT76DEavorSytFpWmXzX i+6FjxP6+Tdo4Y/QszAaJXaCXpL9D8XqCk3hqsI0FUyYc+MtMRd8g9QY/RH1AzdsuaLB Hf801mUExVuv/efSSwn3UJa6V75a5v5loJmIyWiL4bP36Xp12MHMGw0LM8PGMzbaQrW0 oHbPzIz56OeRs1BQNfpIXVClkYutWh4P04JDXbkJ9QWjVT7yiV7aB5N2YbCqhDz67y+R o6X/skCdWp4wakVVam610PYnwsf4VTj3a7m+VwfXZv0kaMg8q7NbAbAese788sCPoCfd pnwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=9wE9+uYnPyHYBqhR+xTCODqhwbytCS+WPKk2ROqoQ0g=; b=BVjZh/Bbn+lDeyTaDl1Da/lSD/FtIMJSk3BIOOSe10A2DMj2GVTFtiCMEBaN9Sn2v2 kuo7GTPe5g8vbpPYr/aQxynz21JDLTI2YLDyOLX266VaaWIJrLHN0W1WgB2nuqtEPKTp w+wfDEoQoYVAUgLEbwTG+m/v96BuOagXm5YyOt9azfB1YVkRV1D2ixuCgTOwUjW/tARn ZNFgADS8rTyetSGFyR5APTtQLn8tCqaaDsArpZOP6RTrU/YqMLmpwm7W2hu4L8HLNx4N PhGnU2ADpJnZWGwnE1iK56FPaK6ya7sNnj6+MApub724L6CBOkdGbb9w2MaYOABXaykV BFYg== X-Gm-Message-State: AOAM530Vh4MuT3OIBt/sxZjFulSgd8DbSUFl35fe0ofEp1btagKbhZLw CvyN31t8tyxNhgCFY1s/Szp3xPzhV5la X-Received: by 2002:a25:71c6:: with SMTP id m189mr3881034ybc.187.1589561412313; Fri, 15 May 2020 09:50:12 -0700 (PDT) Date: Fri, 15 May 2020 09:50:00 -0700 Message-Id: <20200515165007.217120-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-goog Subject: [PATCH v2 0/7] Copy hashmap to tools/perf/util, use in perf expr 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 , Adrian Hunter , Leo Yan , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: 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 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. 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