MCPcopy Create free account
hub / github.com/F-Stack/f-stack / unlock_rm

Function unlock_rm

freebsd/kern/kern_rmlock.c:138–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138static uintptr_t
139unlock_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
181static int

Callers

nothing calls this directly

Calls 4

get_pcpuFunction · 0.85
rm_wownedFunction · 0.70
critical_enterFunction · 0.50
critical_exitFunction · 0.50

Tested by

no test coverage detected