Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1211292 > unrolled thread

[PATCH,RFC] sched: fix "impossible" load balancing oops

Started byRik van Riel <riel@redhat.com>
First post2015-08-21 20:30 +0200
Last post2015-08-25 20:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH,RFC] sched: fix "impossible" load balancing oops Rik van Riel <riel@redhat.com> - 2015-08-21 20:30 +0200
    Re: [PATCH,RFC] sched: fix "impossible" load balancing oops Peter Zijlstra <peterz@infradead.org> - 2015-08-25 12:20 +0200
      Re: [PATCH,RFC] sched: fix "impossible" load balancing oops Rik van Riel <riel@redhat.com> - 2015-08-25 20:10 +0200

#1211292 — [PATCH,RFC] sched: fix "impossible" load balancing oops

FromRik van Riel <riel@redhat.com>
Date2015-08-21 20:30 +0200
Subject[PATCH,RFC] sched: fix "impossible" load balancing oops
Message-ID<pZZeF-3cy-7@gated-at.bofh.it>
The load balancing code can run into the situation where
the source and destination runqueues are the same, in
the active balancing code.

        /*
         * This condition is "impossible", if it occurs
         * we need to fix it. Originally reported by
         * Bjorn Helgaas on a 128-cpu setup.
         */
        BUG_ON(busiest_rq == target_rq);

This happens despite not triggering the BUG_ON(busiest == env.dst_rq)
line after find_busiest_queue.

From code inspection, it appears there is a condition where this can happen.

Specifically, if we encounter only pinned tasks on a CPU, can_migrate_task
will set env->new_dst_cpu to a CPU in the env->dst_grpmask.  If the group
includes the source cpu, we may end up setting env.dst_cpu to the same
as dst.src_cpu.

The fix would be to clear the source cpu from env.dst_grpmask, to ensure
we never select the source cpu as the destination.

Signed-off-by: Rik van Riel <riel@redhat.com>
---
 kernel/sched/fair.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d113c3b..514a369 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7172,6 +7172,8 @@ redo:
 	env.src_cpu = busiest->cpu;
 	env.src_rq = busiest;
 
+	cpumask_clear_cpu(busiest->cpu, env.dst_grpmask);
+
 	ld_moved = 0;
 	if (busiest->nr_running > 1) {
 		/*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1212933

FromPeter Zijlstra <peterz@infradead.org>
Date2015-08-25 12:20 +0200
Message-ID<q1juF-3vj-15@gated-at.bofh.it>
In reply to#1211292
On Fri, Aug 21, 2015 at 02:21:22PM -0400, Rik van Riel wrote:
> The load balancing code can run into the situation where
> the source and destination runqueues are the same, in
> the active balancing code.
> 
>         /*
>          * This condition is "impossible", if it occurs
>          * we need to fix it. Originally reported by
>          * Bjorn Helgaas on a 128-cpu setup.
>          */
>         BUG_ON(busiest_rq == target_rq);
> 
> This happens despite not triggering the BUG_ON(busiest == env.dst_rq)
> line after find_busiest_queue.
> 
> From code inspection, it appears there is a condition where this can happen.
> 
> Specifically, if we encounter only pinned tasks on a CPU, can_migrate_task
> will set env->new_dst_cpu to a CPU in the env->dst_grpmask.  If the group
> includes the source cpu, we may end up setting env.dst_cpu to the same
> as dst.src_cpu.
> 
> The fix would be to clear the source cpu from env.dst_grpmask, to ensure
> we never select the source cpu as the destination.
> 
> Signed-off-by: Rik van Riel <riel@redhat.com>
> ---
>  kernel/sched/fair.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index d113c3b..514a369 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7172,6 +7172,8 @@ redo:
>  	env.src_cpu = busiest->cpu;
>  	env.src_rq = busiest;
>  
> +	cpumask_clear_cpu(busiest->cpu, env.dst_grpmask);
> +
>  	ld_moved = 0;
>  	if (busiest->nr_running > 1) {
>  		/*

Right, so real problem 'recently' introduced by:

  88b8dac0a14c ("sched: Improve balance_cpu() to consider other cpus in its group as target of (pinned) task")

But I think there's a wee problem with the solution, if I'm not still
entirely asleep, it appears dst_grpmask might be NULL in case of
CPU_NEWLY_IDLE, which would make that cpumask_clear_cpu() do something
naughty.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1213213

FromRik van Riel <riel@redhat.com>
Date2015-08-25 20:10 +0200
Message-ID<q1qPw-5Lv-27@gated-at.bofh.it>
In reply to#1212933
On 08/25/2015 06:19 AM, Peter Zijlstra wrote:
> On Fri, Aug 21, 2015 at 02:21:22PM -0400, Rik van Riel wrote:
>> The load balancing code can run into the situation where
>> the source and destination runqueues are the same, in
>> the active balancing code.
>>
>>         /*
>>          * This condition is "impossible", if it occurs
>>          * we need to fix it. Originally reported by
>>          * Bjorn Helgaas on a 128-cpu setup.
>>          */
>>         BUG_ON(busiest_rq == target_rq);
>>
>> This happens despite not triggering the BUG_ON(busiest == env.dst_rq)
>> line after find_busiest_queue.
>>
>> From code inspection, it appears there is a condition where this can happen.
>>
>> Specifically, if we encounter only pinned tasks on a CPU, can_migrate_task
>> will set env->new_dst_cpu to a CPU in the env->dst_grpmask.  If the group
>> includes the source cpu, we may end up setting env.dst_cpu to the same
>> as dst.src_cpu.
>>
>> The fix would be to clear the source cpu from env.dst_grpmask, to ensure
>> we never select the source cpu as the destination.
>>
>> Signed-off-by: Rik van Riel <riel@redhat.com>
>> ---
>>  kernel/sched/fair.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index d113c3b..514a369 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -7172,6 +7172,8 @@ redo:
>>  	env.src_cpu = busiest->cpu;
>>  	env.src_rq = busiest;
>>  
>> +	cpumask_clear_cpu(busiest->cpu, env.dst_grpmask);
>> +
>>  	ld_moved = 0;
>>  	if (busiest->nr_running > 1) {
>>  		/*
> 
> Right, so real problem 'recently' introduced by:
> 
>   88b8dac0a14c ("sched: Improve balance_cpu() to consider other cpus in its group as target of (pinned) task")
> 
> But I think there's a wee problem with the solution, if I'm not still
> entirely asleep, it appears dst_grpmask might be NULL in case of
> CPU_NEWLY_IDLE, which would make that cpumask_clear_cpu() do something
> naughty.

Ahhh, so that's what I've been seeing!

Also, I am not sure that find_busiest_group will actually return the
group the CPU is in, so the patch may be wrong in another way too.

I have yet to wrap my head around the sd & sg stuff (again), to figure
out that bit...
-- 
All rights reversed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web