Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1789197ybi; Sat, 8 Jun 2019 18:56:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzrKTRFcdF+5egK5adswZObXoilyq9jGukKOvD6FaHXkqUkoX/eoIjReNV8GRYPX9IhsrVi X-Received: by 2002:a17:90a:374c:: with SMTP id u70mr13765936pjb.19.1560045396329; Sat, 08 Jun 2019 18:56:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560045396; cv=none; d=google.com; s=arc-20160816; b=SEkfqTOvQFb66ZUE5rWaKcChmRiiD1QvD2WFUL7FhTDUBFbBUfums9yyUrEYKhUqsT 2j3kSRWPCixr305PldDm4mAYWd6PHnhDHAyJiyjpoJ9xIHB0R4l4sIkyL01lyvcx8xDa T7C0YeDZHOPd22tsmeSLM1G1sihkXhMxgJemB3yxF120GTXVxPX3o5rQD8UNHAsGcL8/ RisPHDsqPXa3s8MSjG2DtAA7EOXesh3X2+chkcsy52cbpHnreuNf55wFmDQ5nOgIwkDS kSdWI/MTxbJGsEnJAzwJNmHFgUrKThYoXdT3a2lRuAMJdbdSoZwbAn2Snv43tZwT5FcP iC2g== 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=x+M0Mv5Zb9UXiRYfxKM6z9oZmTfxBCdsXIjXQ8gVKSc=; b=HGfVx33Uue6fRna4vzuN9u4DUaX5YHCLeRC8TT5HfRvPwqfKSZISezZkLyXdcqEVFJ +jG//xidLuFxyDv16hN0XU3DZ84xW8vsyJEzuMuuYWBZjGMurj6kzUxiW32flou2bZSU GORbrYacRRrb6g/c5BBIaGkxHu3ILHettrLBEATfqzoPulSH8tpbaAbV9kU18iQLLwBJ tySxMbFOjgsuTF+lqK2soRQHMVhFsxFJF2BTr7gsJMQnnddGcTBYUfFIExNpgRXuIf8O PhyJRMbJTUB2AE1KPgwjfNbZrwpa6cfDxo7ADRPyxL37qQyrB4/sijnGxIjrmQAVT+Gv voeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="j1N+Q6/+"; 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 h5si5880761pji.39.2019.06.08.18.56.20; Sat, 08 Jun 2019 18:56:36 -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="j1N+Q6/+"; 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 S1728072AbfFIBzU (ORCPT + 99 others); Sat, 8 Jun 2019 21:55:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:54442 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727444AbfFIBzU (ORCPT ); Sat, 8 Jun 2019 21:55:20 -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 x591rdEJ030612; Sun, 9 Jun 2019 01:54:44 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-2018-07-02; bh=x+M0Mv5Zb9UXiRYfxKM6z9oZmTfxBCdsXIjXQ8gVKSc=; b=j1N+Q6/+fFyoxnDn0l58lkMlsruewpWCLdPi1/j5S9DQN6qMkgJ/6LrrucGOe2JKyjW2 16klZr6wbzumwBJuHHtQr6VSGHWPsb5T7kImjgpDfShBAsfUtb9HmFQ4do/xTd1eMdzt ZWGg/uggEZLDGvwMMnGTePDjcjDW/dn78hfhf18tYuPLZlV893mDmTkOwNIHsnvHNwIr 89reU5EfAec+GoxYEZE8CE1Tx0hj5YoPGaIOZLJUbeQjtGFr8UclUMDHBDgP4TpBv7Er EsJCgOv3Us4Mi0dJj4h8+ne7Hg8crdX1aYK/8rg3nQMbM3QyWGwwqxelDmhF8BaoVDnC xw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2t05nqa0mf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 09 Jun 2019 01:54:44 +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 x591rB8Z026415; Sun, 9 Jun 2019 01:54:44 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2t024tcfmp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 09 Jun 2019 01:54:44 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x591sd55030390; Sun, 9 Jun 2019 01:54:40 GMT Received: from smazumda-Precision-T1600.us.oracle.com (/10.132.91.175) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 08 Jun 2019 18:54:39 -0700 From: subhra mazumdar To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, 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 Subject: [PATCH v3 3/7] sched: rotate the cpu search window for better spread Date: Sat, 8 Jun 2019 18:49:50 -0700 Message-Id: <20190609014954.1033-4-subhra.mazumdar@oracle.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20190609014954.1033-1-subhra.mazumdar@oracle.com> References: <20190609014954.1033-1-subhra.mazumdar@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9282 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=846 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906090012 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9282 signatures=668687 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=881 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906090013 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 b58f08f..c1ca88e 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, limit, floor, nr = INT_MAX; + int cpu, limit, floor, target_tmp, nr = INT_MAX; this_sd = rcu_dereference(*this_cpu_ptr(&sd_llc)); if (!this_sd) @@ -6219,9 +6219,15 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t } } + 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