Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1475083
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in __wait_on_bit_lock() |
| Date | 2016-09-02 14:10 +0200 |
| Message-ID | <scVse-7Ky-15@gated-at.bofh.it> (permalink) |
| References | <saoK6-6YC-21@gated-at.bofh.it> <saoK6-6YC-23@gated-at.bofh.it> <scHpf-70l-21@gated-at.bofh.it> <scHpf-70l-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 09/01, Peter Zijlstra wrote:
>
> > ret = 0;
> >
> > for (;;) {
> > prepare_to_wait_exclusive(wq, &q->wait, mode);
> >
> > if (test_bit(&q->key.bit_nr, &q->key.flag))
> > ret = action(&q->key, mode);
> >
> > if (!test_and_set_bit(&q->key.bit_nr, &q->key.flag)) {
> > /* we got the lock anyway, ignore the signal */
> > ret = 0;
> > break;
> > }
> >
> > if (ret)
> > break;
> > }
> > finish_wait(wq, &q->wait);
> >
> > return ret;
> >
> >
> > Would not that work too?
>
> Nope, because we need to do that finish_wait() before
> test_and_set_bit()..
Yes, I meant
int __sched
__wait_on_bit_lock(wait_queue_head_t *wq, struct wait_bit_queue *q,
wait_bit_action_f *action, unsigned mode)
{
int ret = 0;
for (;;) {
prepare_to_wait_exclusive(wq, &q->wait, mode);
if (test_bit(q->key.bit_nr, q->key.flags))
ret = action(&q->key, mode);
finish_wait(wq, &q->wait);
if (!test_and_set_bit(q->key.bit_nr, q->key.flags))
return 0;
else if (ret)
return ret;
}
}
> Also the problem with doing finish_wait() unconditionally would be
> destroying the FIFO order. With a bit of bad luck you'd get starvation
> cases :/
OK, I didn't think about that, thanks.
Oleg.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/2] sched/wait: abort_exclusive_wait() should pass TASK_NORMAL to wake_up() Oleg Nesterov <oleg@redhat.com> - 2016-08-26 15:00 +0200
[PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in __wait_on_bit_lock() Oleg Nesterov <oleg@redhat.com> - 2016-08-26 15:00 +0200
Re: [PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in __wait_on_bit_lock() Peter Zijlstra <peterz@infradead.org> - 2016-09-01 23:10 +0200
Re: [PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in __wait_on_bit_lock() Oleg Nesterov <oleg@redhat.com> - 2016-09-02 14:10 +0200
Re: [PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in __wait_on_bit_lock() Peter Zijlstra <peterz@infradead.org> - 2016-09-01 23:20 +0200
Re: [PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in __wait_on_bit_lock() Peter Zijlstra <peterz@infradead.org> - 2016-09-02 00:20 +0200
Re: [PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in __wait_on_bit_lock() Oleg Nesterov <oleg@redhat.com> - 2016-09-02 14:10 +0200
Re: [PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in __wait_on_bit_lock() Peter Zijlstra <peterz@infradead.org> - 2016-09-02 15:30 +0200
Re: [PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in __wait_on_bit_lock() Oleg Nesterov <oleg@redhat.com> - 2016-09-02 14:10 +0200
[PATCH 1/2] sched/wait: abort_exclusive_wait() should pass TASK_NORMAL to wake_up() Oleg Nesterov <oleg@redhat.com> - 2016-08-26 15:00 +0200
Re: [PATCH 1/2] sched/wait: abort_exclusive_wait() should pass TASK_NORMAL to wake_up() Peter Zijlstra <peterz@infradead.org> - 2016-09-01 13:40 +0200
Re: [PATCH 1/2] sched/wait: abort_exclusive_wait() should pass TASK_NORMAL to wake_up() Oleg Nesterov <oleg@redhat.com> - 2016-09-01 23:10 +0200
Re: [PATCH 1/2] sched/wait: abort_exclusive_wait() should pass TASK_NORMAL to wake_up() Peter Zijlstra <peterz@infradead.org> - 2016-09-02 00:50 +0200
Re: [PATCH 0/2] sched/wait: abort_exclusive_wait() should pass TASK_NORMAL to wake_up() Peter Zijlstra <peterz@infradead.org> - 2016-09-01 13:10 +0200
csiph-web