lkml.org 
[lkml]   [2006]   [Nov]   [24]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateFri, 24 Nov 2006 13:10:33 +0300
FromPavel Emelianov <>
SubjectRe: [ckrm-tech] [PATCH 4/13] BC: context handling
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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-11-24 10:17    [from the cache]
©2003-2008