From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Martin KaFai Lau <kafai@fb.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
David Miller <davem@davemloft.net>,
kernel-team@fb.com,
Linus Torvalds <torvalds@linux-foundation.org>,
Linux-Sparse <linux-sparse@vger.kernel.org>,
netdev@vger.kernel.org, Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH bpf] bpf: Improve bucket_log calculation logic
Date: Fri, 7 Feb 2020 14:07:21 +0100 [thread overview]
Message-ID: <20200207130721.pitlvbxcx656c7ur@ltop.local> (raw)
In-Reply-To: <20200207081810.3918919-1-kafai@fb.com>
On Fri, Feb 07, 2020 at 12:18:10AM -0800, Martin KaFai Lau wrote:
>
> diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
> index 458be6b3eda9..3ab23f698221 100644
> --- a/net/core/bpf_sk_storage.c
> +++ b/net/core/bpf_sk_storage.c
> @@ -643,9 +643,10 @@ static struct bpf_map *bpf_sk_storage_map_alloc(union bpf_attr *attr)
> return ERR_PTR(-ENOMEM);
> bpf_map_init_from_attr(&smap->map, attr);
>
> + nbuckets = roundup_pow_of_two(num_possible_cpus());
> /* Use at least 2 buckets, select_bucket() is undefined behavior with 1 bucket */
> - smap->bucket_log = max_t(u32, 1, ilog2(roundup_pow_of_two(num_possible_cpus())));
> - nbuckets = 1U << smap->bucket_log;
> + nbuckets = max_t(u32, 2, nbuckets);
> + smap->bucket_log = ilog2(nbuckets);
> cost = sizeof(*smap->buckets) * nbuckets + sizeof(*smap);
>
> ret = bpf_map_charge_init(&smap->map.memory, cost);
> --
Yes, that's much nicer to read. Feel free to add my
Reviewed-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-- Luc
next prev parent reply other threads:[~2020-02-07 13:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-07 8:18 [PATCH bpf] bpf: Improve bucket_log calculation logic Martin KaFai Lau
2020-02-07 13:07 ` Luc Van Oostenryck [this message]
2020-02-07 18:07 ` Linus Torvalds
2020-02-07 19:39 ` Linus Torvalds
2020-02-07 20:41 ` Luc Van Oostenryck
2020-02-07 21:22 ` Linus Torvalds
2020-02-07 20:13 ` Alexei Starovoitov
2020-02-07 21:09 ` Linus Torvalds
2020-02-07 22:04 ` 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=20200207130721.pitlvbxcx656c7ur@ltop.local \
--to=luc.vanoostenryck@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=kafai@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-sparse@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=torvalds@linux-foundation.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).