On Sun, Nov 6, 2022 at 12:29 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > An update for libbpf's hashmap interface from void* -> void* to > long -> long. Removes / simplifies some type casts when hashmap > keys or values are 32-bit integers. > > In libbpf hashmap is more often used with integral keys / values > rather than with pointer keys / values. > > Perf copies hashmap implementation from libbpf and has to be > updated as well. > > Changes to libbpf, selftests/bpf and perf are packed as a single > commit to avoid compilation issues with any future bisect. > > The net number of casts is decreased after this refactoring. Although > perf mostly uses ptr to ptr maps, thus a lot of casts have to be > added there: > > Casts Casts > removed added > libbpf ~50 ~20 > libbpf tests ~55 ~0 > perf ~0 ~33 > perf tests ~0 ~13 > > This is a follow up for [1]. > > [1] https://lore.kernel.org/bpf/af1facf9-7bc8-8a3d-0db4-7b3f333589a2@xxxxxxxx/T/#m65b28f1d6d969fcd318b556db6a3ad499a42607d > > Signed-off-by: Eduard Zingerman <eddyz87@xxxxxxxxx> > --- > tools/bpf/bpftool/btf.c | 25 ++--- > tools/bpf/bpftool/common.c | 10 +- > tools/bpf/bpftool/gen.c | 19 ++-- > tools/bpf/bpftool/link.c | 8 +- > tools/bpf/bpftool/main.h | 14 +-- > tools/bpf/bpftool/map.c | 8 +- > tools/bpf/bpftool/pids.c | 16 +-- > tools/bpf/bpftool/prog.c | 8 +- > tools/lib/bpf/btf.c | 41 ++++--- > tools/lib/bpf/btf_dump.c | 16 +-- > tools/lib/bpf/hashmap.c | 16 +-- > tools/lib/bpf/hashmap.h | 34 +++--- > tools/lib/bpf/libbpf.c | 18 ++-- > tools/lib/bpf/strset.c | 18 ++-- > tools/lib/bpf/usdt.c | 31 +++--- > tools/perf/tests/expr.c | 40 +++---- > tools/perf/tests/pmu-events.c | 6 +- > tools/perf/util/bpf-loader.c | 23 ++-- > tools/perf/util/expr.c | 32 +++--- > tools/perf/util/hashmap.c | 16 +-- > tools/perf/util/hashmap.h | 34 +++--- > tools/perf/util/metricgroup.c | 12 +-- > tools/perf/util/stat.c | 9 +- > .../selftests/bpf/prog_tests/hashmap.c | 102 +++++++++--------- > .../bpf/prog_tests/kprobe_multi_test.c | 6 +- > 25 files changed, 257 insertions(+), 305 deletions(-) Looks like the churn is not worth it. I'd keep it as-is.