sched_info_arrive()

本文介绍了一个内核级的进程调度统计方法,通过跟踪进程在就绪队列中的等待时间来评估进程调度效率。具体实现包括记录进程加入就绪队列的时间、计算每次调度延迟以及更新相关计数器。
进程t即将获得CPU控制权
汇总进程t在可执行队列上所等候时间的综合;更新进程t获得CPU控制权的时间戳
static inline void sched_info_arrive(task_t *t)
{
    unsigned long now = jiffies, diff = 0;
    struct runqueue *rq = task_rq(t);

    if (t->sched_info.last_queued)
        diff = now - t->sched_info.last_queued;
    sched_info_dequeued(t);
    t->sched_info.run_delay += diff;
    t->sched_info.last_arrival = now;
    t->sched_info.pcnt++;

    if (!rq)
        return;

    rq->rq_sched_info.run_delay += diff;
    rq->rq_sched_info.pcnt++;
}
task_struct.sched_info.last_queued        
    when we were last queued to run(最近一次加入runqueue的时间)
task_struct.sched_info.run_delay        
    time spent waiting on a runqueue(每一次进入runqueue到得到CPU控制权的时间间隔的总和)
task_struct.sched_info.pcnt                
    # of timeslices run on this cpu







这个函数干了啥,它有因为while太久而触发软死锁判断的可能吗?/* * Generic idle loop implementation * * Called with polling cleared. */ static void cpu_idle_loop(void) { while (1) { /* * If the arch has a polling bit, we maintain an invariant: * * Our polling bit is clear if we're not scheduled (i.e. if * rq->curr != rq->idle). This means that, if rq->idle has * the polling bit set, then setting need_resched is * guaranteed to cause the cpu to reschedule. */ __current_set_polling(); #if defined CONFIG_BCM_KF_INTERACTIVE && defined CONFIG_CPU_FREQ_GOV_INTERACTIVE idle_notifier_call_chain(IDLE_START); #endif tick_nohz_idle_enter(); while (!need_resched()) { check_pgt_cache(); rmb(); if (cpu_is_offline(smp_processor_id())) { rcu_cpu_notify(NULL, CPU_DYING_IDLE, (void *)(long)smp_processor_id()); smp_mb(); /* all activity before dead. */ this_cpu_write(cpu_dead_idle, true); arch_cpu_idle_dead(); } local_irq_disable(); arch_cpu_idle_enter(); /* * In poll mode we reenable interrupts and spin. * * Also if we detected in the wakeup from idle * path that the tick broadcast device expired * for us, we don't want to go deep idle as we * know that the IPI is going to arrive right * away */ if (cpu_idle_force_poll || tick_check_broadcast_expired()) cpu_idle_poll(); else cpuidle_idle_call(); arch_cpu_idle_exit(); } /* * Since we fell out of the loop above, we know * TIF_NEED_RESCHED must be set, propagate it into * PREEMPT_NEED_RESCHED. * * This is required because for polling idle loops we will * not have had an IPI to fold the state for us. */ preempt_set_need_resched(); tick_nohz_idle_exit(); #if defined CONFIG_BCM_KF_INTERACTIVE && defined CONFIG_CPU_FREQ_GOV_INTERACTIVE idle_notifier_call_chain(IDLE_END); #endif __current_clr_polling(); /* * We promise to call sched_ttwu_pending and reschedule * if need_resched is set while polling is set. That * means that clearing polling needs to be visible * before doing these things. */ smp_mb__after_atomic(); sched_ttwu_pending(); schedule_preempt_disabled(); } }
最新发布
09-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值