- 论坛徽章:
- 0
|
- /*
- * in .26
- *
- * im not sure the following `curr` must be not kthread,
- * if scheduled by cfs
- */
- static void check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
- {
- unsigned long ideal_runtime, delta_exec;
- ideal_runtime = sched_slice(cfs_rq, curr);
- delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
- if (delta_exec > ideal_runtime)
- resched_task(rq_of(cfs_rq)->curr);
- }
- static void entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
- {
- /*
- * Update run-time statistics of the 'current'.
- */
- update_curr(cfs_rq);
- #ifdef CONFIG_SCHED_HRTICK
- /*
- * queued ticks are scheduled to match the slice, so don't bother
- * validating it and just reschedule.
- */
- if (queued) {
- resched_task(rq_of(cfs_rq)->curr);
- return;
- }
- /*
- * don't let the period tick interfere with the hrtick preemption
- */
- if (!sched_feat(DOUBLE_TICK) &&
- hrtimer_active(&rq_of(cfs_rq)->hrtick_timer))
- return;
- #endif
- if (cfs_rq->nr_running > 1 || !sched_feat(WAKEUP_PREEMPT))
- check_preempt_tick(cfs_rq, curr);
- }
- /*
- * scheduler tick hitting a task of our scheduling class:
- */
- static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
- {
- struct cfs_rq *cfs_rq;
- struct sched_entity *se = &curr->se;
- for_each_sched_entity(se) {
- cfs_rq = cfs_rq_of(se);
- entity_tick(cfs_rq, se, queued);
- }
- }
- /*
- * High-resolution timer tick.
- * Runs from hardirq context with interrupts disabled.
- */
- static enum hrtimer_restart hrtick(struct hrtimer *timer)
- {
- struct rq *rq = container_of(timer, struct rq, hrtick_timer);
- WARN_ON_ONCE(cpu_of(rq) != smp_processor_id());
- spin_lock(&rq->lock);
- update_rq_clock(rq);
- rq->curr->sched_class->task_tick(rq, rq->curr, 1);
- spin_unlock(&rq->lock);
- return HRTIMER_NORESTART;
- }
- /*
- * This function gets called by the timer code, with HZ frequency.
- * We call it with interrupts disabled.
- *
- * It also gets called by the fork code, when changing the parent's timeslices.
- */
- void scheduler_tick(void)
- {
- int cpu = smp_processor_id();
- struct rq *rq = cpu_rq(cpu);
- struct task_struct *curr = rq->curr;
- sched_clock_tick();
- spin_lock(&rq->lock);
- update_rq_clock(rq);
- update_cpu_load(rq);
- curr->sched_class->task_tick(rq, curr, 0);
- spin_unlock(&rq->lock);
- #ifdef CONFIG_SMP
- rq->idle_at_tick = idle_cpu(cpu);
- trigger_load_balance(rq, cpu);
- #endif
- }
复制代码 |
|