]> git.baikalelectronics.ru Git - kernel.git/commit
lockref: Limit number of cmpxchg loop retries
authorJan Glauber <jglauber@cavium.com>
Wed, 5 Jun 2019 13:48:49 +0000 (15:48 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 7 Jun 2019 20:15:06 +0000 (13:15 -0700)
commit821de501cf5c1818302ee48d4277f552f69f2e88
treedc6946c02bd1d17178e8ac9b4925513834490e11
parent80993e9f1c3ffe896f2dd26eefffd99c538229a4
lockref: Limit number of cmpxchg loop retries

The lockref cmpxchg loop is unbound as long as the spinlock is not
taken. Depending on the hardware implementation of compare-and-swap
a high number of loop retries might happen.

Add an upper bound to the loop to force the fallback to spinlocks
after some time. A retry value of 100 should not impact any hardware
that does not have this issue.

With the retry limit the performance of an open-close testcase
improved between 60-70% on ThunderX2.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jan Glauber <jglauber@marvell.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/lockref.c