sched: At sched_fork use __set_task_cpu().
PATCH 1/1 sched: At sched_fork use __set_task_cpu().
We don't use select_task_rq() from sched_fork() anymore and no chance of task gets migrated at
this point. Therefore, we can avoid task migration related checking/accounting, so use __set_task_cpu() instead of set_task_cpu().
---
kernel/sched/core.c +1 -1
@@ -1755,7 +1755,7 @@ void sched_fork(struct task_struct *p)* Silence PROVE_RCU. */ raw_spin_lock_irqsave (&p->pi_lock, flags); -set_task_cpu (p, cpu); +__set_task_cpu (p, cpu);raw_spin_unlock_irqrestore (&p->pi_lock, flags);#if defined(CONFIG_SCHEDSTATS ) || defined(CONFIG_TASK_DELAY_ACCT )
Quoted 5 lines · Rakib Mullick
We don't use
select_task_rq()fromsched_fork()anymore and no chance of task gets migrated at
this point. Therefore, we can avoid task migration related checking/accounting, so use__set_task_cpu()instead ofset_task_cpu().Signed-off-by Rakib Mullick <[email protected]>
Quoted 18 lines
---
kernel/sched/core.c +1
-2@@ -1755,7 +1755,7 @@ void sched_fork(struct task_struct *p)* Silence PROVE_RCU. */ raw_spin_lock_irqsave (&p->pi_lock, flags); -set_task_cpu (p, cpu); +__set_task_cpu (p, cpu);raw_spin_unlock_irqrestore (&p->pi_lock, flags);#if defined(CONFIG_SCHEDSTATS ) || defined(CONFIG_TASK_DELAY_ACCT ) --
Quoted 8 lines · Kamalesh Babulal
Quoted 5 lines · Rakib Mullick
We don't use
select_task_rq()fromsched_fork()anymore and no chance of task gets migrated at
this point. Therefore, we can avoid task migration related checking/accounting, so use__set_task_cpu()instead ofset_task_cpu().Signed-off-by Rakib Mullick <[email protected]>Reviewed-by Kamalesh Babulal <[email protected]>
Since we call sched_fork() with preemption enabled _long_ after the child is copied from the parent who is to say we (parent) didn't migrate away and are now setting a different cpu?
One could argue that that might not be a real migration from the child's POV, maybe, but nobody seems to be making that argument.
I really don't see the point of this..
Quoted 19 lines
Quoted 18 lines
---
kernel/sched/core.c +1
-2@@ -1755,7 +1755,7 @@ void sched_fork(struct task_struct *p)* Silence PROVE_RCU. */ raw_spin_lock_irqsave (&p->pi_lock, flags); -set_task_cpu (p, cpu); +__set_task_cpu (p, cpu);raw_spin_unlock_irqrestore (&p->pi_lock, flags);#if defined(CONFIG_SCHEDSTATS ) || defined(CONFIG_TASK_DELAY_ACCT ) --
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Kamalesh Babulal
Quoted 4 lines · Rakib Mullick
We don't use
select_task_rq()fromsched_fork()anymore and no chance of task gets migrated at this point. Therefore, we can avoid task migration related checking/accounting, so use__set_task_cpu()instead ofset_task_cpu().
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Rakib Mullick <[email protected]>Reviewed-by Kamalesh Babulal <[email protected]>Since we call
sched_fork()with preemption enabled _long_ after the child is copied from the parent who is to say we (parent) didn't migrate away and are now setting a different cpu?
If parent gets migrated that should be accounted as parents migration count not for child offcourse. And if we're counting child's nr_migration count for parent's getting migrated, we're simply screwing childs migration count. Isn't it?
Quoted 3 lines
One could argue that that might not be a real migration from the child's POV, maybe, but nobody seems to be making that argument.
But I'm not seeing it from child's or parent's POV. I'm simply addressing the point of a task's migration counter (p->se.nr_migrations), simply this task wasn't moved.
Quoted 2 lines
I really don't see the point of this..
I'm hoping, you'll rethink...
Thanks,
Rakib