Received: by 10.192.165.148 with SMTP id m20csp4033830imm; Mon, 23 Apr 2018 17:42:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+c+ml9gwSVJjaaVutMWlvehKRVwekMIXxsZzdfKutm4TDHF+LyknZklNyXsq/FaBORQ91u X-Received: by 10.101.97.200 with SMTP id j8mr18640682pgv.443.1524530541605; Mon, 23 Apr 2018 17:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524530541; cv=none; d=google.com; s=arc-20160816; b=eCHu8vfIV7PAds5jOWHI1gpzFuKGHdntg1KgS5u1NGHgEci4aYXgfzLVJCrt4IsxrS 8bQJ5FoyBremwfYNjZUZYwuQX1ej4QNgpLtjF5PeQXq9Se5r+8gPCfowRNYeW6sFq7pG K1lKVs6Od8CLqCpLCxcW1UADs8BIWTytNA4CWBY/gzEc6qWbqwqAoRnakbwdA05AFUoo kJz+/xfpewuMVzW5lB1ulgXg6zcWrwQJ6EgZXYH7fvp8/xfAE5dK43Ru0pemVrz5RNmY KBEQKWvZB8w9Nk5Njd8dvJGNHVEn7Z8e2BxpkYTyBirPXXHNI2BgNuca0BPRvp7XwwZ2 3lqA== 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=ZFiehZ9kmkI7mHWrmVkrNjkBK9AjyYvVwLHi2M2ZkZM=; b=CgbDeRQIF4uzdCAGTZqbWG8odTZuK6N5WZxMAemrSS1srGy303bKscmD4Dq6b/vjbx ULYb0yN8wr9S+bY/9/68Bmh2EDBc9Q+iyzaf1H9eMEONFNkIOzsdC9xLxy3p/YCtpDBo hXIWHrKb7ibjYlVecDJOV6yrj8Kxr0PkZO6rE/iFlPeQOD26N5CI36D/eGfTJsjzdnnm niZxrb1+Gc3SHiEeA+7mV2Nhg0UCeuJ+ecposZt5wHwJZFMKD9ye7nIUKQNxz3iOBoIN BjX1dvnqBa2QwnWSh3BVpVJs2g3TPkgWeEjVzWEjRlh7EMYKJJyWaKA+ZzfHvBGRKcah H+Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=Gy0hESCG; 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 z5si10384724pgu.377.2018.04.23.17.42.06; Mon, 23 Apr 2018 17:42:21 -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=Gy0hESCG; 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 S932734AbeDXAj0 (ORCPT + 99 others); Mon, 23 Apr 2018 20:39:26 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54680 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932691AbeDXAjA (ORCPT ); Mon, 23 Apr 2018 20:39:00 -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 w3O0UsOq028086; Tue, 24 Apr 2018 00:38:25 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=ZFiehZ9kmkI7mHWrmVkrNjkBK9AjyYvVwLHi2M2ZkZM=; b=Gy0hESCG89mSoW49RLngIbrq3TtMIuxQJN/wV6NyMIm8Aw4X3ZPiBkXcWBnvjpIyrM+f mQyLHg+ig0oH0g9VOfyhca6YLU/oceadAqg9HBZC8qgYMdWc1w0/HpmVw4XliS6eP3Fx TK+q4RYa6LxrRoSkDQh829pW50R35T4iBoMGrHhWAPWt315D3KpdY3WodCNK4LOuTmIv qGnTPC/N2gPvlAwYBw5PwTQ0wedLp+QZCvlQlBxdIKG3YEvhz9uxAoTS6zMZwqr6c7Sp AA+qZxjIsqakECrhvmd4woJQdt9xTHrD/p7RSgx3WWSdUM4jK6oMtWR7GiNRCLq81OFW DA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2hfvrbqt9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Apr 2018 00:38:25 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w3O0cOKc012042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Apr 2018 00:38:24 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w3O0cNEm003078; Tue, 24 Apr 2018 00:38:23 GMT Received: from smazumda-Precision-T1600.us.oracle.com (/10.132.91.87) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 23 Apr 2018 17:38:23 -0700 From: subhra mazumdar To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, daniel.lezcano@linaro.org, steven.sistare@oracle.com, dhaval.giani@oracle.com, rohit.k.jain@oracle.com, subhra.mazumdar@oracle.com Subject: [PATCH 3/3] sched: limit cpu search and rotate search window for scalability Date: Mon, 23 Apr 2018 17:41:16 -0700 Message-Id: <20180424004116.28151-4-subhra.mazumdar@oracle.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180424004116.28151-1-subhra.mazumdar@oracle.com> References: <20180424004116.28151-1-subhra.mazumdar@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8872 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=978 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804240003 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lower the lower limit of idle cpu search in select_idle_cpu() and also put an upper limit. This helps in scalability of the search by restricting the search window. Also rotating the search window with help of next_cpu ensures any idle cpu is eventually found in case of high load. Signed-off-by: subhra mazumdar --- kernel/sched/fair.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d1d4769..62d585b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6279,7 +6279,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, nr = INT_MAX; + int cpu, target_tmp, nr = INT_MAX; this_sd = rcu_dereference(*this_cpu_ptr(&sd_llc)); if (!this_sd) @@ -6297,15 +6297,24 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t if (sched_feat(SIS_PROP)) { u64 span_avg = sd->span_weight * avg_idle; - if (span_avg > 4*avg_cost) + if (span_avg > 2*avg_cost) { nr = div_u64(span_avg, avg_cost); - else - nr = 4; + if (nr > 4) + nr = 4; + } else { + nr = 2; + } } + 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