History

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().

Waiman Long committed 10 years ago

Commit a40ca561 parent 5bbd7e61 file · +4 −9Browse files

Showing the changes to kernel/locking (1 of 1 file). Show all

Unified · Split

kernel/locking/mutex.c+4−9
@@ -587,10 +587,11 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, · 586 unmodified lines
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, · 5 unmodified lines
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 @@ skip_wait: · 77 unmodified lines
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();