| 136 | } |
| 137 | |
| 138 | static uintptr_t |
| 139 | unlock_rm(struct lock_object *lock) |
| 140 | { |
| 141 | struct thread *td; |
| 142 | struct pcpu *pc; |
| 143 | struct rmlock *rm; |
| 144 | struct rm_queue *queue; |
| 145 | struct rm_priotracker *tracker; |
| 146 | uintptr_t how; |
| 147 | |
| 148 | rm = (struct rmlock *)lock; |
| 149 | tracker = NULL; |
| 150 | how = 0; |
| 151 | rm_assert(rm, RA_LOCKED | RA_NOTRECURSED); |
| 152 | if (rm_wowned(rm)) |
| 153 | rm_wunlock(rm); |
| 154 | else { |
| 155 | /* |
| 156 | * Find the right rm_priotracker structure for curthread. |
| 157 | * The guarantee about its uniqueness is given by the fact |
| 158 | * we already asserted the lock wasn't recursively acquired. |
| 159 | */ |
| 160 | critical_enter(); |
| 161 | td = curthread; |
| 162 | pc = get_pcpu(); |
| 163 | for (queue = pc->pc_rm_queue.rmq_next; |
| 164 | queue != &pc->pc_rm_queue; queue = queue->rmq_next) { |
| 165 | tracker = (struct rm_priotracker *)queue; |
| 166 | if ((tracker->rmp_rmlock == rm) && |
| 167 | (tracker->rmp_thread == td)) { |
| 168 | how = (uintptr_t)tracker; |
| 169 | break; |
| 170 | } |
| 171 | } |
| 172 | KASSERT(tracker != NULL, |
| 173 | ("rm_priotracker is non-NULL when lock held in read mode")); |
| 174 | critical_exit(); |
| 175 | rm_runlock(rm, tracker); |
| 176 | } |
| 177 | return (how); |
| 178 | } |
| 179 | |
| 180 | #ifdef KDTRACE_HOOKS |
| 181 | static int |
nothing calls this directly
no test coverage detected