Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp414524imm; Thu, 28 Jun 2018 23:25:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpciY5cJCRCBZL+zGyZjeshHPEIFicDa02T7ASMMcAAvEVDpmP4hYMcAasrkl4ziHc/DTB26 X-Received: by 2002:a17:902:8f86:: with SMTP id z6-v6mr9054237plo.38.1530253534416; Thu, 28 Jun 2018 23:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530253534; cv=none; d=google.com; s=arc-20160816; b=ZDpMoBx5+XaS7IW8Grw/gdeImtNFh51PC49DNfd/yBd7YRzfkmr4cVU183dt+4gy0P DCfvFmKblmr5+09w9bGMwY6ovtCr1faoYvLJJ20IoXNzLnUqm55Nq4JeABb3FVjOzKmr 1iaYPwV2fYhse1C7q7DZUHvJuPI4Ovyw8Ohr6Uf17S3FNs+/f9GmpFhqieYxVqQxp0AN IpBJnjDogEO5W5CSTE7WYIFeVNG2JRHf4evRtsdJgBwnwRmNeFL53r0USqOqV1G4luoR q5qTrtg8TdsWsVZgyJaU1fTSlOr9wmOX52f/JG/hdE1YF4ISJdMqw1knnrRyHFifdrUX UT5A== 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:arc-authentication-results; bh=ReW1pI6oN+r6+AWvU3lVAoEyC5OJWHjiET6JJeScG5c=; b=m2d7wDYKeZ7IEchbaMv1CoVcGYSlniQxY3cjoev4Hq/f4S2UujoD9wP4y07zU8Lkjo D6Ypagi5GH9FqiMf9W/LDxVjKQHkS9hCRhxIW1UM/os+bfcqfZusKBR3IfprVi2/yZVy 0Vz9/SmU+S3qMmlsMN0PtXSeReGE2NIxBfLIHddYl54Zoz34FNJR5FxHLJ49H1qxVnx3 4LiJTs8GD79rWnXUa5fSLRswH/cSA/eBnS1nxBT3Ui07SiRmWUOa7Mw/IN2atKLmUWdq SeY2gyALHnczl0kxEJwSiZop7C9BItRDvBf+UH9OYv05RXhZSzixBW8Vmy26/ZkEy5ti m/sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b="bw/3uLNy"; 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 x15-v6si8549518pfk.25.2018.06.28.23.25.20; Thu, 28 Jun 2018 23:25:34 -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-2017-10-26 header.b="bw/3uLNy"; 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 S967082AbeF1WoG (ORCPT + 99 others); Thu, 28 Jun 2018 18:44:06 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:47392 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936138AbeF1Wn5 (ORCPT ); Thu, 28 Jun 2018 18:43:57 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5SMcuZG035321; Thu, 28 Jun 2018 22:43:23 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-2017-10-26; bh=ReW1pI6oN+r6+AWvU3lVAoEyC5OJWHjiET6JJeScG5c=; b=bw/3uLNygcsIMAzdsW6Dpfdvw3muPyxU0kOeQ4ERmQlCu2C/BEBfapY3H9dcVuob+ptb WnpTTircSygsDjAt0mFdJfXQbHDOHU1WjLVI6wJySQ8dLJ5mP3ht4nMmvlZnVOY3WMR5 ctdEH5kMZRVu0tBWWH3dHpvbEQ4/kIVDS4/XP7dJDMPzNyR7Al4mtLI7HYEH+EEVtq+3 BTgEVxA9a9ep1Pw0sKPKpdYb5y75/44p/jwfd0aw4qVFbpf6jGYO34M/xtWInrseh5xs ulxfE2h9TxAPtHfge/ia9Pv+serSVNBGT+Vo70uwy42Rt9Q+j4QXGcLezeUAjY+RNjJS Mw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2jum5844yb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Jun 2018 22:43:23 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5SMhMRF000727 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Jun 2018 22:43:22 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w5SMhM7j023364; Thu, 28 Jun 2018 22:43:22 GMT Received: from smazumda-Precision-T1600.us.oracle.com (/10.132.91.87) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 28 Jun 2018 15:43:22 -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, rohit.k.jain@oracle.com, daniel.lezcano@linaro.org Subject: [PATCH 3/5] sched: rotate the cpu search window for better spread Date: Thu, 28 Jun 2018 15:44:54 -0700 Message-Id: <20180628224456.13548-4-subhra.mazumdar@oracle.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180628224456.13548-1-subhra.mazumdar@oracle.com> References: <20180628224456.13548-1-subhra.mazumdar@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8938 signatures=668703 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=656 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806280249 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 7243146..574cb14 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6372,7 +6372,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) @@ -6403,9 +6403,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