lists.openwall.net   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  linux-cve-announce  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]
Message-ID: <CAEf4BzbEcV6YaezP4yY8J=kYSBhh0cRHCvgCUe9xvB12mF08qg@mail.gmail.com>
Date:   Mon, 8 Jun 2020 10:32:16 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
Cc:     Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Ian Rogers <irogers@...gle.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Pekka Enberg <penberg@...nel.org>,
        Jiri Olsa <jolsa@...nel.org>,
        Irina Tirdea <irina.tirdea@...el.com>,
        bpf <bpf@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: libbpf's hashmap use of __WORDSIZE

On Mon, Jun 8, 2020 at 9:11 AM Arnaldo Carvalho de Melo
<arnaldo.melo@...il.com> wrote:
>
> Hi Andrii,
>
>         We've got that hashmap.[ch] copy from libbpf so that we can
> build perf in systems where libbpf isn't available, and to make it build
> in all the containers I regularly test build perf I had to add the patch
> below, I test build with many versions of both gcc and clang and
> multiple libcs.
>
>   https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
>
> The way that tools/include/linux/bitops.h has been doing since 2012 is
> explained in:
>
>   http://git.kernel.org/torvalds/c/3f34f6c0233ae055b5
>
> Please take a look and see if you find it acceptable,
>
> Thanks,
>
> - Arnaldo
>
>   Warning: Kernel ABI header at 'tools/perf/util/hashmap.h' differs from latest version at 'tools/lib/bpf/hashmap.h'
>   diff -u tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
>
> $ diff -u tools/lib/bpf/hashmap.h tools/perf/util/hashmap.h
> --- tools/lib/bpf/hashmap.h     2020-06-05 13:25:27.822079838 -0300
> +++ tools/perf/util/hashmap.h   2020-06-05 13:25:27.838079794 -0300
> @@ -10,10 +10,9 @@
>
>  #include <stdbool.h>
>  #include <stddef.h>
> -#ifdef __GLIBC__
> -#include <bits/wordsize.h>
> -#else
> -#include <bits/reg.h>
> +#include <limits.h>
> +#ifndef __WORDSIZE
> +#define __WORDSIZE (__SIZEOF_LONG__ * 8)
>  #endif

This looks fine, I also build-tested it in Travis CI, so all good.
There is actually __SIZEOF_SIZE_T__, which is more directly what
hash_bits work with, but I don't think it matters for any reasonable
system in use :)

So yeah,

Acked-by: Andrii Nakryiko <andriin@...com>

Are you going to do this change for libbpf's variant, or should I
submit a separate patch?

>
>  static inline size_t hash_bits(size_t h, int bits)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ