Re: [ckrm-tech] [PATCH 4/13] BC: context handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've got it! That's what will work:

struct task_struct {
	...
	struct beancounter *exec_bc;
	struct beancounter *tmp_exec_bc; /* is set to NULL on
                                          * tsk creation
                                          */
};

struct beancounter get_exec_bc(void)
{
	if (current->tmp_exec_bc)
		return current->tmp_exec_bc;
	return rcu_dereference(current->exec_bc);
}


struct beancounter set_tmp_exec_bc(struct beancounter *new)
{
	struct beancounter *old;

	old = current->tmp_exec_bc;
	current->tmp_exec_bc = new;
	return old;
}

void reset_tmp_exec_bc(struct beancounter *expected_old)
{
	BUG_ON(current->tmp_exec_bc != expected_old);
	current->tmp_exec_bc = NULL;
}

void move_task(struct task_struct *tsk, struct beancounter *bc)
{
	struct beancounter *old;

	mutex_lock(&tsk_move_mutex);
	old = tsk->exec_bc;
	get_bc(bc);
	rcu_assign_pointer(current->exec_bc, bc);
	syncronize_rcu();
	mutex_unlock(&tsk_move_mutex);

	bc_put(old);
}

I will implement this in the next beancounter patches.
Thanks for discussion :)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux