Received: by 2002:a17:90a:b81:0:0:0:0 with SMTP id 1csp993601pjr; Fri, 30 Aug 2019 10:57:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOVMISZ66D+3SHFltW3IqaNs5kHOrhcRLocyAMPVucbKiiSMdeEUCr9LCGCxg8macgZeFi X-Received: by 2002:a62:2a55:: with SMTP id q82mr16126198pfq.23.1567187821866; Fri, 30 Aug 2019 10:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567187821; cv=none; d=google.com; s=arc-20160816; b=IXT1O78coV4avPvoRvusL0Ni6WXbw/m/xkW9wtfsGumMPji98uy/agh4XU3nsY1y1a KjnUURLmfKlWiai2ZxR/0AJ9bNI5lpg2a3fi4IP+kPrjN7e2v/2t244yWTcUpGCJx4kT duZ1PG93WxlzTc/mM/kgNOUiAjXroh2RJ3y6gN5+72RNxuoeojrpyyyKRP71gguemjiE EkJqFRfa66qmvR/2gFgAtcSVFZTyWhBGqw8s6TlOSq4VQkvlay9tVpWwbnvtJUyRRGwk /mWH/udWh9TFg2AREg2w0ZoqZu83ZEUtlXoBH4mvP/aOPJd8q/yQ+nLmMU0HwM5P7BNi 0t6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=6TBcR3z4xqJM0wmVaFettciFd952rvhR5dlqXaUUv48=; b=BP08zD2SeDVzhuKrRaUti0rXhbpgaxW/elCvmK+x+ihQWKaDrY2vwPOnUg92sK/DYZ M5uyv5Y35EW/AmjwiMWlAEy4KXGLaqRr94orJfbWVW3NH4l+tmlZpMnaL0nSPi/jj1v3 iuf4H03vCP9HvgRyazKLgZde+PYLH+TiDFja48U9JcuKZaD725WAuSyUv8dLUczRvWzi vsn5iGshZrlM/cYj/7DNg4NAbFqQL9FIoscw1jC8DrwgFCHL4jR2t2dFSGgchy5bdSZR 4dZNe0hA/91c00jwtcyiVs1injV6Nl6Mxt9Rdp0+IBKGJgTVx+baGI2qS19hozkqz4XJ M1Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=fYPRu+zT; 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 g14si6826095pfk.149.2019.08.30.10.56.47; Fri, 30 Aug 2019 10:57:01 -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-2019-08-05 header.b=fYPRu+zT; 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 S1728217AbfH3Rz5 (ORCPT + 99 others); Fri, 30 Aug 2019 13:55:57 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34208 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727924AbfH3Rzx (ORCPT ); Fri, 30 Aug 2019 13:55:53 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7UHt6tF088742; Fri, 30 Aug 2019 17:55:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=6TBcR3z4xqJM0wmVaFettciFd952rvhR5dlqXaUUv48=; b=fYPRu+zTGJ1MuIYtr3IP9HHd/y+sL77rcRmIEjdZYMC/ykGbXKLTiTwcfl/wOC2prheE B55JjDXKYRtfBKaeMmakP3xNXm1AbLmcDyxvsDx+PIZ6CJpq2O5H2KdHylfTbzHMsVom kiGRCBrrOGx3mAv46rTtuSP3XEgbWDmsZqRgHrEr2w9mLR4baCsSw+UK5r8a05WUXMsl xmPdhUriKDJ2Cg0oPbe755VURCkZSyhj39853j/AtGNSwIj2F8BCizvL5ZtgoH/wsO30 MdZtlsSWVd/MuA9qu+N9NIRP8InO8rDcum0S1kD0sBtRh7rcwFHD8sBa5z3hjsJSJVRs Xw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2uq8fsg22t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2019 17:55:11 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7UHrdbw017994; Fri, 30 Aug 2019 17:54:39 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2upxabkvum-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Aug 2019 17:54:39 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7UHscpH014866; Fri, 30 Aug 2019 17:54:38 GMT Received: from smazumda-Precision-T1600.us.oracle.com (/10.132.91.113) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 30 Aug 2019 10:54:38 -0700 From: subhra mazumdar To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, tglx@linutronix.de, steven.sistare@oracle.com, dhaval.giani@oracle.com, daniel.lezcano@linaro.org, vincent.guittot@linaro.org, viresh.kumar@linaro.org, tim.c.chen@linux.intel.com, mgorman@techsingularity.net, parth@linux.ibm.com, patrick.bellasi@arm.com Subject: [RFC PATCH 9/9] sched: rotate the cpu search window for better spread Date: Fri, 30 Aug 2019 10:49:44 -0700 Message-Id: <20190830174944.21741-10-subhra.mazumdar@oracle.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20190830174944.21741-1-subhra.mazumdar@oracle.com> References: <20190830174944.21741-1-subhra.mazumdar@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9365 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=912 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908300174 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9365 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=970 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908300174 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rotate the cpu search window for better spread of threads. This will ensure an idle cpu will quickly be found if one exists. Signed-off-by: subhra mazumdar --- kernel/sched/fair.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 94dd4a32..7419b47 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6188,7 +6188,7 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t u64 avg_cost, avg_idle; u64 time, cost; s64 delta; - int cpu, floor, nr = INT_MAX; + int cpu, floor, target_tmp, nr = INT_MAX; this_sd = rcu_dereference(*this_cpu_ptr(&sd_llc)); if (!this_sd) @@ -6213,9 +6213,15 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t nr = floor; } + if (per_cpu(next_cpu, target) != -1) + target_tmp = per_cpu(next_cpu, target); + else + target_tmp = target; + time = local_clock(); - for_each_cpu_wrap(cpu, sched_domain_span(sd), target) { + for_each_cpu_wrap(cpu, sched_domain_span(sd), target_tmp) { + per_cpu(next_cpu, target) = cpu; if (!--nr) return -1; if (!cpumask_test_cpu(cpu, &p->cpus_allowed)) -- 2.9.3