--- ./kernel/sched.c.schedx	2006-04-21 16:37:42.000000000 +0400
+++ ./kernel/sched.c	2006-05-22 11:31:55.000000000 +0400
@@ -1654,8 +1654,9 @@ void fastcall sched_fork(task_t *p)
 void fastcall wake_up_forked_process(task_t * p)
 {
 	unsigned long flags;
-	runqueue_t *rq = task_rq_lock(current, &flags);
+	runqueue_t *rq;
 
+	rq = task_rq_lock(p, &flags);
 	BUG_ON(p->state != TASK_RUNNING);
 	BUG_ON(task_vsched(current) != task_vsched(p));
 
@@ -1664,17 +1665,12 @@ void fastcall wake_up_forked_process(tas
 	 * and children as well, to keep max-interactive tasks
 	 * from forking tasks that are max-interactive.
 	 */
-	current->sleep_avg = JIFFIES_TO_NS(CURRENT_BONUS(current) *
-		PARENT_PENALTY / 100 * MAX_SLEEP_AVG / MAX_BONUS);
-
 	p->sleep_avg = JIFFIES_TO_NS(CURRENT_BONUS(p) *
 		CHILD_PENALTY / 100 * MAX_SLEEP_AVG / MAX_BONUS);
 
 	p->interactive_credit = 0;
 
 	p->prio = effective_prio(p);
-	set_task_pcpu(p, task_pcpu(current));
-	set_task_vcpu(p, this_vcpu());
 
 	if (unlikely(!current->array))
 		__activate_task(p, rq);
@@ -1687,6 +1683,12 @@ void fastcall wake_up_forked_process(tas
 		nr_running_inc(smp_processor_id(), task_cpu(p),
 				VE_TASK_INFO(p)->owner_env);
 	}
+	if (unlikely(task_vcpu(p) != this_vcpu())) {
+		task_rq_unlock(rq, &flags);
+		rq = task_rq_lock(current, &flags);
+	}
+	current->sleep_avg = JIFFIES_TO_NS(CURRENT_BONUS(current) *
+		PARENT_PENALTY / 100 * MAX_SLEEP_AVG / MAX_BONUS);
 	task_rq_unlock(rq, &flags);
 }
 
