Completely Fair Scheduler (CFS): vruntime of long running processes

If vruntime is counted from the moment a process was created, why does such a process even get a processor if it competes with a recently created process associated with a processor that is younger, say, in days?

As I read, the rule is simple: select the leftmost sheet, which is the process with the smallest runtime.

Thanks!

+4
source share
1 answer

The core documentation for CFS is what would be the answer to your question, but briefly calls it:

, .

, vruntime . .

?

min_vruntime. min_vruntime CFS (struct cfs_rq). min_vruntime vruntime rbtree. , cfs_rq.

, CFS enqueue_entity():

2998 static void
2999 enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
3000 {
3001         /*
3002          * Update the normalized vruntime before updating min_vruntime
3003          * through calling update_curr().
3004          */
3005         if (!(flags & ENQUEUE_WAKEUP) || (flags & ENQUEUE_WAKING))
3006                 se->vruntime += cfs_rq->min_vruntime;
3007 
3008         /*
3009          * Update run-time statistics of the 'current'.
3010          */
3011         update_curr(cfs_rq);
...
3031 }

update_curr(), vruntime min_vruntime :

701 static void update_curr(struct cfs_rq *cfs_rq)
702 {
703         struct sched_entity *curr = cfs_rq->curr;
...
713 
714         curr->exec_start = now;
... 
719         curr->sum_exec_runtime += delta_exec;
... 
722         curr->vruntime += calc_delta_fair(delta_exec, curr);
723         update_min_vruntime(cfs_rq);
... 
733         account_cfs_rq_runtime(cfs_rq, delta_exec);
734 }

min_vruntime update_min_vruntime():

457 static void update_min_vruntime(struct cfs_rq *cfs_rq)
458 {
459         u64 vruntime = cfs_rq->min_vruntime;
460 
461         if (cfs_rq->curr)
462                 vruntime = cfs_rq->curr->vruntime;
463 
464         if (cfs_rq->rb_leftmost) {
465                 struct sched_entity *se = rb_entry(cfs_rq->rb_leftmost,
466                                                    struct sched_entity,
467                                                    run_node);
468 
469                 if (!cfs_rq->curr)
470                         vruntime = se->vruntime;
471                 else
472                         vruntime = min_vruntime(vruntime, se->vruntime);
473         }
474 
475         /* ensure we never gain time by being placed backwards. */
476         cfs_rq->min_vruntime = max_vruntime(cfs_rq->min_vruntime, vruntime);
...
481 }

min_vruntime, , min_vruntime . ( , min_vruntime grepping "normalize" "min_vruntime" fair.c.)

, CFS- vruntime min_vruntime, , vruntime vruntime, ( , , min_vruntime .)

+7

Source: https://habr.com/ru/post/1625885/


All Articles