bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ian Rogers <irogers@google.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Pekka Enberg <penberg@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	Irina Tirdea <irina.tirdea@intel.com>, bpf <bpf@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: libbpf's hashmap use of __WORDSIZE
Date: Mon, 8 Jun 2020 10:32:16 -0700	[thread overview]
Message-ID: <CAEf4BzbEcV6YaezP4yY8J=kYSBhh0cRHCvgCUe9xvB12mF08qg@mail.gmail.com> (raw)
In-Reply-To: <20200608161150.GA3073@kernel.org>

On Mon, Jun 8, 2020 at 9:11 AM Arnaldo Carvalho de Melo
<arnaldo.melo@gmail.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@fb.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)

  reply	other threads:[~2020-06-08 17:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08 16:11 libbpf's hashmap use of __WORDSIZE Arnaldo Carvalho de Melo
2020-06-08 17:32 ` Andrii Nakryiko [this message]
2020-06-08 18:12   ` Arnaldo Carvalho de Melo
2020-06-09 15:34   ` [PATCH] libbpf: Define __WORDSIZE if not available Arnaldo Carvalho de Melo
2020-06-09 20:37     ` Daniel Borkmann
2020-06-09 21:16       ` Arnaldo Carvalho de Melo
2020-06-09 23:21         ` Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEf4BzbEcV6YaezP4yY8J=kYSBhh0cRHCvgCUe9xvB12mF08qg@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=arnaldo.melo@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=irina.tirdea@intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=penberg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).