| 1293 | MTX_SYSINIT(sleepq_prof_lock, &sleepq_prof_lock, "sleepq_prof", MTX_SPIN); |
| 1294 | |
| 1295 | static void |
| 1296 | sleepq_profile(const char *wmesg) |
| 1297 | { |
| 1298 | struct sleepq_prof *sp; |
| 1299 | |
| 1300 | mtx_lock_spin(&sleepq_prof_lock); |
| 1301 | if (prof_enabled == 0) |
| 1302 | goto unlock; |
| 1303 | LIST_FOREACH(sp, &sleepq_hash[SC_HASH(wmesg)], sp_link) |
| 1304 | if (sp->sp_wmesg == wmesg) |
| 1305 | goto done; |
| 1306 | sp = LIST_FIRST(&sleepq_prof_free); |
| 1307 | if (sp == NULL) |
| 1308 | goto unlock; |
| 1309 | sp->sp_wmesg = wmesg; |
| 1310 | LIST_REMOVE(sp, sp_link); |
| 1311 | LIST_INSERT_HEAD(&sleepq_hash[SC_HASH(wmesg)], sp, sp_link); |
| 1312 | done: |
| 1313 | sp->sp_count++; |
| 1314 | unlock: |
| 1315 | mtx_unlock_spin(&sleepq_prof_lock); |
| 1316 | return; |
| 1317 | } |
| 1318 | |
| 1319 | static void |
| 1320 | sleepq_prof_reset(void) |