Lines Matching defs:cpu

336 #include <machine/cpu.h>
360 cyclic_upheap(cyc_cpu_t *cpu, cyc_index_t ndx)
370 heap = cpu->cyp_heap;
371 cyclics = cpu->cyp_cyclics;
403 cyclic_downheap(cyc_cpu_t *cpu, cyc_index_t ndx)
405 cyclic_t *cyclics = cpu->cyp_cyclics;
406 cyc_index_t *heap = cpu->cyp_heap;
410 cyc_index_t nelems = cpu->cyp_nelems;
478 cyclic_expire(cyc_cpu_t *cpu, cyc_index_t ndx, cyclic_t *cyclic)
515 cyc_cpu_t *cpu = c->cpu_cyclic;
516 cyc_backend_t *be = cpu->cyp_backend;
517 cyc_index_t *heap = cpu->cyp_heap;
518 cyclic_t *cyclic, *cyclics = cpu->cyp_cyclics;
523 if (cpu->cyp_nelems == 0) {
538 cyclic_expire(cpu, ndx, cyclic);
568 cyclic_downheap(cpu, 0);
581 cyc_cpu_t *cpu = arg->cyx_cpu;
582 cyc_index_t new_size = arg->cyx_size, size = cpu->cyp_size, i;
584 cyclic_t *cyclics = cpu->cyp_cyclics, *new_cyclics = arg->cyx_cyclics;
587 mtx_lock_spin(&cpu->cyp_mtx);
594 ASSERT(cpu->cyp_heap != NULL && cpu->cyp_cyclics != NULL);
596 bcopy(cpu->cyp_heap, new_heap, sizeof (cyc_index_t) * size);
611 cpu->cyp_heap = new_heap;
612 cpu->cyp_cyclics = new_cyclics;
613 cpu->cyp_size = new_size;
614 mtx_unlock_spin(&cpu->cyp_mtx);
622 cyclic_expand(cyc_cpu_t *cpu)
628 cyc_backend_t *be = cpu->cyp_backend;
632 old_heap = cpu->cyp_heap;
633 old_cyclics = cpu->cyp_cyclics;
635 if ((new_size = ((old_size = cpu->cyp_size) << 1)) == 0) {
648 arg.cyx_cpu = cpu;
653 be->cyb_xcall(be->cyb_arg, cpu->cyp_cpu,
667 cyc_cpu_t *cpu = arg->cyx_cpu;
670 cyc_backend_t *be = cpu->cyp_backend;
675 ASSERT(cpu->cyp_nelems < cpu->cyp_size);
678 mtx_lock_spin(&cpu->cyp_mtx);
679 nelems = cpu->cyp_nelems++;
689 ndx = cpu->cyp_heap[nelems];
690 cyclic = &cpu->cyp_cyclics[ndx];
710 if (cyclic_upheap(cpu, nelems)) {
719 mtx_unlock_spin(&cpu->cyp_mtx);
725 cyclic_add_here(cyc_cpu_t *cpu, cyc_handler_t *hdlr,
728 cyc_backend_t *be = cpu->cyp_backend;
733 ASSERT(!(cpu->cyp_cpu->cpu_flags & CPU_OFFLINE));
736 if (cpu->cyp_nelems == cpu->cyp_size) {
741 cyclic_expand(cpu);
742 ASSERT(cpu->cyp_nelems < cpu->cyp_size);
750 arg.cyx_cpu = cpu;
755 be->cyb_xcall(bar, cpu->cyp_cpu, (cyc_func_t)cyclic_add_xcall, &arg);
763 cyc_cpu_t *cpu = arg->cyx_cpu;
764 cyc_backend_t *be = cpu->cyp_backend;
766 cyc_index_t ndx = arg->cyx_ndx, nelems = cpu->cyp_nelems, i;
767 cyc_index_t *heap = cpu->cyp_heap, last;
773 mtx_lock_spin(&cpu->cyp_mtx);
774 cyclic = &cpu->cyp_cyclics[ndx];
802 cpu->cyp_nelems = --nelems;
829 cyclic_downheap(cpu, 0);
831 if (cyclic_upheap(cpu, i) == 0) {
837 cyclic_downheap(cpu, i);
847 cyclic = &cpu->cyp_cyclics[heap[0]];
852 mtx_unlock_spin(&cpu->cyp_mtx);
856 cyclic_remove_here(cyc_cpu_t *cpu, cyc_index_t ndx, cyc_time_t *when, int wait)
858 cyc_backend_t *be = cpu->cyp_backend;
865 arg.cyx_cpu = cpu;
869 be->cyb_xcall(be->cyb_arg, cpu->cyp_cpu,
878 cyc_cpu_t *cpu = malloc(sizeof(cyc_cpu_t), M_CYCLIC, M_ZERO | M_WAITOK);
887 cpu->cyp_cpu = c;
889 cpu->cyp_size = 1;
890 cpu->cyp_heap = malloc(sizeof(cyc_index_t), M_CYCLIC, M_ZERO | M_WAITOK);
891 cpu->cyp_cyclics = malloc(sizeof(cyclic_t), M_CYCLIC, M_ZERO | M_WAITOK);
892 cpu->cyp_cyclics->cy_flags = CYF_FREE;
894 mtx_init(&cpu->cyp_mtx, "cyclic cpu", NULL, MTX_SPIN);
902 cpu->cyp_backend = nbe;
911 c->cpu_cyclic = cpu;
917 cyc_cpu_t *cpu = c->cpu_cyclic;
918 cyc_backend_t *be = cpu->cyp_backend;
932 cpu->cyp_backend = NULL;
934 mtx_destroy(&cpu->cyp_mtx);
937 free(cpu->cyp_cyclics, M_CYCLIC);
938 free(cpu->cyp_heap, M_CYCLIC);
939 free(cpu, M_CYCLIC);
943 cyclic_omni_start(cyc_id_t *idp, cyc_cpu_t *cpu)
959 omni->cyo_online(omni->cyo_arg, cpu->cyp_cpu, &hdlr, &when);
964 ocpu->cyo_cpu = cpu;
966 ocpu->cyo_ndx = cyclic_add_here(cpu, &hdlr, &when, 0);
972 cyclic_omni_stop(cyc_id_t *idp, cyc_cpu_t *cpu)
981 while (ocpu != NULL && ocpu->cyo_cpu != cpu) {
1006 omni->cyo_offline(omni->cyo_arg, cpu->cyp_cpu, ocpu->cyo_arg);
1218 cyc_cpu_t *cpu;
1229 if ((cpu = c->cpu_cyclic) == NULL)
1231 cyclic_omni_start(idp, cpu);
1279 cyc_cpu_t *cpu = idp->cyi_cpu;
1283 if (cpu != NULL) {
1284 (void) cyclic_remove_here(cpu, idp->cyi_ndx, NULL, CY_WAIT);