CFS scheduler: change vruntime of task to slow it down

I'd like to modify the cfs in a way that for a particular process id (which will be defined at runtime by sysctl or /proc filesystem) the vruntime (amount of time the task has run and index for the red-black tree of cfs) is artificially augmented so that the cfs thinks that process has run for a long time while in reality it has run for, let's say, half that time..

I want to achieve the goad of having to identical processes that normally use 50% each of the cpu, and make them use for example 10% and 90%...

ideas? If I just go and edit vruntime then the red-black tree would mess up, what function should be used to adjust the vruntime of a task in sched_entity?


You Don't need to do it in the kernel.(Your final goal is not to cheat the cfs). If I understood, you need to make a particular process running with lower CPU usages.

  • You can start the particular process with lower scheduling priority.

    nice -n 10 your_process arguments

    You can type `man nice' to get more information

  • If you can change the code of the particular process, you can use nice() in the code. Also you can type man 2 nice to get more information

  • You can use cgroup/cpu to achieve it.

    mount -t cgroup -ocpu cgroup /cgroup

    And then use it.

  • I suggest the first one.

    Finally, if you stick in kernel, you can try to use __dequeue_entity() to dequeue the entity and change the vruntime and then use __enqueue_entity() to insert it back. It is just a hint, it may be wrong, no one like suck hack, it is not my answer.

    链接地址: http://www.djcxy.com/p/84874.html

    上一篇: 如何在MVC4 C#中安排任务?

    下一篇: CFS调度程序:更改任务的vruntime以减慢速度