323 ASSERT(MUTEX_HELD(&cpu_lock));
324
325 disp_mem = kmem_zalloc(NCPU *
326 sizeof (struct disp_queue_info), KM_SLEEP);
327
328 /*
329 * This routine must allocate all of the memory before stopping
330 * the cpus because it must not sleep in kmem_alloc while the
331 * CPUs are stopped. Locks they hold will not be freed until they
332 * are restarted.
333 */
334 i = 0;
335 cpup = cpu_list;
336 do {
337 disp_dq_alloc(&disp_mem[i], numpris, cpup->cpu_disp);
338 i++;
339 cpup = cpup->cpu_next;
340 } while (cpup != cpu_list);
341 num = i;
342
343 pause_cpus(NULL);
344 for (i = 0; i < num; i++)
345 disp_dq_assign(&disp_mem[i], numpris);
346 start_cpus();
347
348 /*
349 * I must free all of the memory after starting the cpus because
350 * I can not risk sleeping in kmem_free while the cpus are stopped.
351 */
352 for (i = 0; i < num; i++)
353 disp_dq_free(&disp_mem[i]);
354
355 kmem_free(disp_mem, NCPU * sizeof (struct disp_queue_info));
356 }
357
358 static void
359 disp_dq_alloc(struct disp_queue_info *dptr, int numpris, disp_t *dp)
360 {
361 dptr->newdispq = kmem_zalloc(numpris * sizeof (dispq_t), KM_SLEEP);
362 dptr->newdqactmap = kmem_zalloc(((numpris / BT_NBIPUL) + 1) *
363 sizeof (long), KM_SLEEP);
|
323 ASSERT(MUTEX_HELD(&cpu_lock));
324
325 disp_mem = kmem_zalloc(NCPU *
326 sizeof (struct disp_queue_info), KM_SLEEP);
327
328 /*
329 * This routine must allocate all of the memory before stopping
330 * the cpus because it must not sleep in kmem_alloc while the
331 * CPUs are stopped. Locks they hold will not be freed until they
332 * are restarted.
333 */
334 i = 0;
335 cpup = cpu_list;
336 do {
337 disp_dq_alloc(&disp_mem[i], numpris, cpup->cpu_disp);
338 i++;
339 cpup = cpup->cpu_next;
340 } while (cpup != cpu_list);
341 num = i;
342
343 pause_cpus(NULL, NULL);
344 for (i = 0; i < num; i++)
345 disp_dq_assign(&disp_mem[i], numpris);
346 start_cpus();
347
348 /*
349 * I must free all of the memory after starting the cpus because
350 * I can not risk sleeping in kmem_free while the cpus are stopped.
351 */
352 for (i = 0; i < num; i++)
353 disp_dq_free(&disp_mem[i]);
354
355 kmem_free(disp_mem, NCPU * sizeof (struct disp_queue_info));
356 }
357
358 static void
359 disp_dq_alloc(struct disp_queue_info *dptr, int numpris, disp_t *dp)
360 {
361 dptr->newdispq = kmem_zalloc(numpris * sizeof (dispq_t), KM_SLEEP);
362 dptr->newdqactmap = kmem_zalloc(((numpris / BT_NBIPUL) + 1) *
363 sizeof (long), KM_SLEEP);
|