Re: [PATCH 00/10] steal tasks to improve CPU utilization

From: Steven Sistare
Date: Mon Oct 22 2018 - 15:07:59 EST


On 10/22/2018 1:04 PM, Peter Zijlstra wrote:
> On Mon, Oct 22, 2018 at 07:59:31AM -0700, Steve Sistare wrote:
>> When a CPU has no more CFS tasks to run, and idle_balance() fails to
>> find a task, then attempt to steal a task from an overloaded CPU in the
>> same LLC. Maintain and use a bitmap of overloaded CPUs to efficiently
>> identify candidates. To minimize search time, steal the first migratable
>> task that is found when the bitmap is traversed. For fairness, search
>> for migratable tasks on an overloaded CPU in order of next to run.
>>
>> This simple stealing yields a higher CPU utilization than idle_balance()
>> alone, because the search is cheap, so it may be called every time the CPU
>> is about to go idle. idle_balance() does more work because it searches
>> widely for the busiest queue, so to limit its CPU consumption, it declines
>> to search if the system is too busy. Simple stealing does not offload the
>> globally busiest queue, but it is much better than running nothing at all.
>
> Why I don't dislike the idea; I feel it is unfortunate to have two
> different mechanisms to do effectively the same thing.
>
> Can't we improve idle_balance() instead of building this parallel
> functionality?

We could delete idle_balance() and use stealing exclusively for handling
new idle. For each sd level, stealing would look for an overloaded CPU
in the overloaded bitmap(s) that overlap that level. I played with that
a little but it is not ready for prime time, and I did not want to hold
the patch series for it. Also, I would like folks to get some production
experience with stealing on a variety of architectures before considering
a radical step like replacing idle_balance().

We could merge the stealing code into the idle_balance() code to get a
union of the two, but IMO that would be less readable.

We could remove the core and socket levels from idle_balance() and let
stealing handle those levels. I think that makes sense after stealing
performance is validated on more architectures, but we would still have
two different mechanisms.

- Steve