Skip to content

Commit a40ca56

Browse files
Waiman Longingomolnar
authored andcommitted
locking/mutex: Simplify some ww_mutex code in __mutex_lock_common()
This patch removes some of the redundant ww_mutex code in __mutex_lock_common(). Tested-by: Jason Low <jason.low2@hpe.com> Signed-off-by: Waiman Long <Waiman.Long@hpe.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Ding Tianhong <dingtianhong@huawei.com> Cc: Imre Deak <imre.deak@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Paul E. McKenney <paulmck@us.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tim Chen <tim.c.chen@linux.intel.com> Cc: Will Deacon <Will.Deacon@arm.com> Link: http://lkml.kernel.org/r/1472254509-27508-1-git-send-email-Waiman.Long@hpe.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 5bbd7e6 commit a40ca56

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

kernel/locking/mutex.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,10 +587,11 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
587587
struct mutex_waiter waiter;
588588
unsigned long flags;
589589
bool first = false;
590+
struct ww_mutex *ww;
590591
int ret;
591592

592593
if (use_ww_ctx) {
593-
struct ww_mutex *ww = container_of(lock, struct ww_mutex, base);
594+
ww = container_of(lock, struct ww_mutex, base);
594595
if (unlikely(ww_ctx == READ_ONCE(ww->ctx)))
595596
return -EALREADY;
596597
}
@@ -602,12 +603,8 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
602603
mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx)) {
603604
/* got the lock, yay! */
604605
lock_acquired(&lock->dep_map, ip);
605-
if (use_ww_ctx) {
606-
struct ww_mutex *ww;
607-
ww = container_of(lock, struct ww_mutex, base);
608-
606+
if (use_ww_ctx)
609607
ww_mutex_set_context_fastpath(ww, ww_ctx);
610-
}
611608
preempt_enable();
612609
return 0;
613610
}
@@ -691,10 +688,8 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
691688
/* got the lock - cleanup and rejoice! */
692689
lock_acquired(&lock->dep_map, ip);
693690

694-
if (use_ww_ctx) {
695-
struct ww_mutex *ww = container_of(lock, struct ww_mutex, base);
691+
if (use_ww_ctx)
696692
ww_mutex_set_context_slowpath(ww, ww_ctx);
697-
}
698693

699694
spin_unlock_mutex(&lock->wait_lock, flags);
700695
preempt_enable();

0 commit comments

Comments
 (0)