Messages in this thread | | | Subject | Re: regression introduced by - timers: fix itimer/many thread hang | From | Peter Zijlstra <> | Date | Fri, 07 Nov 2008 21:26:14 +0100 |
| |
OK, so how about going about this differently.
How about we group the threads per cpu, and appoint one the cpu-leader and collect the per cpu sum in there.
Then, on tick time we sum the cpu-leaders to obtain the total.
This would require finding the cpu-leader for any particular cpu, which for example, we could do by maintaining a rb-tree ordered on cpu. If you find an entry, its the leader and you store a pointer to it, if its empty, insert yourself.
We'd have to update this whenever a task migrates.
When the cpu-leader migrates it can hand off its sum to the cpu-leader of the target cpu (assuming there is one, otherwise it will again be cpu-leader).
The advantage is that the memory foot-print scales with nr_tasks and the runtime cost is min(nr_tasks, nr_cpus) where nr_cpus is limited to the cpus the process actually runs on, so this takes full advantage of things like cpusets.
| |