]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - mm/percpu.c
mm, percpu: add support for __GFP_NOWARN flag
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 17 Oct 2017 14:55:52 +0000 (16:55 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Oct 2017 12:13:49 +0000 (13:13 +0100)
commit0ea7eeec24be5f04ae80d68f5b1ea3a11f49de2f
treeb9163bc8153d22ab2f1cf4bea65c2f7890500fa0
parent3fd3b03b4359852914b0a504cc87d1c1170c5d7c
mm, percpu: add support for __GFP_NOWARN flag

Add an option for pcpu_alloc() to support __GFP_NOWARN flag.
Currently, we always throw a warning when size or alignment
is unsupported (and also dump stack on failed allocation
requests). The warning itself is harmless since we return
NULL anyway for any failed request, which callers are
required to handle anyway. However, it becomes harmful when
panic_on_warn is set.

The rationale for the WARN() in pcpu_alloc() is that it can
be tracked when larger than supported allocation requests are
made such that allocations limits can be tweaked if warranted.
This makes sense for in-kernel users, however, there are users
of pcpu allocator where allocation size is derived from user
space requests, e.g. when creating BPF maps. In these cases,
the requests should fail gracefully without throwing a splat.

The current work-around was to check allocation size against
the upper limit of PCPU_MIN_UNIT_SIZE from call-sites for
bailing out prior to a call to pcpu_alloc() in order to
avoid throwing the WARN(). This is bad in multiple ways since
PCPU_MIN_UNIT_SIZE is an implementation detail, and having
the checks on call-sites only complicates the code for no
good reason. Thus, lets fix it generically by supporting the
__GFP_NOWARN flag that users can then use with calling the
__alloc_percpu_gfp() helper instead.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Tejun Heo <tj@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
mm/percpu.c