Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1707289
| From | Mike Galbraith <efault@gmx.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [patch-rt] locking, rwlock-rt: do not save state multiple times in __write_rt_lock() |
| Date | 2017-08-09 14:10 +0200 |
| Message-ID | <ucxYf-6SW-29@gated-at.bofh.it> (permalink) |
| References | <uaOJP-1Av-1@gated-at.bofh.it> <ub0Bk-11T-7@gated-at.bofh.it> <ubL7c-5nh-5@gated-at.bofh.it> <ubLJU-5RE-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Save state prior to entering the acquisition loop, otherwise we may
initially see readers, but upon releasing ->wait_lock see none, loop
back around, and having not slept, save TASK_UNINTERRUPTIBLE.
Signed-off-by_ Mike Galbraith <efault@gmx.de>
---
kernel/locking/rwlock-rt.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
--- a/kernel/locking/rwlock-rt.c
+++ b/kernel/locking/rwlock-rt.c
@@ -190,30 +190,33 @@ void __sched __write_rt_lock(struct rt_r
/* Force readers into slow path */
atomic_sub(READER_BIAS, &lock->readers);
- for (;;) {
- raw_spin_lock_irqsave(&m->wait_lock, flags);
-
- raw_spin_lock(&self->pi_lock);
- self->saved_state = self->state;
- __set_current_state_no_track(TASK_UNINTERRUPTIBLE);
- raw_spin_unlock(&self->pi_lock);
+ raw_spin_lock_irqsave(&m->wait_lock, flags);
+ raw_spin_lock(&self->pi_lock);
+ self->saved_state = self->state;
+ __set_current_state_no_track(TASK_UNINTERRUPTIBLE);
+ raw_spin_unlock(&self->pi_lock);
+ for (;;) {
/* Have all readers left the critical region? */
- if (!atomic_read(&lock->readers)) {
- atomic_set(&lock->readers, WRITER_BIAS);
- raw_spin_lock(&self->pi_lock);
- __set_current_state_no_track(self->saved_state);
- self->saved_state = TASK_RUNNING;
- raw_spin_unlock(&self->pi_lock);
- raw_spin_unlock_irqrestore(&m->wait_lock, flags);
- return;
- }
+ if (!atomic_read(&lock->readers))
+ break;
raw_spin_unlock_irqrestore(&m->wait_lock, flags);
-
if (atomic_read(&lock->readers) != 0)
schedule();
+ raw_spin_lock_irqsave(&m->wait_lock, flags);
+
+ raw_spin_lock(&self->pi_lock);
+ __set_current_state_no_track(TASK_UNINTERRUPTIBLE);
+ raw_spin_unlock(&self->pi_lock);
}
+
+ atomic_set(&lock->readers, WRITER_BIAS);
+ raw_spin_lock(&self->pi_lock);
+ __set_current_state_no_track(self->saved_state);
+ self->saved_state = TASK_RUNNING;
+ raw_spin_unlock(&self->pi_lock);
+ raw_spin_unlock_irqrestore(&m->wait_lock, flags);
}
int __write_rt_trylock(struct rt_rw_lock *lock)
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[ANNOUNCE] v4.11.12-rt9 Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-08-04 19:40 +0200
Re: [ANNOUNCE] v4.11.12-rt9 Mike Galbraith <efault@gmx.de> - 2017-08-05 08:20 +0200
Re: [ANNOUNCE] v4.11.12-rt9 Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-08-07 09:40 +0200
Re: [ANNOUNCE] v4.11.12-rt9 Mike Galbraith <efault@gmx.de> - 2017-08-07 10:30 +0200
Re: [ANNOUNCE] v4.11.12-rt9 Mike Galbraith <efault@gmx.de> - 2017-08-08 12:10 +0200
[patch-rt] hotplug, hrtimer: Migrate expired/deferred timers during cpu offline Mike Galbraith <efault@gmx.de> - 2017-08-11 10:00 +0200
Re: [patch-rt] hotplug, hrtimer: Migrate expired/deferred timers during cpu offline Mike Galbraith <efault@gmx.de> - 2017-08-11 10:20 +0200
Re: [ANNOUNCE] v4.11.12-rt9 Sebastian Andrzej Siewior <bigeasy@linutronix.de> - 2017-08-07 10:00 +0200
Re: [ANNOUNCE] v4.11.12-rt9 Mike Galbraith <efault@gmx.de> - 2017-08-07 10:40 +0200
[patch-rt] locking, rwlock-rt: do not save state multiple times in __write_rt_lock() Mike Galbraith <efault@gmx.de> - 2017-08-09 14:10 +0200
Re: [ANNOUNCE] v4.11.12-rt9 Mike Galbraith <efault@gmx.de> - 2017-08-07 11:20 +0200
csiph-web