27
27
#include <trace/events/lock.h>
28
28
29
29
#include "rtmutex_common.h"
30
+ #include "lock_events.h"
30
31
31
32
#ifndef WW_RT
32
33
# define build_ww_mutex () (false)
@@ -1612,10 +1613,13 @@ static int __sched rt_mutex_slowlock_block(struct rt_mutex_base *lock,
1612
1613
struct task_struct * owner ;
1613
1614
int ret = 0 ;
1614
1615
1616
+ lockevent_inc (rtmutex_slow_block );
1615
1617
for (;;) {
1616
1618
/* Try to acquire the lock: */
1617
- if (try_to_take_rt_mutex (lock , current , waiter ))
1619
+ if (try_to_take_rt_mutex (lock , current , waiter )) {
1620
+ lockevent_inc (rtmutex_slow_acq3 );
1618
1621
break ;
1622
+ }
1619
1623
1620
1624
if (timeout && !timeout -> task ) {
1621
1625
ret = - ETIMEDOUT ;
@@ -1638,8 +1642,10 @@ static int __sched rt_mutex_slowlock_block(struct rt_mutex_base *lock,
1638
1642
owner = NULL ;
1639
1643
raw_spin_unlock_irq_wake (& lock -> wait_lock , wake_q );
1640
1644
1641
- if (!owner || !rtmutex_spin_on_owner (lock , waiter , owner ))
1645
+ if (!owner || !rtmutex_spin_on_owner (lock , waiter , owner )) {
1646
+ lockevent_inc (rtmutex_slow_sleep );
1642
1647
rt_mutex_schedule ();
1648
+ }
1643
1649
1644
1650
raw_spin_lock_irq (& lock -> wait_lock );
1645
1651
set_current_state (state );
@@ -1694,13 +1700,15 @@ static int __sched __rt_mutex_slowlock(struct rt_mutex_base *lock,
1694
1700
int ret ;
1695
1701
1696
1702
lockdep_assert_held (& lock -> wait_lock );
1703
+ lockevent_inc (rtmutex_slowlock );
1697
1704
1698
1705
/* Try to acquire the lock again: */
1699
1706
if (try_to_take_rt_mutex (lock , current , NULL )) {
1700
1707
if (build_ww_mutex () && ww_ctx ) {
1701
1708
__ww_mutex_check_waiters (rtm , ww_ctx , wake_q );
1702
1709
ww_mutex_lock_acquired (ww , ww_ctx );
1703
1710
}
1711
+ lockevent_inc (rtmutex_slow_acq1 );
1704
1712
return 0 ;
1705
1713
}
1706
1714
@@ -1719,10 +1727,12 @@ static int __sched __rt_mutex_slowlock(struct rt_mutex_base *lock,
1719
1727
__ww_mutex_check_waiters (rtm , ww_ctx , wake_q );
1720
1728
ww_mutex_lock_acquired (ww , ww_ctx );
1721
1729
}
1730
+ lockevent_inc (rtmutex_slow_acq2 );
1722
1731
} else {
1723
1732
__set_current_state (TASK_RUNNING );
1724
1733
remove_waiter (lock , waiter );
1725
1734
rt_mutex_handle_deadlock (ret , chwalk , lock , waiter );
1735
+ lockevent_inc (rtmutex_deadlock );
1726
1736
}
1727
1737
1728
1738
/*
@@ -1751,6 +1761,7 @@ static inline int __rt_mutex_slowlock_locked(struct rt_mutex_base *lock,
1751
1761
& waiter , wake_q );
1752
1762
1753
1763
debug_rt_mutex_free_waiter (& waiter );
1764
+ lockevent_cond_inc (rtmutex_slow_wake , !wake_q_empty (wake_q ));
1754
1765
return ret ;
1755
1766
}
1756
1767
@@ -1823,9 +1834,12 @@ static void __sched rtlock_slowlock_locked(struct rt_mutex_base *lock,
1823
1834
struct task_struct * owner ;
1824
1835
1825
1836
lockdep_assert_held (& lock -> wait_lock );
1837
+ lockevent_inc (rtlock_slowlock );
1826
1838
1827
- if (try_to_take_rt_mutex (lock , current , NULL ))
1839
+ if (try_to_take_rt_mutex (lock , current , NULL )) {
1840
+ lockevent_inc (rtlock_slow_acq1 );
1828
1841
return ;
1842
+ }
1829
1843
1830
1844
rt_mutex_init_rtlock_waiter (& waiter );
1831
1845
@@ -1838,17 +1852,21 @@ static void __sched rtlock_slowlock_locked(struct rt_mutex_base *lock,
1838
1852
1839
1853
for (;;) {
1840
1854
/* Try to acquire the lock again */
1841
- if (try_to_take_rt_mutex (lock , current , & waiter ))
1855
+ if (try_to_take_rt_mutex (lock , current , & waiter )) {
1856
+ lockevent_inc (rtlock_slow_acq2 );
1842
1857
break ;
1858
+ }
1843
1859
1844
1860
if (& waiter == rt_mutex_top_waiter (lock ))
1845
1861
owner = rt_mutex_owner (lock );
1846
1862
else
1847
1863
owner = NULL ;
1848
1864
raw_spin_unlock_irq_wake (& lock -> wait_lock , wake_q );
1849
1865
1850
- if (!owner || !rtmutex_spin_on_owner (lock , & waiter , owner ))
1866
+ if (!owner || !rtmutex_spin_on_owner (lock , & waiter , owner )) {
1867
+ lockevent_inc (rtlock_slow_sleep );
1851
1868
schedule_rtlock ();
1869
+ }
1852
1870
1853
1871
raw_spin_lock_irq (& lock -> wait_lock );
1854
1872
set_current_state (TASK_RTLOCK_WAIT );
@@ -1865,6 +1883,7 @@ static void __sched rtlock_slowlock_locked(struct rt_mutex_base *lock,
1865
1883
debug_rt_mutex_free_waiter (& waiter );
1866
1884
1867
1885
trace_contention_end (lock , 0 );
1886
+ lockevent_cond_inc (rtlock_slow_wake , !wake_q_empty (wake_q ));
1868
1887
}
1869
1888
1870
1889
static __always_inline void __sched rtlock_slowlock (struct rt_mutex_base * lock )
0 commit comments