Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1655628
| From | Waiman Long <longman@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v5 9/9] locking/rwsem: Enable reader lock stealing |
| Date | 2017-06-01 19:50 +0200 |
| Message-ID | <tNCop-5EC-17@gated-at.bofh.it> (permalink) |
| References | <tNCop-5EC-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
The rwsem has supported writer lock stealing for a long time. Reader lock stealing isn't allowed as it may lead to writer lock starvation. As a result, writers are preferred over readers. However, preferring readers generally leads to better overall performance. This patch now enables reader lock stealing on a rwsem as long as the lock is reader-owned and optimistic spinning hasn't been disabled because of long writer wait. This will improve overall performance without running the risk of writer lock starvation. Signed-off-by: Waiman Long <longman@redhat.com> --- kernel/locking/rwsem-xadd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c index a571bec..f5caba8 100644 --- a/kernel/locking/rwsem-xadd.c +++ b/kernel/locking/rwsem-xadd.c @@ -529,6 +529,14 @@ struct rw_semaphore __sched *rwsem_down_read_failed(struct rw_semaphore *sem) goto enqueue; /* + * Steal the lock if no writer was present and the optimistic + * spinning disable bit isn't set. + */ + count = atomic_long_read(&sem->count); + if (!count_has_writer(count)) + return sem; + + /* * Undo read bias from down_read operation to stop active locking if: * 1) Optimistic spinners are present; * 2) the wait_lock isn't free; or -- 1.8.3.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v5 0/9] locking/rwsem: Enable reader optimistic spinning Waiman Long <longman@redhat.com> - 2017-06-01 19:50 +0200 [PATCH v5 4/9] locking/rwsem: Change RWSEM_WAITING_BIAS for better disambiguation Waiman Long <longman@redhat.com> - 2017-06-01 19:50 +0200 [PATCH v5 6/9] locking/rwsem: Use bit in owner to stop spinning Waiman Long <longman@redhat.com> - 2017-06-01 19:50 +0200 [PATCH v5 9/9] locking/rwsem: Enable reader lock stealing Waiman Long <longman@redhat.com> - 2017-06-01 19:50 +0200 [PATCH v5 3/9] locking/rwsem: Move common rwsem macros to asm-generic/rwsem_types.h Waiman Long <longman@redhat.com> - 2017-06-01 19:50 +0200 [PATCH v5 8/9] locking/rwsem: Enable count-based spinning on reader Waiman Long <longman@redhat.com> - 2017-06-01 19:50 +0200 [PATCH v5 2/9] locking/rwsem: Stop active read lock ASAP Waiman Long <longman@redhat.com> - 2017-06-01 19:50 +0200 [PATCH v5 1/9] locking/rwsem: relocate rwsem_down_read_failed() Waiman Long <longman@redhat.com> - 2017-06-01 19:50 +0200 [PATCH v5 7/9] locking/rwsem: Make rwsem_spin_on_owner() return a tri-state value Waiman Long <longman@redhat.com> - 2017-06-01 19:50 +0200 [PATCH v5 5/9] locking/rwsem: Enable readers spinning on writer Waiman Long <longman@redhat.com> - 2017-06-01 19:50 +0200
csiph-web