0

In the Linux scheduler, each CPU has one struct rq, which contains sub-runqueues for each sched_class (CFS, RT, DL, idle). For CFS, the runqueue stores a task’s sched_entity (p->se) instead of the whole task_struct.

What is the purpose of sched_entity in CFS, and why does CFS operate on these entities rather than task_struct directly?

1
  • It keeps the source cleaner and this was done nearly 18 years ago (in the 2.6.23 kernel). Commented Aug 14 at 16:44

1 Answer 1

1

task_struct is huge and the scheduler doesn't really care at all about 90% of the fields it holds. The details in sched_entity are what the scheduler is concerned the most about. Therefore, it makes sense to only keep track of task->se. At the very least, you are saving additional math to retrieve task->se every single time you need to access it, but most importantly you are also making it clear that scheduler code dealing with sched_entity should not deal with other fields of task_struct.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.