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

Function sysctl_debug_umtx_chains_peaks

freebsd/kern/kern_umtx.c:317–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317static int
318sysctl_debug_umtx_chains_peaks(SYSCTL_HANDLER_ARGS)
319{
320 char buf[512];
321 struct sbuf sb;
322 struct umtxq_chain *uc;
323 u_int fract, i, j, tot, whole;
324 u_int sf0, sf1, sf2, sf3, sf4;
325 u_int si0, si1, si2, si3, si4;
326 u_int sw0, sw1, sw2, sw3, sw4;
327
328 sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
329 for (i = 0; i < 2; i++) {
330 tot = 0;
331 for (j = 0; j < UMTX_CHAINS; ++j) {
332 uc = &umtxq_chains[i][j];
333 mtx_lock(&uc->uc_lock);
334 tot += uc->max_length;
335 mtx_unlock(&uc->uc_lock);
336 }
337 if (tot == 0)
338 sbuf_printf(&sb, "%u) Empty ", i);
339 else {
340 sf0 = sf1 = sf2 = sf3 = sf4 = 0;
341 si0 = si1 = si2 = si3 = si4 = 0;
342 sw0 = sw1 = sw2 = sw3 = sw4 = 0;
343 for (j = 0; j < UMTX_CHAINS; j++) {
344 uc = &umtxq_chains[i][j];
345 mtx_lock(&uc->uc_lock);
346 whole = uc->max_length * 100;
347 mtx_unlock(&uc->uc_lock);
348 fract = (whole % tot) * 100;
349 if (UPROF_PERC_BIGGER(whole, fract, sw0, sf0)) {
350 sf0 = fract;
351 si0 = j;
352 sw0 = whole;
353 } else if (UPROF_PERC_BIGGER(whole, fract, sw1,
354 sf1)) {
355 sf1 = fract;
356 si1 = j;
357 sw1 = whole;
358 } else if (UPROF_PERC_BIGGER(whole, fract, sw2,
359 sf2)) {
360 sf2 = fract;
361 si2 = j;
362 sw2 = whole;
363 } else if (UPROF_PERC_BIGGER(whole, fract, sw3,
364 sf3)) {
365 sf3 = fract;
366 si3 = j;
367 sw3 = whole;
368 } else if (UPROF_PERC_BIGGER(whole, fract, sw4,
369 sf4)) {
370 sf4 = fract;
371 si4 = j;
372 sw4 = whole;
373 }
374 }

Callers

nothing calls this directly

Calls 10

sbuf_newFunction · 0.85
sbuf_printfFunction · 0.85
sbuf_trimFunction · 0.85
sbuf_finishFunction · 0.85
sysctl_handle_stringFunction · 0.85
sbuf_dataFunction · 0.85
sbuf_lenFunction · 0.85
sbuf_deleteFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected