mirror_zfs/module
Matthew Ahrens d4e04cc145 Missed wakeup when growing kmem cache
When growing the size of a (VMEM or KVMEM) kmem cache, spl_cache_grow()
always does taskq_dispatch(spl_cache_grow_work), and then waits for the
KMC_BIT_GROWING to be cleared by the taskq thread.

The taskq thread (spl_cache_grow_work()) does:
1. allocate new slab and add to list
2. wake_up_all(skc_waitq)
3. clear_bit(KMC_BIT_GROWING)

Therefore, the waiting thread can wake up before GROWING has been
cleared.  It will see that the growing has not yet completed, and go
back to sleep until it hits the 100ms timeout.

This can have an extreme performance impact on workloads that alloc/free
more than fits in the (statically-sized) magazines.  These workloads
allocate and free slabs with high frequency.

The problem can be observed with `funclatency spl_cache_grow`, which on
some workloads shows that 99.5% of the time it takes <64us to allocate
slabs, but we spend ~70% of our time in outliers, waiting for the 100ms
timeout.

The fix is to do `clear_bit(KMC_BIT_GROWING)` before
`wake_up_all(skc_waitq)`.

A future investigation should evaluate if we still actually need to
taskq_dispatch() at all, and if so on which kernel versions.

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Wilson <gwilson@delphix.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #9989
2020-05-12 10:53:32 -07:00
..
avl Fix typos in module/ 2020-01-22 13:48:59 -08:00
icp cppcheck: (error) Uninitialized variable 2020-01-22 13:49:06 -08:00
lua cppcheck: (error) Address of local auto-variable assigned 2020-01-22 13:49:06 -08:00
nvpair cppcheck: (warning) Possible null pointer dereference: nvh 2020-01-22 13:49:06 -08:00
spl Missed wakeup when growing kmem cache 2020-05-12 10:53:32 -07:00
unicode Update build system and packaging 2018-05-29 16:00:33 -07:00
zcommon Increase allowed 'special_small_blocks' maximum value 2020-01-22 13:49:05 -08:00
zfs Fix zfs-0.8.3 "qat.h" 2020-01-22 13:49:07 -08:00
.gitignore Adapt gitignore for modules 2020-01-22 13:49:05 -08:00
Makefile.in module/Makefile.in: don't run xargs if empty 2020-01-22 13:49:02 -08:00