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