.. | .. |
---|
568 | 568 | struct ww_acquire_ctx *ww_ctx, struct mutex_waiter *waiter) |
---|
569 | 569 | { |
---|
570 | 570 | bool ret = true; |
---|
| 571 | + int cnt = 0; |
---|
| 572 | + bool time_out = false; |
---|
571 | 573 | |
---|
572 | 574 | rcu_read_lock(); |
---|
573 | 575 | while (__mutex_owner(lock) == owner) { |
---|
| 576 | + trace_android_vh_mutex_opt_spin_start(lock, &time_out, &cnt); |
---|
| 577 | + if (time_out) { |
---|
| 578 | + ret = false; |
---|
| 579 | + break; |
---|
| 580 | + } |
---|
574 | 581 | /* |
---|
575 | 582 | * Ensure we emit the owner->on_cpu, dereference _after_ |
---|
576 | 583 | * checking lock->owner still matches owner. If that fails, |
---|
.. | .. |
---|
621 | 628 | if (owner) |
---|
622 | 629 | retval = owner->on_cpu && !vcpu_is_preempted(task_cpu(owner)); |
---|
623 | 630 | rcu_read_unlock(); |
---|
| 631 | + trace_android_vh_mutex_can_spin_on_owner(lock, &retval); |
---|
624 | 632 | |
---|
625 | 633 | /* |
---|
626 | 634 | * If lock->owner is not set, the mutex has been released. Return true |
---|
.. | .. |
---|
702 | 710 | if (!waiter) |
---|
703 | 711 | osq_unlock(&lock->osq); |
---|
704 | 712 | |
---|
| 713 | + trace_android_vh_mutex_opt_spin_finish(lock, true); |
---|
705 | 714 | return true; |
---|
706 | 715 | |
---|
707 | 716 | |
---|
.. | .. |
---|
710 | 719 | osq_unlock(&lock->osq); |
---|
711 | 720 | |
---|
712 | 721 | fail: |
---|
| 722 | + trace_android_vh_mutex_opt_spin_finish(lock, false); |
---|
713 | 723 | /* |
---|
714 | 724 | * If we fell out of the spin path because of need_resched(), |
---|
715 | 725 | * reschedule now, before we try-lock the mutex. This avoids getting |
---|
.. | .. |
---|
750 | 760 | */ |
---|
751 | 761 | void __sched mutex_unlock(struct mutex *lock) |
---|
752 | 762 | { |
---|
753 | | - trace_android_vh_record_mutex_lock_starttime(current, 0); |
---|
754 | 763 | #ifndef CONFIG_DEBUG_LOCK_ALLOC |
---|
755 | | - if (__mutex_unlock_fast(lock)) |
---|
| 764 | + if (__mutex_unlock_fast(lock)) { |
---|
| 765 | + trace_android_vh_record_mutex_lock_starttime(current, 0); |
---|
756 | 766 | return; |
---|
| 767 | + } |
---|
757 | 768 | #endif |
---|
758 | 769 | __mutex_unlock_slowpath(lock, _RET_IP_); |
---|
| 770 | + trace_android_vh_record_mutex_lock_starttime(current, 0); |
---|
759 | 771 | } |
---|
760 | 772 | EXPORT_SYMBOL(mutex_unlock); |
---|
761 | 773 | |
---|