diff options
author | Niklas Cassel <niklas.cassel@axis.com> | 2017-02-24 19:17:53 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-03-16 04:28:30 -0400 |
commit | 17fcbd590d0c3e35bd9646e2215f86586378bc42 (patch) | |
tree | 4600933a681ee6d74d395e06dfef9f0fb1c77396 | |
parent | 9bbb25afeb182502ca4f2c4f3f88af0681b34cae (diff) |
locking/rwsem: Fix down_write_killable() for CONFIG_RWSEM_GENERIC_SPINLOCK=y
We hang if SIGKILL has been sent, but the task is stuck in down_read()
(after do_exit()), even though no task is doing down_write() on the
rwsem in question:
INFO: task libupnp:21868 blocked for more than 120 seconds.
libupnp D 0 21868 1 0x08100008
...
Call Trace:
__schedule()
schedule()
__down_read()
do_exit()
do_group_exit()
__wake_up_parent()
This bug has already been fixed for CONFIG_RWSEM_XCHGADD_ALGORITHM=y in
the following commit:
04cafed7fc19 ("locking/rwsem: Fix down_write_killable()")
... however, this bug also exists for CONFIG_RWSEM_GENERIC_SPINLOCK=y.
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <mhocko@suse.com>
Cc: <stable@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Niklas Cassel <niklass@axis.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: d47996082f52 ("locking/rwsem: Introduce basis for down_write_killable()")
Link: http://lkml.kernel.org/r/1487981873-12649-1-git-send-email-niklass@axis.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | kernel/locking/rwsem-spinlock.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/kernel/locking/rwsem-spinlock.c b/kernel/locking/rwsem-spinlock.c index 7bc24d477805..c65f7989f850 100644 --- a/kernel/locking/rwsem-spinlock.c +++ b/kernel/locking/rwsem-spinlock.c | |||
@@ -213,10 +213,9 @@ int __sched __down_write_common(struct rw_semaphore *sem, int state) | |||
213 | */ | 213 | */ |
214 | if (sem->count == 0) | 214 | if (sem->count == 0) |
215 | break; | 215 | break; |
216 | if (signal_pending_state(state, current)) { | 216 | if (signal_pending_state(state, current)) |
217 | ret = -EINTR; | 217 | goto out_nolock; |
218 | goto out; | 218 | |
219 | } | ||
220 | set_current_state(state); | 219 | set_current_state(state); |
221 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); | 220 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
222 | schedule(); | 221 | schedule(); |
@@ -224,12 +223,19 @@ int __sched __down_write_common(struct rw_semaphore *sem, int state) | |||
224 | } | 223 | } |
225 | /* got the lock */ | 224 | /* got the lock */ |
226 | sem->count = -1; | 225 | sem->count = -1; |
227 | out: | ||
228 | list_del(&waiter.list); | 226 | list_del(&waiter.list); |
229 | 227 | ||
230 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); | 228 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
231 | 229 | ||
232 | return ret; | 230 | return ret; |
231 | |||
232 | out_nolock: | ||
233 | list_del(&waiter.list); | ||
234 | if (!list_empty(&sem->wait_list)) | ||
235 | __rwsem_do_wake(sem, 1); | ||
236 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); | ||
237 | |||
238 | return -EINTR; | ||
233 | } | 239 | } |
234 | 240 | ||
235 | void __sched __down_write(struct rw_semaphore *sem) | 241 | void __sched __down_write(struct rw_semaphore *sem) |