lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 18 May 2020 12:45:05 -0300
From:   Arnaldo Carvalho de Melo <>
To:     Ian Rogers <>
Cc:     Peter Zijlstra <>,
        Ingo Molnar <>,
        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 <>,,,,
        Stephane Eranian <>
Subject: Re: [PATCH v3 7/7] perf expr: Migrate expr ids table to a hashmap

Em Fri, May 15, 2020 at 03:17:32PM -0700, Ian Rogers escreveu:
> Use a hashmap between a char* string and a double* value. While bpf's
> hashmap entries are size_t in size, we can't guarantee sizeof(size_t) >=
> sizeof(double). Avoid a memory allocation when gathering ids by making 0.0
> a special value encoded as NULL.
> Original map suggestion by Andi Kleen:
> and seconded by Jiri Olsa:

I'm having trouble here when building it with:

make -C tools/perf O=/tmp/build/perf

    CC       /tmp/build/perf/tests/expr.o
    INSTALL  trace_plugins
    CC       /tmp/build/perf/util/metricgroup.o
  In file included from /home/acme/git/perf/tools/lib/bpf/hashmap.h:18,
                   from /home/acme/git/perf/tools/perf/util/expr.h:6,
                   from tests/expr.c:3:
  /home/acme/git/perf/tools/lib/bpf/libbpf_internal.h:63: error: "pr_info" redefined [-Werror]
     63 | #define pr_info(fmt, ...) __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__)
  In file included from tests/expr.c:2:
  /home/acme/git/perf/tools/perf/util/debug.h:24: note: this is the location of the previous definition
It looks like libbpf's hashmap.h is being used instead of the one in
tools/perf/util/, yeah, as intended, but then since I don't have the
fixes you added to the BPF tree, the build fails, if I instead
unconditionally use

#include "util/hashmap.h"

It works. Please ack.

I.e. with the patch below, further tests:

[acme@...e perf]$ perf -vv | grep -i bpf
                   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT
[acme@...e perf]$ nm ~/bin/perf | grep -i libbpf_ | wc -l
[acme@...e perf]$ nm ~/bin/perf | grep -i hashmap_ | wc -l
[acme@...e perf]$

Explicitely building without LIBBPF:

[acme@...e perf]$ perf -vv | grep -i bpf
                   bpf: [ OFF ]  # HAVE_LIBBPF_SUPPORT
[acme@...e perf]$
[acme@...e perf]$ nm ~/bin/perf | grep -i libbpf_ | wc -l
[acme@...e perf]$ nm ~/bin/perf | grep -i hashmap_ | wc -l
[acme@...e perf]$


- Arnaldo

diff --git a/tools/perf/util/expr.h b/tools/perf/util/expr.h
index d60a8feaf50b..8a2c1074f90f 100644
--- a/tools/perf/util/expr.h
+++ b/tools/perf/util/expr.h
@@ -2,11 +2,14 @@
 #ifndef PARSE_CTX_H
 #define PARSE_CTX_H 1
-#include <bpf/hashmap.h>
-#include "hashmap.h"
+// There are fixes that need to land upstream before we can use libbpf's headers,
+// for now use our copy unconditionally, since the data structures at this point
+// are exactly the same, no problem.
+//#include <bpf/hashmap.h>
+#include "util/hashmap.h"
 struct expr_parse_ctx {
 	struct hashmap ids;

Powered by blists - more mailing lists