Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1766491imm; Wed, 10 Oct 2018 22:34:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV62OJCD3eaLcgDIjKmoeI3uxuQhahEemIhttYQ3pdyxjXWtWGEE48bYghVHqAi9FenXmXhD0 X-Received: by 2002:a17:902:9a4c:: with SMTP id x12-v6mr151360plv.92.1539236040721; Wed, 10 Oct 2018 22:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539236040; cv=none; d=google.com; s=arc-20160816; b=t25sLVQxALgjsWOHIGM5A/hfcor97Zcyd2h1jtDMvLGiJUFBlfYPM0bRHfelHdhOY5 WJPMbFplpLMsimGPjKr9x0f5FmwmGT6mBQgyd56dzr1/LZUTQ4ebDxVhBeSW0GraL7pd k3cF6vNlb4jq+5Kdg9lW5mia3qyqyfI3g2HjGFmD3ezYrp3917E04sWuqBjAhfQf2PuI JWe8iX11nwy8FfMRWqg7IOzIjqgbFjlGN+KbdK4b61wELBtZx6Hcz7kuG1YATww6/UeO CeDVs1VmqzFsLpr/kS7iXt85yOLafS38uJZUdFnxehGwm5hTitOuNPQxoFRjYKqMMayj Iz8Q== 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=G458m+qGeVZTYOAQ113zMIGWG/Q6dMWlAR3wr7M0TdMhH22LQRwRU3dTj0zqH6A53Z WC+21+Uy1UKcLJOrIze5C8ACHVeDHDvPCZ1scINhzeo0y+l0CIaKAm3o35XRnVzaagNO /1kEZydkFiQGcV7UxPmjq/UqdmW2pwhryGUGwW0UZ4RUuTpPQtIPeFqRMfXSfml2+M/m H5sckcVysA+sA2uymnVY9s/mYGBLKIMyEbZryV0fUE1CFOk8QjCjIImkYXHKLwyj02JH s0XjYNp3vfpDJ831dR0rGtwOb0fuAZAQzW/81O8jFYFHrdAxRqAVVH6Sfe9quGV/TwP2 OFDg== 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 x10-v6si25543574plo.100.2018.10.10.22.33.46; Wed, 10 Oct 2018 22:34:00 -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 S1727785AbeJKM6y (ORCPT + 99 others); Thu, 11 Oct 2018 08:58:54 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34020 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727218AbeJKM6y (ORCPT ); Thu, 11 Oct 2018 08:58:54 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9B5T4uS123963 for ; Thu, 11 Oct 2018 01:33:17 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n1xxmk8r9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 11 Oct 2018 01:33:17 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Oct 2018 23:33:16 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 10 Oct 2018 23:33:12 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9B5XB7010223706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 10 Oct 2018 22:33:11 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 76B4BBE04F; Wed, 10 Oct 2018 23:33:11 -0600 (MDT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E86D5BE059; Wed, 10 Oct 2018 23:33:10 -0600 (MDT) Received: from sofia.ibm.com (unknown [9.124.35.51]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 10 Oct 2018 23:33:10 -0600 (MDT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 3CA592E3D7F; Thu, 11 Oct 2018 11:03:09 +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 v10 2/3] powerpc: Use cpu_smallcore_sibling_mask at SMT level on bigcores Date: Thu, 11 Oct 2018 11:03:02 +0530 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1539235983-25259-1-git-send-email-ego@linux.vnet.ibm.com> References: <1539235983-25259-1-git-send-email-ego@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18101105-0020-0000-0000-00000E76B0E7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009858; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000268; SDB=6.01100952; UDB=6.00569661; IPR=6.00880998; MB=3.00023704; MTD=3.00000008; XFM=3.00000015; UTC=2018-10-11 05:33:15 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101105-0021-0000-0000-000063552A5A Message-Id: <1539235983-25259-3-git-send-email-ego@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-11_01:,, 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=953 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110052 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