Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1399102
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable |
| Date | 2016-05-11 16:00 +0200 |
| Message-ID | <rxCQ9-UH-1@gated-at.bofh.it> (permalink) |
| References | (5 earlier) <rxy0b-4vB-31@gated-at.bofh.it> <rxyjx-58a-21@gated-at.bofh.it> <rxytd-5fG-43@gated-at.bofh.it> <rxyMx-5vM-1@gated-at.bofh.it> <rxyWf-5Bh-43@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Wed 11-05-16 11:41:28, Peter Zijlstra wrote:
> On Wed, May 11, 2016 at 11:31:27AM +0200, Michal Hocko wrote:
>
> > Care to cook up a full patch?
>
> compile tested only, if someone could please test it?
I have tried to run the test case from Tetsuo[1] with a small printk to
show the interrupted writer case:
[ 2753.596678] XXX: Writer interrupted. Woken waiters:0
[ 2998.266978] XXX: Writer interrupted. Woken waiters:0
which means rwsem_atomic_update(-RWSEM_WAITING_BIAS, sem) path which is
the problematic case. oom_reaper was always able to succeed so I guess
the patch works as expected. I will leave the test run for longer to be
sure.
[1] http://lkml.kernel.org/r/201605061958.HHG48967.JVFtSLFQOFOOMH@I-love.SAKURA.ne.jp
>
> I'll go write a Changelog if it turns out to actually work ;-)
>
> ---
> kernel/locking/rwsem-xadd.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c
> index df4dcb883b50..09e30c6225e5 100644
> --- a/kernel/locking/rwsem-xadd.c
> +++ b/kernel/locking/rwsem-xadd.c
> @@ -487,23 +487,32 @@ __rwsem_down_write_failed_common(struct rw_semaphore *sem, int state)
>
> /* Block until there are no active lockers. */
> do {
> - if (signal_pending_state(state, current)) {
> - raw_spin_lock_irq(&sem->wait_lock);
> - ret = ERR_PTR(-EINTR);
> - goto out;
> - }
> + if (signal_pending_state(state, current))
> + goto out_nolock;
> +
> schedule();
> set_current_state(state);
> } while ((count = sem->count) & RWSEM_ACTIVE_MASK);
>
> raw_spin_lock_irq(&sem->wait_lock);
> }
> -out:
> __set_current_state(TASK_RUNNING);
> list_del(&waiter.list);
> raw_spin_unlock_irq(&sem->wait_lock);
>
> return ret;
> +
> +out_nolock:
> + __set_current_state(TASK_RUNNING);
> + raw_spin_lock_irq(&sem->wait_lock);
> + list_del(&waiter.list);
> + if (list_empty(&sem->wait_list))
> + rwsem_atomic_update(-RWSEM_WAITING_BIAS, sem);
> + else
> + __rwsem_do_wake(sem, RWSEM_WAKE_ANY);
> + raw_spin_unlock_irq(&sem->wait_lock);
> +
> + return ERR_PTR(-EINTR);
> }
>
> __visible struct rw_semaphore * __sched
--
Michal Hocko
SUSE Labs
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-05-10 12:50 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Michal Hocko <mhocko@kernel.org> - 2016-05-10 14:00 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Peter Zijlstra <peterz@infradead.org> - 2016-05-10 14:40 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-05-10 16:00 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Michal Hocko <mhocko@kernel.org> - 2016-05-11 09:30 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Michal Hocko <mhocko@kernel.org> - 2016-05-11 10:30 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Peter Zijlstra <peterz@infradead.org> - 2016-05-11 10:50 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Michal Hocko <mhocko@kernel.org> - 2016-05-11 11:10 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Peter Zijlstra <peterz@infradead.org> - 2016-05-11 11:20 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Michal Hocko <mhocko@kernel.org> - 2016-05-11 11:40 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Peter Zijlstra <peterz@infradead.org> - 2016-05-11 11:50 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Michal Hocko <mhocko@kernel.org> - 2016-05-11 16:00 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Michal Hocko <mhocko@kernel.org> - 2016-05-11 20:10 +0200
[PATCH] locking, rwsem: Fix down_write_killable() Peter Zijlstra <peterz@infradead.org> - 2016-05-12 14:00 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Peter Zijlstra <peterz@infradead.org> - 2016-05-11 10:40 +0200
Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable Michal Hocko <mhocko@kernel.org> - 2016-05-11 11:10 +0200
csiph-web