mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Sistare <steven.sistare@oracle.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: subhra mazumdar <subhra.mazumdar@oracle.com>,
	linux-kernel@vger.kernel.org, mingo@redhat.com,
	dhaval.giani@oracle.com
Subject: Re: [RESEND RFC PATCH V3] sched: Improve scalability of select_idle_sibling using SMT balance
Date: Fri, 2 Feb 2018 15:51:25 -0500	[thread overview]
Message-ID: <b927a1ef-6d5f-e411-8853-f58b3cfeed2e@oracle.com> (raw)
In-Reply-To: <20180202195839.GQ2269@hirez.programming.kicks-ass.net>

On 2/2/2018 2:58 PM, Peter Zijlstra wrote:
> On Fri, Feb 02, 2018 at 12:36:47PM -0500, Steven Sistare wrote:
>> On 2/2/2018 12:17 PM, Peter Zijlstra wrote:
>>> On Fri, Feb 02, 2018 at 11:53:40AM -0500, Steven Sistare wrote:
>>>>>> +static int select_idle_smt(struct task_struct *p, struct sched_group *sg)
>>>>>>  {
>>>>>> +	int i, rand_index, rand_cpu;
>>>>>> +	int this_cpu = smp_processor_id();
>>>>>>  
>>>>>> +	rand_index = CPU_PSEUDO_RANDOM(this_cpu) % sg->group_weight;
>>>>>> +	rand_cpu = sg->cp_array[rand_index];
>>>>>
>>>>> Right, so yuck.. I know why you need that, but that extra array and
>>>>> dereference is the reason I never went there.
>>>>>
>>>>> How much difference does it really make vs the 'normal' wrapping search
>>>>> from last CPU ?
>>>>>
>>>>> This really should be a separate patch with separate performance numbers
>>>>> on.
>>>>
>>>> For the benefit of other readers, if we always search and choose starting from
>>>> the first CPU in a core, then later searches will often need to traverse the first
>>>> N busy CPU's to find the first idle CPU.  Choosing a random starting point avoids
>>>> such bias.  It is probably a win for processors with 4 to 8 CPUs per core, and
>>>> a slight but hopefully negligible loss for 2 CPUs per core, and I agree we need
>>>> to see performance data for this as a separate patch to decide.  We have SPARC
>>>> systems with 8 CPUs per core.
>>>
>>> Which is why the current code already doesn't start from the first cpu
>>> in the mask. We start at whatever CPU the task ran last on, which is
>>> effectively 'random' if the system is busy.
>>>
>>> So how is a per-cpu rotor better than that?
>>
>> The current code is:
>>         for_each_cpu(cpu, cpu_smt_mask(target)) {
>>
>> For an 8-cpu/core processor, 8 values of target map to the same cpu_smt_mask.
>> 8 different tasks will traverse the mask in the same order.
> 
> Ooh, the SMT loop.. yes that can be improved. But look at the other
> ones, they do:
> 
>   for_each_cpu_wrap(cpu, sched_domain_span(), target)
> 
> so we look for an idle cpu in the LLC domain, and start iteration at
> @target, which will (on average) be different for different CPUs, and
> thus hopefully find different idle CPUs.
> 
> You could simple change the SMT loop to something like:
> 
>   for_each_cpu_wrap(cpu, cpu_smt_mask(target), target)
> 
> and see what that does.

Good idea - Steve

  reply	other threads:[~2018-02-02 20:52 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29 23:31 subhra mazumdar
2018-02-01 12:33 ` Peter Zijlstra
2018-02-01 13:33   ` Peter Zijlstra
2018-02-02 16:53   ` Steven Sistare
2018-02-02 17:17     ` Peter Zijlstra
2018-02-02 17:36       ` Steven Sistare
2018-02-02 19:58         ` Peter Zijlstra
2018-02-02 20:51           ` Steven Sistare [this message]
2018-02-02 17:37       ` Subhra Mazumdar
2018-02-05 12:19         ` Peter Zijlstra
2018-02-05 22:09           ` Subhra Mazumdar
2018-02-06  9:12             ` Peter Zijlstra
2018-02-07  0:30               ` Subhra Mazumdar
2018-02-07  8:42                 ` Peter Zijlstra
2018-02-07 23:10                   ` Subhra Mazumdar
2018-02-02 17:21     ` Peter Zijlstra
2018-02-02 17:39       ` Steven Sistare
2018-02-02 18:34         ` Steven Sistare
2018-02-02 20:04           ` Peter Zijlstra
2018-02-02 21:17             ` Steven Sistare
2018-02-03  3:47           ` Mike Galbraith
2018-02-02 19:59     ` Peter Zijlstra
2018-02-02 21:06       ` Steven Sistare
2018-02-05 12:48         ` Peter Zijlstra
2018-02-05 13:54           ` Mike Galbraith
2018-02-05 17:03           ` Peter Zijlstra
2018-02-05 22:32             ` Subhra Mazumdar

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=b927a1ef-6d5f-e411-8853-f58b3cfeed2e@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=dhaval.giani@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=subhra.mazumdar@oracle.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

all inboxes | Powered by JetHome®