Esempio n. 1
0
void
percpu_init_cpu(struct cpu_info *ci)
{
    percpu_cpu_t * const pcc = cpu_percpu(ci);
    size_t size = percpu_nextoff; /* XXX racy */

    ASSERT_SLEEPABLE();
    pcc->pcc_size = size;
    if (size) {
        pcc->pcc_data = kmem_zalloc(pcc->pcc_size, KM_SLEEP);
    }
}
Esempio n. 2
0
static void
percpu_cpu_swap(void *p1, void *p2)
{
	struct cpu_info * const ci = p1;
	percpu_cpu_t * const newpcc = p2;
	percpu_cpu_t * const pcc = cpu_percpu(ci);

	KASSERT(ci == curcpu() || !mp_online);

	/*
	 * swap *pcc and *newpcc unless anyone has beaten us.
	 */
	rw_enter(&percpu_swap_lock, RW_WRITER);
	if (newpcc->pcc_size > pcc->pcc_size) {
		percpu_cpu_t tmp;
		int s;

		tmp = *pcc;

		/*
		 * block interrupts so that we don't lose their modifications.
		 */

		s = splhigh();

		/*
		 * copy data to new storage.
		 */

		memcpy(newpcc->pcc_data, pcc->pcc_data, pcc->pcc_size);

		/*
		 * this assignment needs to be atomic for percpu_getptr_remote.
		 */

		pcc->pcc_data = newpcc->pcc_data;

		splx(s);

		pcc->pcc_size = newpcc->pcc_size;
		*newpcc = tmp;
	}
	rw_exit(&percpu_swap_lock);
}
Esempio n. 3
0
void *
percpu_getptr_remote(percpu_t *pc, struct cpu_info *ci)
{

    return &((char *)cpu_percpu(ci)->pcc_data)[percpu_offset(pc)];
}