mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeffrey Hugo <jhugo@codeaurora.org>
To: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Austin Christ <austinwc@codeaurora.org>,
	Tyler Baicar <tbaicar@codeaurora.org>,
	Timur Tabi <timur@codeaurora.org>
Subject: Re: [PATCH V4 1/2] sched/fair: Fix load_balance() affinity redo path
Date: Mon, 5 Jun 2017 12:33:48 -0600	[thread overview]
Message-ID: <b391cf82-8290-5c8f-b5c7-b355ba9e6ce8@codeaurora.org> (raw)
In-Reply-To: <783f8711-0f90-9480-2b76-b1ffcf4c34a8@codeaurora.org>

On 6/5/2017 11:23 AM, Jeffrey Hugo wrote:
> On 6/2/2017 4:27 PM, Jeffrey Hugo wrote:
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index d711093..84255ab 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -6737,10 +6737,10 @@ int can_migrate_task(struct task_struct *p, 
>> struct lb_env *env)
>>            * our sched_group. We may want to revisit it if we couldn't
>>            * meet load balance goals by pulling other tasks on src_cpu.
>>            *
>> -         * Also avoid computing new_dst_cpu if we have already computed
>> -         * one in current iteration.
>> +         * Avoid computing new_dst_cpu for NEWLY_IDLE or if we have
>> +         * already computed one in current iteration.
>>            */
>> -        if (!env->dst_grpmask || (env->flags & LBF_DST_PINNED))
>> +        if (env->idle == CPU_NEWLY_IDLE || (env->flags & 
>> LBF_DST_PINNED))
>>               return 0;
> 
> Self NACK.  This breaks active_load_balance_cpu_stop().  Looks like 
> env->idle == CPU_IDLE, but env->dst_grpmask is uninitialized, so it can 
> be NULL, which causes a null pointer dereference a few lines later.
> 
> I'm still having a look to see what makes sense to address the issue.
> 
> 

As far as I can see, there appears to be two options to resolve the issue -

1. Update active_load_balance_cpu_stop() to initialize dst_grpmask to a 
sane value

2. Undo the proposed changes in load_balance() to "ensure" dst_grpmask 
is valid, and calculate the value on demand when checking to see if the 
redo path needs to be done.

The downside to #1 is that dst_grpmask is not needed in the 
active_load_balance_cpu_stop() path, and the loop to calculate a new 
dst_cpu will be used.  Extra code is evaluated, but there appears to be 
no side effects.

The downside to #2 is that dst_grpmask is valid the majority of the time 
in load_balance(), so calculating it on demand is redundant most of the 
time, but again there appears to be no side effects.

It somewhat feels like a choice of which option is less bad.

Peter/Dietmar, any preferences?

-- 
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

  reply	other threads:[~2017-06-05 18:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 22:27 [PATCH V4 0/2] load_balance() fixes for affinity Jeffrey Hugo
2017-06-02 22:27 ` [PATCH V4 1/2] sched/fair: Fix load_balance() affinity redo path Jeffrey Hugo
2017-06-05 17:23   ` Jeffrey Hugo
2017-06-05 18:33     ` Jeffrey Hugo [this message]
2017-06-06 12:30   ` Peter Zijlstra
2017-06-06 15:51     ` Jeffrey Hugo
2017-06-06 16:33     ` Peter Zijlstra
2017-06-02 22:27 ` [PATCH V4 2/2] sched/fair: Remove group imbalance from calculate_imbalance() Jeffrey Hugo

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=b391cf82-8290-5c8f-b5c7-b355ba9e6ce8@codeaurora.org \
    --to=jhugo@codeaurora.org \
    --cc=austinwc@codeaurora.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tbaicar@codeaurora.org \
    --cc=timur@codeaurora.org \
    /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

Powered by JetHome