Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1483162
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH -v3 07/10] mutex: Restructure wait loop |
| Date | 2016-09-14 12:40 +0200 |
| Message-ID | <shfLH-89J-5@gated-at.bofh.it> (permalink) |
| References | <se1vA-3Ov-11@gated-at.bofh.it> <se1vA-3Ov-27@gated-at.bofh.it> <shfLH-89J-7@gated-at.bofh.it> <shfLH-89J-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, Sep 09, 2016 at 04:32:39PM -0400, Waiman Long wrote:
> >I think you need to remove the HANDOFF flag here in the error path too.
> >Maybe you should fix that in patch 6.
> >
> >It is also possible that __mutex_handoff() has been called at this point.
> >So this task may now be the owner of the lock. Maybe you should do a final
> >trylock here.
>
> Alternatively, we can move the trylock in the main loop after the
> spin_lock_mutex(). In this case, we don't need an extra trylock in the error
> path.
I did something like so..
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -629,12 +629,12 @@ __mutex_lock_common(struct mutex *lock,
if (__mutex_waiter_is_first(lock, &waiter))
__mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
- if (__mutex_trylock(lock, false))
- goto remove_waiter;
-
lock_contended(&lock->dep_map, ip);
for (;;) {
+ if (__mutex_trylock(lock, first))
+ break;
+
/*
* got a signal? (This code gets eliminated in the
* TASK_UNINTERRUPTIBLE case.)
@@ -659,13 +659,9 @@ __mutex_lock_common(struct mutex *lock,
first = true;
__mutex_set_flag(lock, MUTEX_FLAG_HANDOFF);
}
-
- if (__mutex_trylock(lock, first))
- break;
}
__set_task_state(task, TASK_RUNNING);
-remove_waiter:
mutex_remove_waiter(lock, &waiter, task);
if (likely(list_empty(&lock->wait_list)))
__mutex_clear_flag(lock, MUTEX_FLAGS);
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
Re: [PATCH -v3 07/10] mutex: Restructure wait loop Peter Zijlstra <peterz@infradead.org> - 2016-09-14 12:40 +0200
csiph-web