Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3619381ybd; Fri, 28 Jun 2019 11:49:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8r9lZFqcSQY/YmaYdCjvrTUgE6lRSkPqNPjiGcZvoaoo3apMfYWKclDFYQIddC4HCtlBI X-Received: by 2002:a17:90a:ae12:: with SMTP id t18mr15354535pjq.32.1561747791814; Fri, 28 Jun 2019 11:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561747791; cv=none; d=google.com; s=arc-20160816; b=PeqwOjlC8Y/LoZT0pDcHhuXver1/otaZ0Jg+vomSFMH0/GNtB/FR8TR+gnx+82RyNq Qz8q/1EF8OvTni1Hi/EI9ZMkSQ11e+D6tfX2sWxFMHJPlnu2Hd3K2WJFfARG5x5p1cxb FpzoJz/9xqQ/HOglb5vy5RlUxewqPaN766o2Zxbs/NjkTfHv3OWCDgPN0xU8reUunSeq zcfLDfwHawWDK8Il/o2bM3dOXutEP0qb/BP4aFWDVucFsDB3YcPAhvtJQ2f/27rMu215 61iWu/GGOrRbPlsWFuqGZYSxAuLVdVHJDA10GZm60L4qFPENUWjv/QcA8xDGSA8aYl/F 1U0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject; bh=Z3MNStyoDL2LNhLEGNj6g/uXSaV36LBYRqdVyp5mrDY=; b=gu2s9DGkV+o0NJAsmHme7h3mniWmMTKu1sWln4FQnQ/p/YfTx5NChd9ZMEbhYvWyTp aQ3X9V3C41aWt8EcTLCGZ9E+PBymW7oYapGaIgNddGitKw6/wRZKsZSab/HPulckIUug 8fO+AzpDuXvBiWCvU/SMD8/J23t/ohejyZSMG3WU8IRTAvklXS8N2Sv5Kg7DAkoHg1Ho 9FjHWygb49GHIQMCM6uj252SQqOUdJCMmQFlOB925k9yw8lFm14RHWsFtBneC/qObe2z DdYtji7V83PqiaXSPughMzk1vdiVhv+nBhjUWmmE3paXYdkRROh19J3Yio0CcqMZjiOR klQA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si2744719pln.247.2019.06.28.11.49.35; Fri, 28 Jun 2019 11:49:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726932AbfF1SsF (ORCPT + 99 others); Fri, 28 Jun 2019 14:48:05 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34128 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726702AbfF1SsF (ORCPT ); Fri, 28 Jun 2019 14:48:05 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5SIkkjc144298 for ; Fri, 28 Jun 2019 14:48:02 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2tdn2x7uq1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Jun 2019 14:48:01 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Jun 2019 19:47:59 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 28 Jun 2019 19:47:54 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x5SIlrwt49676454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jun 2019 18:47:53 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0C64A4040; Fri, 28 Jun 2019 18:47:53 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 546EBA4051; Fri, 28 Jun 2019 18:47:50 +0000 (GMT) Received: from localhost.localdomain (unknown [9.199.62.39]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Jun 2019 18:47:50 +0000 (GMT) Subject: Re: [PATCH v3 1/7] sched: limit cpu search in select_idle_cpu To: subhra mazumdar , 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 References: <20190627012919.4341-1-subhra.mazumdar@oracle.com> <20190627012919.4341-2-subhra.mazumdar@oracle.com> From: Parth Shah Date: Sat, 29 Jun 2019 00:17:49 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20190627012919.4341-2-subhra.mazumdar@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 19062818-0020-0000-0000-0000034E74BA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19062818-0021-0000-0000-000021A1F6EE Message-Id: <68baf89b-6d77-4eff-3aac-f96b72f98bae@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-28_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 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-1906280212 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/27/19 6:59 AM, subhra mazumdar wrote: > Put upper and lower limit on cpu search of select_idle_cpu. The lower limit > is amount of cpus in a core while upper limit is twice that. This ensures > for any architecture we will usually search beyond a core. The upper limit > also helps in keeping the search cost low and constant. > > Signed-off-by: subhra mazumdar > --- > kernel/sched/fair.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index f35930f..b58f08f 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, nr = INT_MAX; > + int cpu, limit, floor, nr = INT_MAX; > > this_sd = rcu_dereference(*this_cpu_ptr(&sd_llc)); > if (!this_sd) > @@ -6206,10 +6206,17 @@ 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) > + floor = cpumask_weight(topology_sibling_cpumask(target)); > + if (floor < 2) > + floor = 2; > + limit = floor << 1; Is upper limit an experimental value only or it has any arch specific significance? Because, AFAIU, systems like POWER9 might have benefit for searching for 4-cores due to its different cache model. So it can be tuned for arch specific builds then. Also variable names can be changed for better readability. floor -> weight_clamp_min limit -> weight_clamp_max or something similar > + if (span_avg > floor*avg_cost) { > nr = div_u64(span_avg, avg_cost); > - else > - nr = 4; > + if (nr > limit) > + nr = limit; > + } else { > + nr = floor; > + } > } > > time = local_clock(); > Best, Parth