Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp34017imm; Mon, 1 Oct 2018 06:18:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV61pMfaImWMj/mK/aAYSNNklIam7ZDuxPv3JuCvOKcVa56xIQqsk686+VnFLcvpwWAmNgDNw X-Received: by 2002:a63:b25e:: with SMTP id t30-v6mr1768056pgo.401.1538399904297; Mon, 01 Oct 2018 06:18:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538399904; cv=none; d=google.com; s=arc-20160816; b=xjRe9wXuC/vhMwir7Gk8OV0tDr1n6d9qWlwEiu102uGp3V+kPPw6uXvHO1D8TdGVCo 5hjgxz+AzOk0d8oKAAdLIBfwvz/sVQ5mmtWZlKUAwAWgPyM3h7znqsVBXJCiuezdBxd0 HeS2JXzQOb9gW+Nmg7IqN2YIrQkka1+81numtqxil66Tk6oMG3kY2M6BNS6jfRQCuzZR 80pzBFueVCEXLQMFrUGmWpCvFIuHK6xR2MUn7l274Yp6ICH21FXLBgu/ZoRyTbPvw9Uq WZOriIG8SKw2NKxfHqUVeDvNcvVmhQyGQivf6LG5ciq3r8mDPMnXXX+iHaePla5YKdEH UpQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=TYGI+saDNv1hhUpzy9eJ+KdOnYJ2EqX0Z0yGXbGnooc=; b=DEKuNoTSrhLFoNx2gFoPKGTLuEwiUHjbV+4HOi/GQBtNBee2Zh8wpV4+1KShP6zfvt shZlBovuzyInVZ+//aDCPnuyatSPU3/lFObVm+Ks1N2A+YlNIoVsEO2EvYtP6YPV0z0B 1J5xH5jAIfUzuIVqy6MgT5L2zLd/LHnE3XHZAZWI/OHn6cOszPJ3/5umdtWrHazW/Ju1 zck7JfHgnzZngm61KVnlQKNcBhMvkPKL3udenZk9bTm991ObieWwDQFkKf0Bqu8VqfUZ xUjfGdl/6BIQ6xI1G5ZkFifhxPbdCogLqupiAZCGwTvp0qCfHw/ZbVsFghQzjLlRg47N wd+g== 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 l10-v6si12742322plt.440.2018.10.01.06.18.06; Mon, 01 Oct 2018 06:18:24 -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 S1729298AbeJATyq (ORCPT + 99 others); Mon, 1 Oct 2018 15:54:46 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60444 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729265AbeJATyp (ORCPT ); Mon, 1 Oct 2018 15:54:45 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w91DAmQS035679 for ; Mon, 1 Oct 2018 09:16:59 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mukk4absm-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 01 Oct 2018 09:16:58 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 1 Oct 2018 09:16:57 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 1 Oct 2018 09:16:53 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w91DGqDH31260764 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 1 Oct 2018 13:16:52 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 485BAAE05F; Mon, 1 Oct 2018 09:15:12 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C5292AE063; Mon, 1 Oct 2018 09:15:11 -0400 (EDT) Received: from sofia.ibm.com (unknown [9.124.35.106]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 1 Oct 2018 09:15:11 -0400 (EDT) Received: by sofia.ibm.com (Postfix, from userid 1000) id BE4E32E4140; Mon, 1 Oct 2018 18:46:49 +0530 (IST) From: "Gautham R. Shenoy" To: Dave Hansen , "Aneesh Kumar K.V" , Srikar Dronamraju , Michael Ellerman , Benjamin Herrenschmidt , Michael Neuling , Vaidyanathan Srinivasan , Akshay Adiga , Shilpasri G Bhat , "Oliver O'Halloran" , Nicholas Piggin , Murilo Opsfelder Araujo , Anton Blanchard Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, "Gautham R. Shenoy" Subject: [PATCH v9 2/3] powerpc: Use cpu_smallcore_sibling_mask at SMT level on bigcores Date: Mon, 1 Oct 2018 18:46:41 +0530 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538399802-23582-1-git-send-email-ego@linux.vnet.ibm.com> References: <1538399802-23582-1-git-send-email-ego@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18100113-0064-0000-0000-000003581FDE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009802; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000267; SDB=6.01096315; UDB=6.00566874; IPR=6.00876357; MB=3.00023575; MTD=3.00000008; XFM=3.00000015; UTC=2018-10-01 13:16:56 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18100113-0065-0000-0000-00003AD52B58 Message-Id: <1538399802-23582-3-git-send-email-ego@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-01_08:,, 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=955 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810010131 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Gautham R. Shenoy" POWER9 SMT8 cores consist of two groups of threads, where threads in each group shares L1-cache. The scheduler is not aware of this distinction as the current sched-domain hierarchy has all the threads of the core defined at the SMT domain. SMT [Thread siblings of the SMT8 core] DIE [CPUs in the same die] NUMA [All the CPUs in the system] Due to this, we can observe run-to-run variance when we run a multi-threaded benchmark bound to a single core based on how the scheduler spreads the software threads across the two groups in the core. We fix this in this patch by defining each group of threads which share L1-cache to be the SMT level. The group of threads in the SMT8 core is defined to be the CACHE level. The sched-domain hierarchy after this patch will be : SMT [Thread siblings in the core that share L1 cache] CACHE [Thread siblings that are in the SMT8 core] DIE [CPUs in the same die] NUMA [All the CPUs in the system] Signed-off-by: Gautham R. Shenoy --- arch/powerpc/kernel/smp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 22a14a9..356751e 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -1266,6 +1266,7 @@ static void add_cpu_to_masks(int cpu) void start_secondary(void *unused) { unsigned int cpu = smp_processor_id(); + struct cpumask *(*sibling_mask)(int) = cpu_sibling_mask; mmgrab(&init_mm); current->active_mm = &init_mm; @@ -1291,11 +1292,13 @@ void start_secondary(void *unused) /* Update topology CPU masks */ add_cpu_to_masks(cpu); + if (has_big_cores) + sibling_mask = cpu_smallcore_mask; /* * Check for any shared caches. Note that this must be done on a * per-core basis because one core in the pair might be disabled. */ - if (!cpumask_equal(cpu_l2_cache_mask(cpu), cpu_sibling_mask(cpu))) + if (!cpumask_equal(cpu_l2_cache_mask(cpu), sibling_mask(cpu))) shared_caches = true; set_numa_node(numa_cpu_lookup_table[cpu]); @@ -1362,6 +1365,13 @@ static const struct cpumask *shared_cache_mask(int cpu) return cpu_l2_cache_mask(cpu); } +#ifdef CONFIG_SCHED_SMT +static const struct cpumask *smallcore_smt_mask(int cpu) +{ + return cpu_smallcore_mask(cpu); +} +#endif + static struct sched_domain_topology_level power9_topology[] = { #ifdef CONFIG_SCHED_SMT { cpu_smt_mask, powerpc_smt_flags, SD_INIT_NAME(SMT) }, @@ -1389,6 +1399,13 @@ void __init smp_cpus_done(unsigned int max_cpus) shared_proc_topology_init(); dump_numa_cpu_topology(); +#ifdef CONFIG_SCHED_SMT + if (has_big_cores) { + pr_info("Using small cores at SMT level\n"); + power9_topology[0].mask = smallcore_smt_mask; + powerpc_topology[0].mask = smallcore_smt_mask; + } +#endif /* * If any CPU detects that it's sharing a cache with another CPU then * use the deeper topology that is aware of this sharing. -- 1.9.4