summaryrefslogtreecommitdiffstats
path: root/kernel/user.c
diff options
context:
space:
mode:
authorTakshak Chahande <ctakshak@fb.com>2019-07-31 15:10:55 -0700
committerAlexei Starovoitov <ast@kernel.org>2019-07-31 20:35:19 -0700
commit56fbc24116f458a0ea48f9f37fe770fd791042d9 (patch)
tree17d137a6c297c88c4ad99dddf76b382ab9db9b42 /kernel/user.c
parent5d01ab7bac467edfc530e6ccf953921def935c62 (diff)
downloadlinux-56fbc24116f458a0ea48f9f37fe770fd791042d9.tar.bz2
libbpf : make libbpf_num_possible_cpus function thread safe
Having static variable `cpus` in libbpf_num_possible_cpus function without guarding it with mutex makes this function thread-unsafe. If multiple threads accessing this function, in the current form; it leads to incrementing the static variable value `cpus` in the multiple of total available CPUs. Used local stack variable to calculate the number of possible CPUs and then updated the static variable using WRITE_ONCE(). Changes since v1: * added stack variable to calculate cpus * serialized static variable update using WRITE_ONCE() * fixed Fixes tag Fixes: 6446b3155521 ("bpf: add a new API libbpf_num_possible_cpus()") Signed-off-by: Takshak Chahande <ctakshak@fb.com> Acked-by: Andrey Ignatov <rdna@fb.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/user.c')
0 files changed, 0 insertions, 0 deletions