Linux: Never sleep in kmem_cache_alloc(..., KM_NOSLEEP) (#14926)
commit93f8abeff08e9c4363ec4d53d501cf21830c95e1
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 7 Jun 2023 17:43:43 +0000 (7 10:43 -0700)
committerGitHub <noreply@github.com>
Wed, 7 Jun 2023 17:43:43 +0000 (7 10:43 -0700)
tree638be48d4991e995d9bcbd6716be1fa544496b99
parentbcd5321039c3de29c14eac1068d392c15ad7fe2c
Linux: Never sleep in kmem_cache_alloc(..., KM_NOSLEEP) (#14926)

When a kmem cache is exhausted and needs to be expanded a new
slab is allocated.  KM_SLEEP callers can block and wait for the
allocation, but KM_NOSLEEP callers were incorrectly allowed to
block as well.

Resolve this by attempting an emergency allocation as a best
effort.  This may fail but that's fine since any KM_NOSLEEP
consumer is required to handle an allocation failure.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Adam Moss <c@yotes.com>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
module/os/linux/spl/spl-kmem-cache.c