Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1851125ybi; Mon, 1 Jul 2019 01:24:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKkK86rfV6UdW+J9wrKABECjeYj1CJYa7DXyZgZ8Shh8VhVNJtKAR4iffgUODGHEi+Qevq X-Received: by 2002:a17:902:20c8:: with SMTP id v8mr27728142plg.284.1561969440740; Mon, 01 Jul 2019 01:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561969440; cv=none; d=google.com; s=arc-20160816; b=dn4Iua4mTwVgkjTwJ9owHl2ipBrBLBXdXruBiN80Pwfmx8xA3YgixckIUBo2UmsSrj 2ZmRC04QyO0TUHpAfGGCz3CHVO5bmEWrV7R32FJ1w97A0mXO9KyX6Z/DDthljoWmf9Gp IM8ssiQLL/RkbrUxnuTWAhI+GoIfHxjcw+1KjBW+wYlwXKDt664XBiKuAbvup/HOw52M eJfOWoCX7Pifz1DyKhl8tcBq/6iRNgxa65ItKP/hfy7IloEYvO8ZZRceYafLUYVR8MAn XxYIQokFPLbs8knfOLTn+nDYbo7TAidgk1AK7OTHNNF8b9mqac3aNG/Ah0t8GvwJ36ZN va0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NtIJgEqr5a+tboLGQAt9BeVBtMYgtyvUXMLqycWKEgY=; b=t0N8dxr0il5Kbqhpra/SYr1os3+ZdCQnDbk3EXC3X2/Cy5z5pztmMCOEI6Guuvn+AO JRalz9kY7u/suDpjluPWruhgvNOa8wQ13Kiw7QpiGGFK/cmRFZggwd3tpgQIjwOlvcnB oXym7kyx93NtfF4egnRT0I5CxJEInHmvWkSrz2zAga6tZbl1WDzZz5ZK8gEu6JFR0Lf/ NyfJL2FUtY0XUzyCa2R64wFQnKb2h6vqUOBVVkJHm4ABySphSRkT2lMV96d+2qw7A4ow 3Nubl88PewD6xR0cZxvF6+7T0nneaDqBBnSceogfoWnoozSgWeyFTjud8a3iBkECtNTB E4Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NCfqCyIQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b73si9980337pjc.53.2019.07.01.01.23.44; Mon, 01 Jul 2019 01:24:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NCfqCyIQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727561AbfGAIDw (ORCPT + 99 others); Mon, 1 Jul 2019 04:03:52 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39812 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbfGAIDw (ORCPT ); Mon, 1 Jul 2019 04:03:52 -0400 Received: by mail-pl1-f195.google.com with SMTP id b7so6926404pls.6 for ; Mon, 01 Jul 2019 01:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=NtIJgEqr5a+tboLGQAt9BeVBtMYgtyvUXMLqycWKEgY=; b=NCfqCyIQ8QsnZhro5Uoc0ZBABugb4pmjelltEYnmarUlx6ffHKm8BRcFjveWujNev+ /K1ohG+I+Wt89Dozg9zWPftFA5fkZsKLkAOvSsU6wWIZLdMwiezUbMvX4RxbSNE4+6Mm bEy3+QEutTS23FxIoGR8Hsk6yL5oAaj4f9hZ/WODkeOg74aTQbZRX28sUd+Vif9gqcPs PwCk3IksHr4N6ewFI2MjjgEa9YRxbVhIaff56fwZG6bSb2co8w76x9vn/cIaCmoJTGZy YqmGKrJuZ7Xkx3mM+/jnQi07ZakK8MH5sxmGFWAGlZ8z4GzWm75gLU3k/d6ZuYxCBGzI /3RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NtIJgEqr5a+tboLGQAt9BeVBtMYgtyvUXMLqycWKEgY=; b=EFrO0WwBK9f34I/8Dd3LLNxj3i8fjN5RetPPnyfPQ6/x1umK9TN0u4qZqeQ66YIvok bR9zRWVvikAbfMM77olG25Nx6bl+83zmcoXZ6L6Asqq4d8rmfeer3hIcD5sbe81Nfzfe wt6dSmX5CXb82EAG0oNell9dCVyZCIp6HBtNYO5Evi609vTfK00z4JRGr+aClHswXnzv gINZN0fecikYX0OhoV1IOFZquWAU3TULK6YnjrW3JQVInYH7NCJe9Z1rDJLushuLed+R vIVVYqFHDW23P4iRdo4pgSWJaLMsJk8l5jOb2NYw5qBcWmPgaJglL5bQlKujcyd6fwK4 CjjA== X-Gm-Message-State: APjAAAX2E57Az3GPHeWbaTOSrGzJkD2yewqeCyb9HKUQCit226MyHbts fiAt6Y+cqCoub0odeEche2A/Ag== X-Received: by 2002:a17:902:b487:: with SMTP id y7mr27010317plr.219.1561968231789; Mon, 01 Jul 2019 01:03:51 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id 85sm12931447pfv.130.2019.07.01.01.03.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jul 2019 01:03:50 -0700 (PDT) Date: Mon, 1 Jul 2019 13:33:49 +0530 From: Viresh Kumar To: Subhra Mazumdar Cc: Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, Vincent Guittot , tkjos@google.com, Daniel Lezcano , quentin.perret@linaro.org, chris.redpath@arm.com, steven.sistare@oracle.com, songliubraving@fb.com Subject: Re: [PATCH V3 2/2] sched/fair: Fallback to sched-idle CPU if idle CPU isn't found Message-ID: <20190701080349.homlsgia4fuaitek@vireshk-i7> References: <32bd769c-b692-8896-5cc9-d19ab0a23abb@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <32bd769c-b692-8896-5cc9-d19ab0a23abb@oracle.com> User-Agent: NeoMutt/20180716-391-311a52 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28-06-19, 18:16, Subhra Mazumdar wrote: > > On 6/25/19 10:06 PM, Viresh Kumar wrote: > > We try to find an idle CPU to run the next task, but in case we don't > > find an idle CPU it is better to pick a CPU which will run the task the > > soonest, for performance reason. > > > > A CPU which isn't idle but has only SCHED_IDLE activity queued on it > > should be a good target based on this criteria as any normal fair task > > will most likely preempt the currently running SCHED_IDLE task > > immediately. In fact, choosing a SCHED_IDLE CPU over a fully idle one > > shall give better results as it should be able to run the task sooner > > than an idle CPU (which requires to be woken up from an idle state). > > > > This patch updates both fast and slow paths with this optimization. > > > > Signed-off-by: Viresh Kumar > > --- > > kernel/sched/fair.c | 43 +++++++++++++++++++++++++++++++++---------- > > 1 file changed, 33 insertions(+), 10 deletions(-) > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index 1277adc3e7ed..2e0527fd468c 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -5376,6 +5376,15 @@ static struct { > > #endif /* CONFIG_NO_HZ_COMMON */ > > +/* CPU only has SCHED_IDLE tasks enqueued */ > > +static int sched_idle_cpu(int cpu) > > +{ > > + struct rq *rq = cpu_rq(cpu); > > + > > + return unlikely(rq->nr_running == rq->cfs.idle_h_nr_running && > > + rq->nr_running); > > +} > > + > Shouldn't this check if rq->curr is also sched idle? Why wouldn't the current set of checks be enough to guarantee that ? > And why not drop the rq->nr_running non zero check? Because CPU isn't sched-idle if nr_running and idle_h_nr_running are both 0, i.e. it is an IDLE cpu in that case. And so I thought it is important to have this check as well. -- viresh