Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp227132ybd; Fri, 28 Jun 2019 18:23:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxP/9FFz46nt8WQB/0Hl0iXY7y6cPf5+9R51NzfeSbe6QAADRs5E1siNQmG30oqQ3ZmQda4 X-Received: by 2002:a63:4556:: with SMTP id u22mr12233629pgk.444.1561771434201; Fri, 28 Jun 2019 18:23:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561771434; cv=none; d=google.com; s=arc-20160816; b=JZfFdYB+Pb8kMOAUn1FFp1AcZGUiC/JexjHfBkkemW1Ik8H1GgCGydAcmONEqHhmQL cDWkqbxTxgfWRPGVQHDnRbocqKoN7LUYjqdbvp5mn/YJWCKZB0Hcpzwcqo7r4mDQHFaL O7qJxGXHEhw6nBuJcgqvgeqDJd1gM0HoqjpFgjI2E3Rv84jk42eyxnYZy3s6GCBDH3YG MBZ3NZ979yE9PE663tnCrdYaqcn+/vDEPUYukJf2MGkEjPTAaESDpyp+wt5XNUlW8BSY hK5g+jyl1bc/Pu5Ut9TDoTXGuzA/8p7iS1o3LrCBmMhtHPAhDxB6GQmg13wFNFNZxGj5 vB9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=fBGmRTkrzzmqFmPm0DXAkq8x/dtU+TebvIHnF1bOMkU=; b=0dXQQvOq5SyuOn6n7/Y2lOMDyddeep+D61L8rI+QMuB1+Wtn4NVS9Mh2RF6NwpdJ+9 AlO0/eN49UWqu9KqRprTLlhUJubn+cflxXtLn+blbNTNzGldlNoPKMjDJeSwtZACTXh0 rchMB/DgJKL3kpgA3uz4FQ4Mv9jp089bjgigFcr9sNcVa8avJTMtHLhkHuNPfVFb7V55 oii6cWYOPanqcsdLZ9SpYN9t5HwTelIp1lF41sLny01pA9lU9lmcbZBvvfnt/Jq4PqMC rVF/TGlVp6CdwK2DHOwJnApx35dNNqASVI9r9KqTWFlzdKyPLAPMKqnzu0+FDKWdpDM3 DfVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=GQ0jzzrV; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14si4060455pfr.82.2019.06.28.18.23.37; Fri, 28 Jun 2019 18:23:54 -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=@oracle.com header.s=corp-2018-07-02 header.b=GQ0jzzrV; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbfF2BWV (ORCPT + 99 others); Fri, 28 Jun 2019 21:22:21 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33962 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726643AbfF2BWV (ORCPT ); Fri, 28 Jun 2019 21:22:21 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5T1Ixaq093372; Sat, 29 Jun 2019 01:21:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=fBGmRTkrzzmqFmPm0DXAkq8x/dtU+TebvIHnF1bOMkU=; b=GQ0jzzrVlKOppRKt/M1ZZ/8kWsNAA5b6xOUPTPkXAc9SvcNnc8JaZN9R1XinKMKhi4Th 3VT7+lswdz0AGc0amxE/XqGSiq/VUrA7e4bk2+pnLQr62gt8GP5+o5giLIHqvlXEE0F3 ioFHPbZv+ayXjc1DcATePJq+1axPTJN0oFXtYHVuoSR+zDMWl4qtbxi3rZ37YRYTmJ9Y aW16wfAsPCWd/7o0b8trsV/4SYwprcL40e2AiHE8nK+BN5KvjHC2LAz9RrSt1JzT6hqA 2PS7kIPnwVtSd4dDu4vkZbyRkfLQkJNdHXHzS1glbuVyxSxwG8ljNL3se+TGpPY7Rs38 ig== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2t9c9q80m4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 29 Jun 2019 01:21:38 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5T1LXe1185556; Sat, 29 Jun 2019 01:21:38 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2tat7e7h6s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 29 Jun 2019 01:21:37 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5T1LY34029233; Sat, 29 Jun 2019 01:21:36 GMT Received: from [10.132.91.175] (/10.132.91.175) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 28 Jun 2019 18:21:34 -0700 Subject: Re: [PATCH V3 2/2] sched/fair: Fallback to sched-idle CPU if idle CPU isn't found To: Viresh Kumar , Ingo Molnar , Peter Zijlstra Cc: 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 References: From: Subhra Mazumdar Message-ID: <32bd769c-b692-8896-5cc9-d19ab0a23abb@oracle.com> Date: Fri, 28 Jun 2019 18:16:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9302 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906290012 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9302 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906290013 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? And why not drop the rq->nr_running non zero check?