Function report |
Source Code:kernel\locking\mutex.c |
Create Date:2022-07-28 09:47:30 |
| Last Modify:2020-03-12 14:18:49 | Copyright©Brick |
| home page | Tree |
| Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:Lock a mutex (possibly interruptible), slowpath:
Proto:static __always_inline int __sched __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, struct lockdep_map *nest_lock, unsigned long ip, struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx)
Type:int
Parameter:
| Type | Parameter | Name |
|---|---|---|
| struct mutex * | lock | |
| long | state | |
| unsigned int | subclass | |
| struct lockdep_map * | nest_lock | |
| unsigned long | ip | |
| struct ww_acquire_ctx * | ww_ctx | |
| const bool | use_ww_ctx |
| 931 | bool first = false |
| 935 | might_sleep() |
| 942 | If use_ww_ctx && ww_ctx Then |
| 943 | If Value for the false possibility is greater at compile time(ww_ctx == READ_ONCE(ctx)) Then Return -EALREADY |
| 956 | mutex_acquire_nest( & dep_map, subclass, 0, nest_lock, ip) |
| 958 | If Actual trylock that will work on any unlocked state. || mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, NULL) Then |
| 961 | lock_acquired( & dep_map, ip) |
| 962 | If use_ww_ctx && ww_ctx Then After acquiring lock with fastpath, where we do not hold wait_lock, set ctx* and wake up any waiters so they can recheck. |
| 964 | preempt_enable() |
| 965 | Return 0 |
| 976 | Go to skip_wait |
| 979 | debug_mutex_lock_common(lock, & waiter) |
| 981 | lock_contended( & dep_map, ip) |
| 983 | If Not use_ww_ctx Then |
| 991 | Else |
| 997 | If ret Then Go to err_early_kill |
| 1003 | task = current process |
| 1005 | set_current_state(state) |
| 1006 | cycle |
| 1013 | If Actual trylock that will work on any unlocked state. Then Go to acquired |
| 1021 | If signal_pending_state(state, current process) Then |
| 1026 | If use_ww_ctx && ww_ctx Then |
| 1032 | spin_unlock( & wait_lock) |
| 1039 | If use_ww_ctx && ww_ctx || Not first Then |
| 1040 | first = __mutex_waiter_is_first(lock, & waiter) |
| 1041 | If first Then __mutex_set_flag(lock, MUTEX_FLAG_HANDOFF) |
| 1045 | set_current_state(state) |
| 1051 | If Actual trylock that will work on any unlocked state. || first && mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, & waiter) Then Break |
| 1058 | acquired : |
| 1061 | If use_ww_ctx && ww_ctx Then |
| 1072 | If Value is more likely to compile time(list_empty - tests whether a list is empty*@head: the list to test.) Then __mutex_clear_flag(lock, MUTEX_FLAGS) |
| 1075 | debug_mutex_free_waiter( & waiter) |
| 1077 | skip_wait : |
| 1079 | lock_acquired( & dep_map, ip) |
| 1081 | If use_ww_ctx && ww_ctx Then Associate the ww_mutex @ww with the context @ww_ctx under which we acquired* it. |
| 1084 | spin_unlock( & wait_lock) |
| 1085 | preempt_enable() |
| 1086 | Return 0 |
| 1088 | err : |
| 1091 | err_early_kill : |
| 1092 | spin_unlock( & wait_lock) |
| 1093 | debug_mutex_free_waiter( & waiter) |
| 1094 | mutex_release( & dep_map, ip) |
| 1095 | preempt_enable() |
| 1096 | Return ret |
| Name | Describe |
|---|---|
| __mutex_lock | |
| __ww_mutex_lock | |
| mutex_lock_io_nested |
| Source code conversion tool public plug-in interface | X |
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |