• Muchun Song's avatar
    sched/core: Introduce set_next_task() helper for better code readability · ff1cdc94
    Muchun Song authored
    When we pick the next task, we will do the following for the task:
    
      1) p->se.exec_start = rq_clock_task(rq);
      2) dequeue_pushable(_dl)_task(rq, p);
    
    When we call set_curr_task(), we also need to do the same thing
    above. In rt.c, the code at 1) is in the _pick_next_task_rt()
    and the code at 2) is in the pick_next_task_rt(). If we put two
    operations in one function, maybe better. So, we introduce a new
    function set_next_task(), which is responsible for doing the above.
    
    By introducing the function we can get rid of calling the
    dequeue_pushable(_dl)_task() directly(We can call set_next_task())
    in pick_next_task() and have better code readability and reuse.
    In set_curr_task_rt(), we also can call set_next_task().
    
    Do this things such that we end up with:
    
      static struct task_struct *pick_next_task(struct rq *rq,
      					    struct task_struct *prev,
      					    struct rq_flags *rf)
      {
      	/* do something else ... */
    
      	put_prev_task(rq, prev);
    
      	/* pick next task p */
    
      	set_next_task(rq, p);
    
      	/* do something else ... */
      }
    
    put_prev_task() can match set_next_task(), which can make the
    code more readable.
    Signed-off-by: default avatarMuchun Song <smuchun@gmail.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/20181026131743.21786-1-smuchun@gmail.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    ff1cdc94
rt.c 63.3 KB