public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov@parallels.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>, Paul Turner <pjt@google.com>,
	<linux-kernel@vger.kernel.org>, <devel@openvz.org>
Subject: Re: [PATCH 2/2] sched: load_balance: Reset env when going to redo due to all pinned
Date: Mon, 16 Sep 2013 12:08:59 +0400	[thread overview]
Message-ID: <5236BC9B.8040006@parallels.com> (raw)
In-Reply-To: <20130916054301.GK21832@twins.programming.kicks-ass.net>

On 09/16/2013 09:43 AM, Peter Zijlstra wrote:
> On Sun, Sep 15, 2013 at 09:30:14PM +0400, Vladimir Davydov wrote:
>> Firstly, reset env.dst_cpu/dst_rq to this_cpu/this_rq, because it could
>> have changed in 'some pinned' case. Otherwise, should_we_balance() can
>> stop balancing beforehand.
>>
>> Secondly, reset env.flags, because it can have LBF_SOME_PINNED set.
>>
>> Thirdly, reset env.dst_grpmask cpus in env.cpus to allow handling 'some
>> pinned' case when pulling tasks from a new busiest cpu.
> Did you actually run into any problems because of this?

IRL no, and now I see that catching 'all pinned' after 'some pinned' 
case can only happen if a task changes its affinity mask or gets 
throttled during load balance run, which is very unlikely. So this patch 
is rather for sanity and can be safely dropped.

>> Signed-off-by: Vladimir Davydov<vdavydov@parallels.com>
>> ---
>>   kernel/sched/fair.c |   12 ++++++++++--
>>   1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index cd59640..d840e51 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -5289,8 +5289,16 @@ more_balance:
>>   		if (unlikely(env.flags & LBF_ALL_PINNED)) {
>>   			cpumask_clear_cpu(cpu_of(busiest), cpus);
>>   			if (!cpumask_empty(cpus)) {
>> -				env.loop = 0;
>> -				env.loop_break = sched_nr_migrate_break;
>> +				env.dst_cpu	= this_cpu;
>> +				env.dst_rq	= this_rq;
>> +				env.flags	= 0;
>> +				env.loop	= 0;
>> +				env.loop_break	= sched_nr_migrate_break;
>> +
>> +				/* Reset cpus cleared in LBF_SOME_PINNED case */
>> +				if (env.dst_grpmask)
>> +					cpumask_or(cpus, cpus, env.dst_grpmask);
>> +
>>   				goto redo;
>>   			}
>>   			goto out_balanced;
> So the problem I have with this is that it removes the bound on the
> number of iterations we do. Currently we're limited by the bits in cpus,
> but by resetting those we can do on and on and on...

find_busiest_group() never selects the local group, doesn't it? So none 
of env.dst_grpmask, which is initialized to 
sched_group_cpus(this_rq->sd), can be selected for the source cpu. That 
said, resetting env.dst_grpmask bits in the cpus bitmask actually 
doesn't affect the number of balance iterations.

  reply	other threads:[~2013-09-16  8:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-15 17:30 [PATCH 1/2] sched: load_balance: Prevent reselect prev dst_cpu if some pinned Vladimir Davydov
2013-09-15 17:30 ` [PATCH 2/2] sched: load_balance: Reset env when going to redo due to all pinned Vladimir Davydov
2013-09-16  5:43   ` Peter Zijlstra
2013-09-16  8:08     ` Vladimir Davydov [this message]
2013-09-16  8:16       ` Peter Zijlstra
2013-09-16  8:08 ` [PATCH 1/2] sched: load_balance: Prevent reselect prev dst_cpu if some pinned Peter Zijlstra
2013-09-20 13:47 ` [tip:sched/core] sched/balancing: Prevent the reselection of a previous env.dst_cpu if some tasks are pinned tip-bot for Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5236BC9B.8040006@parallels.com \
    --to=vdavydov@parallels.com \
    --cc=devel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox