This patch removes some of the redundant ww_mutex code in __mutex_lock_common().
Showing the changes to kernel/locking (1 of 1 file). Show all
Unified · Split
| @@ -587,10 +587,11 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, · 586 unmodified lines | |||
| 587 | struct mutex_waiter waiter; | 587 | struct mutex_waiter waiter; |
| 588 | unsigned long flags; | 588 | unsigned long flags; |
| 589 | bool first = false; | 589 | bool first = false; |
| 590 | struct ww_mutex *ww; | ||
| 590 | int ret; | 591 | int ret; |
| 591 | 592 | ||
| 592 | if (use_ww_ctx) { | 593 | 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); |
| 594 | if (unlikely(ww_ctx == READ_ONCE(ww->ctx))) | 595 | if (unlikely(ww_ctx == READ_ONCE(ww->ctx))) |
| 595 | return -EALREADY; | 596 | return -EALREADY; |
| 596 | } | 597 | } |
| @@ -602,12 +603,8 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, · 5 unmodified lines | |||
| 602 | mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx)) { | 603 | mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx)) { |
| 603 | /* got the lock, yay! */ | 604 | /* got the lock, yay! */ |
| 604 | lock_acquired(&lock->dep_map, ip); | 605 | lock_acquired(&lock->dep_map, ip); |
| 605 | if (use_ww_ctx) { | 606 | if (use_ww_ctx) |
| 606 | struct ww_mutex *ww; | ||
| 607 | ww = container_of(lock, struct ww_mutex, base); | ||
| 608 | |||
| 609 | ww_mutex_set_context_fastpath(ww, ww_ctx); | 607 | ww_mutex_set_context_fastpath(ww, ww_ctx); |
| 610 | } | ||
| 611 | preempt_enable(); | 608 | preempt_enable(); |
| 612 | return 0; | 609 | return 0; |
| 613 | } | 610 | } |
| @@ -691,10 +688,8 @@ skip_wait: · 77 unmodified lines | |||
| 691 | /* got the lock - cleanup and rejoice! */ | 688 | /* got the lock - cleanup and rejoice! */ |
| 692 | lock_acquired(&lock->dep_map, ip); | 689 | lock_acquired(&lock->dep_map, ip); |
| 693 | 690 | ||
| 694 | if (use_ww_ctx) { | 691 | if (use_ww_ctx) |
| 695 | struct ww_mutex *ww = container_of(lock, struct ww_mutex, base); | ||
| 696 | ww_mutex_set_context_slowpath(ww, ww_ctx); | 692 | ww_mutex_set_context_slowpath(ww, ww_ctx); |
| 697 | } | ||
| 698 | 693 | ||
| 699 | spin_unlock_mutex(&lock->wait_lock, flags); | 694 | spin_unlock_mutex(&lock->wait_lock, flags); |
| 700 | preempt_enable(); | 695 | preempt_enable(); |