Search code examples
clinuxlinux-kernelreal-timesched-deadline

Empty function in rt.c/deadline.c in Linux Kernel


I was studying the real time scheduling algorithms inside Linux kernel and I saw that there were many function calls with literally nothing defined in them:

(on Kernel 3.15) For instance:

rt.c 1392 : dequeue_pushable_task(rq, p); 
rt.c 365  : static inline void dequeue_pushable_task(struct rq *rq, struct task_struct *p)
              {
              }


rt.c 1394 : set_post_schedule(rq);
rt.c 365  : static inline void set_post_schedule(struct rq *rq)
              {
              }

They are also redefined in the ifdef which checks for SMP. I just wanted to be sure, are these functions specific for SMP? or is there any reason for having those empty functions.


Solution

  • As per the comment at sched/deadline: Add SCHED_DEADLINE SMP-related data structures & logic 1baca4ce16b8cc7d4f50be1f7914799af30a2861 commit.

    These methods are for keeping deadline tasks in CPU specific run queues , the concept of a pushable or pullable deadline task requires that their be multiple CPU run queues to push and pull the tasks between. If CONFIG_SMP isn't set there is only one CPU run queue and hence there is no migration of tasks required.

    So yes the function implementation are specific to SMP and the reason to have those empty functions is in order to have the code compile but do nothing when CONFIG_SMP isn't defined instead of having to implement more ifdef checks at each calling site.