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

Function devctl_alloc_dei

freebsd/kern/subr_bus.c:608–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606}
607
608static struct dev_event_info *
609devctl_alloc_dei(void)
610{
611 struct dev_event_info *dei = NULL;
612
613 mtx_lock(&devsoftc.mtx);
614 if (devctl_queue_length == 0)
615 goto out;
616 dei = uma_zalloc(devsoftc.zone, M_NOWAIT);
617 if (dei == NULL)
618 dei = uma_zalloc(devsoftc.zone, M_NOWAIT | M_USE_RESERVE);
619 if (dei == NULL) {
620 /*
621 * Guard against no items in the queue. Normally, this won't
622 * happen, but if lots of events happen all at once and there's
623 * a chance we're out of allocated space but none have yet been
624 * queued when we get here, leaving nothing to steal. This can
625 * also happen with error injection. Fail safe by returning
626 * NULL in that case..
627 */
628 if (devsoftc.queued == 0)
629 goto out;
630 dei = STAILQ_FIRST(&devsoftc.devq);
631 STAILQ_REMOVE_HEAD(&devsoftc.devq, dei_link);
632 devsoftc.queued--;
633 }
634 MPASS(dei != NULL);
635 *dei->dei_data = '\0';
636out:
637 mtx_unlock(&devsoftc.mtx);
638 return (dei);
639}
640
641static struct dev_event_info *
642devctl_alloc_dei_sb(struct sbuf *sb)

Callers 1

devctl_alloc_dei_sbFunction · 0.85

Calls 3

mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
uma_zallocFunction · 0.50

Tested by

no test coverage detected