* [PATCH bpf] bpf: allocate local storage buffers using GFP_ATOMIC
@ 2018-11-14 18:00 Roman Gushchin
2018-11-16 23:30 ` Y Song
2018-11-17 5:20 ` Alexei Starovoitov
0 siblings, 2 replies; 3+ messages in thread
From: Roman Gushchin @ 2018-11-14 18:00 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel-team, Roman Gushchin, Alexei Starovoitov,
Daniel Borkmann
Naresh reported an issue with the non-atomic memory allocation of
cgroup local storage buffers:
[ 73.047526] BUG: sleeping function called from invalid context at
/srv/oe/build/tmp-rpb-glibc/work-shared/intel-corei7-64/kernel-source/mm/slab.h:421
[ 73.060915] in_atomic(): 1, irqs_disabled(): 0, pid: 3157, name: test_cgroup_sto
[ 73.068342] INFO: lockdep is turned off.
[ 73.072293] CPU: 2 PID: 3157 Comm: test_cgroup_sto Not tainted
4.20.0-rc2-next-20181113 #1
[ 73.080548] Hardware name: Supermicro SYS-5019S-ML/X11SSH-F, BIOS
2.0b 07/27/2017
[ 73.088018] Call Trace:
[ 73.090463] dump_stack+0x70/0xa5
[ 73.093783] ___might_sleep+0x152/0x240
[ 73.097619] __might_sleep+0x4a/0x80
[ 73.101191] __kmalloc_node+0x1cf/0x2f0
[ 73.105031] ? cgroup_storage_update_elem+0x46/0x90
[ 73.109909] cgroup_storage_update_elem+0x46/0x90
cgroup_storage_update_elem() (as well as other update map update
callbacks) is called with disabled preemption, so GFP_ATOMIC
allocation should be used: e.g. alloc_htab_elem() in hashtab.c.
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Roman Gushchin <guro@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
---
kernel/bpf/local_storage.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c
index c97a8f968638..bed9d48a7ae9 100644
--- a/kernel/bpf/local_storage.c
+++ b/kernel/bpf/local_storage.c
@@ -139,7 +139,8 @@ static int cgroup_storage_update_elem(struct bpf_map *map, void *_key,
return -ENOENT;
new = kmalloc_node(sizeof(struct bpf_storage_buffer) +
- map->value_size, __GFP_ZERO | GFP_USER,
+ map->value_size,
+ __GFP_ZERO | GFP_ATOMIC | __GFP_NOWARN,
map->numa_node);
if (!new)
return -ENOMEM;
--
2.17.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: allocate local storage buffers using GFP_ATOMIC
2018-11-14 18:00 [PATCH bpf] bpf: allocate local storage buffers using GFP_ATOMIC Roman Gushchin
@ 2018-11-16 23:30 ` Y Song
2018-11-17 5:20 ` Alexei Starovoitov
1 sibling, 0 replies; 3+ messages in thread
From: Y Song @ 2018-11-16 23:30 UTC (permalink / raw)
To: guroan
Cc: netdev, LKML, kernel-team, guro, Alexei Starovoitov, Daniel Borkmann
On Wed, Nov 14, 2018 at 6:01 PM Roman Gushchin <guroan@gmail.com> wrote:
>
> Naresh reported an issue with the non-atomic memory allocation of
> cgroup local storage buffers:
>
> [ 73.047526] BUG: sleeping function called from invalid context at
> /srv/oe/build/tmp-rpb-glibc/work-shared/intel-corei7-64/kernel-source/mm/slab.h:421
> [ 73.060915] in_atomic(): 1, irqs_disabled(): 0, pid: 3157, name: test_cgroup_sto
> [ 73.068342] INFO: lockdep is turned off.
> [ 73.072293] CPU: 2 PID: 3157 Comm: test_cgroup_sto Not tainted
> 4.20.0-rc2-next-20181113 #1
> [ 73.080548] Hardware name: Supermicro SYS-5019S-ML/X11SSH-F, BIOS
> 2.0b 07/27/2017
> [ 73.088018] Call Trace:
> [ 73.090463] dump_stack+0x70/0xa5
> [ 73.093783] ___might_sleep+0x152/0x240
> [ 73.097619] __might_sleep+0x4a/0x80
> [ 73.101191] __kmalloc_node+0x1cf/0x2f0
> [ 73.105031] ? cgroup_storage_update_elem+0x46/0x90
> [ 73.109909] cgroup_storage_update_elem+0x46/0x90
>
> cgroup_storage_update_elem() (as well as other update map update
> callbacks) is called with disabled preemption, so GFP_ATOMIC
> allocation should be used: e.g. alloc_htab_elem() in hashtab.c.
>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
> ---
> kernel/bpf/local_storage.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: allocate local storage buffers using GFP_ATOMIC
2018-11-14 18:00 [PATCH bpf] bpf: allocate local storage buffers using GFP_ATOMIC Roman Gushchin
2018-11-16 23:30 ` Y Song
@ 2018-11-17 5:20 ` Alexei Starovoitov
1 sibling, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2018-11-17 5:20 UTC (permalink / raw)
To: Roman Gushchin; +Cc: netdev, linux-kernel, kernel-team, Roman Gushchin, daniel
On Wed, Nov 14, 2018 at 10:00:34AM -0800, Roman Gushchin wrote:
> Naresh reported an issue with the non-atomic memory allocation of
> cgroup local storage buffers:
>
> [ 73.047526] BUG: sleeping function called from invalid context at
> /srv/oe/build/tmp-rpb-glibc/work-shared/intel-corei7-64/kernel-source/mm/slab.h:421
> [ 73.060915] in_atomic(): 1, irqs_disabled(): 0, pid: 3157, name: test_cgroup_sto
> [ 73.068342] INFO: lockdep is turned off.
> [ 73.072293] CPU: 2 PID: 3157 Comm: test_cgroup_sto Not tainted
> 4.20.0-rc2-next-20181113 #1
> [ 73.080548] Hardware name: Supermicro SYS-5019S-ML/X11SSH-F, BIOS
> 2.0b 07/27/2017
> [ 73.088018] Call Trace:
> [ 73.090463] dump_stack+0x70/0xa5
> [ 73.093783] ___might_sleep+0x152/0x240
> [ 73.097619] __might_sleep+0x4a/0x80
> [ 73.101191] __kmalloc_node+0x1cf/0x2f0
> [ 73.105031] ? cgroup_storage_update_elem+0x46/0x90
> [ 73.109909] cgroup_storage_update_elem+0x46/0x90
>
> cgroup_storage_update_elem() (as well as other update map update
> callbacks) is called with disabled preemption, so GFP_ATOMIC
> allocation should be used: e.g. alloc_htab_elem() in hashtab.c.
>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
applied to bpf tree, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-17 5:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-14 18:00 [PATCH bpf] bpf: allocate local storage buffers using GFP_ATOMIC Roman Gushchin
2018-11-16 23:30 ` Y Song
2018-11-17 5:20 ` Alexei Starovoitov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.