| 424 | static struct cdev *devctl_dev; |
| 425 | |
| 426 | static void |
| 427 | devinit(void) |
| 428 | { |
| 429 | int reserve; |
| 430 | uma_zone_t z; |
| 431 | |
| 432 | devctl_dev = make_dev_credf(MAKEDEV_ETERNAL, &dev_cdevsw, 0, NULL, |
| 433 | UID_ROOT, GID_WHEEL, 0600, "devctl"); |
| 434 | mtx_init(&devsoftc.mtx, "dev mtx", "devd", MTX_DEF); |
| 435 | cv_init(&devsoftc.cv, "dev cv"); |
| 436 | STAILQ_INIT(&devsoftc.devq); |
| 437 | knlist_init_mtx(&devsoftc.sel.si_note, &devsoftc.mtx); |
| 438 | if (devctl_queue_length > 0) { |
| 439 | /* |
| 440 | * Allocate a zone for the messages. Preallocate 2% of these for |
| 441 | * a reserve. Allow only devctl_queue_length slabs to cap memory |
| 442 | * usage. The reserve usually allows coverage of surges of |
| 443 | * events during memory shortages. Normally we won't have to |
| 444 | * re-use events from the queue, but will in extreme shortages. |
| 445 | */ |
| 446 | z = devsoftc.zone = uma_zcreate("DEVCTL", |
| 447 | sizeof(struct dev_event_info), NULL, NULL, NULL, NULL, |
| 448 | UMA_ALIGN_PTR, 0); |
| 449 | reserve = max(devctl_queue_length / 50, 100); /* 2% reserve */ |
| 450 | uma_zone_set_max(z, devctl_queue_length); |
| 451 | uma_zone_set_maxcache(z, 0); |
| 452 | uma_zone_reserve(z, reserve); |
| 453 | uma_prealloc(z, reserve); |
| 454 | } |
| 455 | devctl2_init(); |
| 456 | } |
| 457 | |
| 458 | static int |
| 459 | devopen(struct cdev *dev, int oflags, int devtype, struct thread *td) |
no test coverage detected