| 2354 | } |
| 2355 | |
| 2356 | void |
| 2357 | sched_preempt(struct thread *td) |
| 2358 | { |
| 2359 | struct tdq *tdq; |
| 2360 | int flags; |
| 2361 | |
| 2362 | SDT_PROBE2(sched, , , surrender, td, td->td_proc); |
| 2363 | |
| 2364 | thread_lock(td); |
| 2365 | tdq = TDQ_SELF(); |
| 2366 | TDQ_LOCK_ASSERT(tdq, MA_OWNED); |
| 2367 | if (td->td_priority > tdq->tdq_lowpri) { |
| 2368 | if (td->td_critnest == 1) { |
| 2369 | flags = SW_INVOL | SW_PREEMPT; |
| 2370 | flags |= TD_IS_IDLETHREAD(td) ? SWT_REMOTEWAKEIDLE : |
| 2371 | SWT_REMOTEPREEMPT; |
| 2372 | mi_switch(flags); |
| 2373 | /* Switch dropped thread lock. */ |
| 2374 | return; |
| 2375 | } |
| 2376 | td->td_owepreempt = 1; |
| 2377 | } else { |
| 2378 | tdq->tdq_owepreempt = 0; |
| 2379 | } |
| 2380 | thread_unlock(td); |
| 2381 | } |
| 2382 | |
| 2383 | /* |
| 2384 | * Fix priorities on return to user-space. Priorities may be elevated due |
no test coverage detected