Your Location is: Home > Linux-kernel

Why is the run queue of Completely Fair Scheduler in linux kernel always null for my process?

From: Dublin View: 4404 Dev Rajput 

Question

For an assignment for my OS course, I need to modify the CFS scheduler of Linux kernel 5.9. I figured out that to complete the objective of the assignment I needed to modify how the scheduler adds processes to its run queue which is a rbtree. This is done in the function __enqueue_entity() which calls the function entity_before() in its while loop.

static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
{
    struct rb_node **link = &cfs_rq->tasks_timeline.rb_root.rb_node;
    struct rb_node *parent = NULL;
    struct sched_entity *entry;
    bool leftmost = true;
    /*
     * Find the right place in the rbtree:
     */
    while (*link) {
        parent = *link;
        entry = rb_entry(parent, struct sched_entity, run_node);
        /*
         * We dont care about collisions. Nodes with
         * the same key stay together.
         */
        if (entity_before(se, entry)) {
            link = &parent->rb_left;
        } else {
            link = &parent->rb_right;
            leftmost = false;
        }
    }
    if(se->rt_timeslice>0){
        printk(KERN_ERR"inside enqueue_entity below the while loop");
    }
    rb_link_node(&se->run_node, parent, link);
    rb_insert_color_cached(&se->run_node,
                   &cfs_rq->tasks_timeline, leftmost);
}

The problem is that the while loop never runs when my process in this scheduler. I used a bunch of printk()s to all the function in the scheduler routine to track my process, and apparently it reaches the __enqueue_entity() function but whenever the function runs for my process the while loop is not run and I can't understand why is this happening?

Best answer