From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933357AbbGJVAm (ORCPT ); Fri, 10 Jul 2015 17:00:42 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:15131 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932532AbbGJVAd (ORCPT ); Fri, 10 Jul 2015 17:00:33 -0400 Message-ID: <55A03232.2090500@fb.com> Date: Fri, 10 Jul 2015 16:59:30 -0400 From: Josef Bacik User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Mike Galbraith , Peter Zijlstra CC: , , , , kernel-team Subject: Re: [patch] sched: beef up wake_wide() References: <1436025462.17152.37.camel@gmail.com> <1436080661.22930.22.camel@gmail.com> <1436159590.5850.27.camel@gmail.com> <559A91F4.7000903@fb.com> <1436207790.2940.30.camel@gmail.com> <559AD9CE.4090309@fb.com> <1436241678.1836.29.camel@gmail.com> <1436262224.1836.74.camel@gmail.com> <559C0700.6090009@fb.com> <1436336026.3767.53.camel@gmail.com> <20150709132654.GE3644@twins.programming.kicks-ass.net> <1436505566.5715.50.camel@gmail.com> In-Reply-To: <1436505566.5715.50.camel@gmail.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151,1.0.33,0.0.0000 definitions=2015-07-10_10:2015-07-10,2015-07-10,1970-01-01 signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/10/2015 01:19 AM, Mike Galbraith wrote: > On Thu, 2015-07-09 at 15:26 +0200, Peter Zijlstra wrote: >> On Wed, Jul 08, 2015 at 08:13:46AM +0200, Mike Galbraith wrote: >>> static int wake_wide(struct task_struct *p) >>> { >>> + unsigned int waker_flips = current->wakee_flips; >>> + unsigned int wakee_flips = p->wakee_flips; >>> int factor = this_cpu_read(sd_llc_size); >>> >>> + if (waker_flips < wakee_flips) >>> + swap(waker_flips, wakee_flips); >> >> This makes the wakee/waker names useless, the end result is more like >> wakee_flips := client_flips, waker_flips := server_flips. > > I settled on master/slave plus hopefully improved comment block. > >>> + if (wakee_flips < factor || waker_flips < wakee_flips * factor) >>> + return 0; >> >> I don't get the first condition... why would the client ever flip? It >> only talks to that one server. > > (tightening heuristic up a bit by one means or another would be good, > but "if it ain't broke, don't fix it" applies for this patchlet) > >>> @@ -5021,14 +5015,17 @@ select_task_rq_fair(struct task_struct * >>> { >>> struct sched_domain *tmp, *affine_sd = NULL, *sd = NULL; >>> int cpu = smp_processor_id(); >>> + int new_cpu = prev_cpu; >>> int want_affine = 0; >>> int sync = wake_flags & WF_SYNC; >>> >>> rcu_read_lock(); >>> + if (sd_flag & SD_BALANCE_WAKE) { >>> + want_affine = !wake_wide(p) && cpumask_test_cpu(cpu, tsk_cpus_allowed(p)); >>> + if (!want_affine) >>> + goto select_idle; >>> + } >> >> So this preserves/makes worse the bug Morten spotted, even without >> want_affine we should still attempt SD_BALANCE_WAKE if set. > > Fixed. wake_wide() may override want_affine as before, want_affine may > override other ->flags as before, but a surviving domain selection now > results in a full balance instead of a select_idle_sibling() call. > > sched: beef up wake_wide() > > Josef Bacik reported that Facebook sees better performance with their > 1:N load (1 dispatch/node, N workers/node) when carrying an old patch > to try very hard to wake to an idle CPU. While looking at wake_wide(), > I noticed that it doesn't pay attention to the wakeup of a many partner > waker, returning 1 only when waking one of its many partners. > > Correct that, letting explicit domain flags override the heuristic. > > While at it, adjust task_struct bits, we don't need a 64bit counter. > > Signed-off-by: Mike Galbraith > Tested-by: Josef Bacik Not quite as awesome but still better than the baseline so we're good. Thanks, Josef