diff options
author | Martin KaFai Lau <kafai@fb.com> | 2020-02-07 00:18:10 -0800 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2020-02-07 23:01:41 +0100 |
commit | 88d6f130e5632bbf419a2e184ec7adcbe241260b (patch) | |
tree | f5eef5513c35757cf56d82496e670a3e4033ac55 /drivers | |
parent | 5d3919a953c3c96c02fc7a337f8376cde43ae31f (diff) | |
download | linux-88d6f130e5632bbf419a2e184ec7adcbe241260b.tar.bz2 |
bpf: Improve bucket_log calculation logic
It was reported that the max_t, ilog2, and roundup_pow_of_two macros have
exponential effects on the number of states in the sparse checker.
This patch breaks them up by calculating the "nbuckets" first so that the
"bucket_log" only needs to take ilog2().
In addition, Linus mentioned:
Patch looks good, but I'd like to point out that it's not just sparse.
You can see it with a simple
make net/core/bpf_sk_storage.i
grep 'smap->bucket_log = ' net/core/bpf_sk_storage.i | wc
and see the end result:
1 365071 2686974
That's one line (the assignment line) that is 2,686,974 characters in
length.
Now, sparse does happen to react particularly badly to that (I didn't
look to why, but I suspect it's just that evaluating all the types
that don't actually ever end up getting used ends up being much more
expensive than it should be), but I bet it's not good for gcc either.
Fixes: 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Link: https://lore.kernel.org/bpf/20200207081810.3918919-1-kafai@fb.com
Diffstat (limited to 'drivers')
0 files changed, 0 insertions, 0 deletions