/*
* 1 . 我们添加一个 tracepoint 来看下该函数的执行通路
* 2 . 该函数在设计的时候做了怎么样的考虑
* 3 . 该函数可以优化的地方
* 4 . 实验验证.
*/
/*
* 该函数的唯一调用者是 copy_process(). 我们先来看下它的参数,然后再看它的执行通路.
* @p
* copy_process() {
* dup_task_struct() {
* alloc_task_struct_node()
* .....
* }
* }
*/
int sched_fork(unsigned long clone_flags, struct task_struct *p)
{
__sched_fork(clone_flags, p);
}
static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
{
p->on_rq = 0;
p->se.on_rq = 0;
p->se.exec_start = 0;
p->se.sum_exec_runtime = 0;
p->se.prev_sum_exec_runtime = 0;
p->se.nr_migrations = 0;
p->se.vruntime = 0;
INIT_LIST_HEAD(&p->se.group_node);
p->se.cfs_rq = NULL;
/* Even if schedstat is disabled, there should not be garbage */
memset(&p->se.statistics, 0, sizeof(p->se.statistics));
RB_CLEAR_NODE(&p->dl.rb_node);
init_dl_task_timer(&p->dl);
init_dl_inactive_task_timer(&p->dl);
__dl_clear_params(p);
INIT_LIST_HEAD(&p->rt.run_list);
p->rt.timeout = 0;
p->rt.time_slice = sched_rr_timeslice;
p->rt.on_rq = 0;
p->rt.on_list = 0;
INIT_HLIST_HEAD(&p->preempt_notifiers);
p->capture_control = NULL;
init_numa_balancing(clone_flags, p);
p->wake_entry.u_flags = CSD_TYPE_TTWU;
}