]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
slab: determine barn status racily outside of lock
authorVlastimil Babka <vbabka@suse.cz>
Wed, 3 Sep 2025 12:59:48 +0000 (14:59 +0200)
committerVlastimil Babka <vbabka@suse.cz>
Mon, 29 Sep 2025 07:21:16 +0000 (09:21 +0200)
commit08294229210916c3b179186f3efa3b9c62a04678
tree47e52f79eb462e6f45c66e80339a5a756ded3faf
parent3c1ea5c5019ff197aca7e886a3a240c38f6c6f0d
slab: determine barn status racily outside of lock

The possibility of many barn operations is determined by the current
number of full or empty sheaves. Taking the barn->lock just to find out
that e.g. there are no empty sheaves results in unnecessary overhead and
lock contention. Thus perform these checks outside of the lock with a
data_race() annotated variable read and fail quickly without taking the
lock.

Checks for sheaf availability that racily succeed have to be obviously
repeated under the lock for correctness, but we can skip repeating
checks if there are too many sheaves on the given list as the limits
don't need to be strict.

Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
mm/slub.c