Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4827695pxu; Thu, 10 Dec 2020 06:30:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvyc0bHSBcoBkI3TQpOIpg8qh/AzxT2prt7f3gU+Xr7oUqzPKE2vAULRfUXx02O0DMKQDR X-Received: by 2002:aa7:cf8f:: with SMTP id z15mr7061452edx.17.1607610643736; Thu, 10 Dec 2020 06:30:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607610643; cv=none; d=google.com; s=arc-20160816; b=MMzMKMlmPzyjE45OChNXOLqbGqbhX3Ivu23ju3b7CaWZcq/942bO3hW412yp8HkO8Y y2M1oOaFGyrGOwmsttMdViLUa0gm6M2wmyGA4syRutECxVoIdhDBf6weZp8PU3UE2oYo X2Kk2xFaXVTtFsGQypLcsfRgC+xZwYdafxaX/q4VLi0XTUqvO09KZ3yMwAKXZ1NhTkLb OPynoF+jHwBxPZmmFyc9yC+axL2yRjaLEeDOIXUUT5j5J07USwcH972EqNXl0MQeY7S0 WKPO+4FvxhqHdDwTCahaiitlaAAdeGf+41hVFePhb1W2fTXBLEDzhoKys5XMAfjSichF eCIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=nuRQFzW2TbDYYdE3YkWjYMqbxTnJB+bRdXAmXVa54ns=; b=UrPbBXEyVRIdi8po7AaDxKiBWFowVvALFyJRH2p3t1mgcCLMs4avHPt1yVRccVmWvL Qx0a7zRyXa2vEYwSy7BCjCHquMY/BC1pMbJLdMh701qSpguF5x1/W+rdlGl0nqTU4/IB jmz27VLazvWBQDqAFtW9hJhst/fgpyqKmyRk0wtspcVem4M8bjkjCERADA/jS/vZrUM+ FUircNq7Xtckg8ja8bdSSSX96DRpD9PjnfWQrFhyXaib5EaOXmRfkF21YhcAqwB20Igx 9kgE5rpJa07P/ZGBVukg2Q2I10L55TXmxthVXKAMsAqLgFmqwbclRvcMXCI1t60NiMB3 I6+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="Ew/Kj+qi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pw18si2619063ejb.163.2020.12.10.06.30.20; Thu, 10 Dec 2020 06:30:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="Ew/Kj+qi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388798AbgLJKlq (ORCPT + 99 others); Thu, 10 Dec 2020 05:41:46 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:30760 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388523AbgLJKlV (ORCPT ); Thu, 10 Dec 2020 05:41:21 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0BAAYYFW103448; Thu, 10 Dec 2020 05:40:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id; s=pp1; bh=nuRQFzW2TbDYYdE3YkWjYMqbxTnJB+bRdXAmXVa54ns=; b=Ew/Kj+qikgv501kyTMHIgOh4b+X9a5JMRVRtawkq7XtTtjJuO43OY0kIFmguWq60Zu56 lH/CCVGvXQw+MYWdoN1RSHklT5cM89q5KxgOeL2y32htEyI1N0Y5gHy8pLuPxtHC48OO Std9dYr+RkAM0/GkMoFRaawIQMNxmDnXdYAkvsHKvbpoVZQipHXSU2utnGd1+s8bT19g Cwp7J9QWt4OS8xNWXoiGXcTGl9ZS9dYyN2pfQlJRHasgJHW3vjajWNTuqTDdJTawPbpx Y9p2lgOzmNgohgoAT3YVt4TO9acT7B9v7TClV56pLat+Bl8X+PiYK+6ab9PwQfwmw7Gi TA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35bhdg1ar4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Dec 2020 05:40:28 -0500 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0BAAZm8p113185; Thu, 10 Dec 2020 05:40:27 -0500 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 35bhdg1aqk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Dec 2020 05:40:27 -0500 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0BAAWIed015779; Thu, 10 Dec 2020 10:40:26 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma01wdc.us.ibm.com with ESMTP id 3581u9nt7y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Dec 2020 10:40:26 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0BAAdAt619530140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Dec 2020 10:39:10 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 424AF6E04E; Thu, 10 Dec 2020 10:39:10 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F0846E050; Thu, 10 Dec 2020 10:39:09 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.199.53.52]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 10 Dec 2020 10:39:09 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id EEEBC2E35A0; Thu, 10 Dec 2020 16:09:05 +0530 (IST) From: "Gautham R. Shenoy" To: Srikar Dronamraju , Anton Blanchard , Vaidyanathan Srinivasan , Michael Ellerman , Michael Neuling , Nicholas Piggin , Nathan Lynch , Peter Zijlstra , Valentin Schneider Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, "Gautham R. Shenoy" Subject: [PATCH v3 0/5] Extend Parsing "ibm,thread-groups" for Shared-L2 information Date: Thu, 10 Dec 2020 16:08:54 +0530 Message-Id: <1607596739-32439-1-git-send-email-ego@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2020-12-10_03:2020-12-09,2020-12-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 spamscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012100067 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Gautham R. Shenoy" Hi, This is the v2 of the patchset to extend parsing of "ibm,thread-groups" property to discover the Shared-L2 cache information. The previous versions can be found here : v2 : https://lore.kernel.org/linuxppc-dev/1607533700-5546-1-git-send-email-ego@linux.vnet.ibm.com/T/#m043ea15d3832658527fca94765202b9cbefd330d v1 : https://lore.kernel.org/linuxppc-dev/1607057327-29822-1-git-send-email-ego@linux.vnet.ibm.com/T/#m0fabffa1ea1a2807b362f25c849bb19415216520 Changes form v2-->v3: * Fixed the build errors reported by the Kernel Test Robot for Patches 4 and 5. Changes from v1-->v2: Incorporate the review comments from Srikar and fix a build error on !PPC64 configs reported by the kernel bot. * Split Patch 1 into three patches * First patch ensure that parse_thread_groups() is made generic to support more than one property. * Second patch renames cpu_l1_cache_map as thread_group_l1_cache_map for consistency. No functional impact. * The third patch makes init_thread_group_l1_cache_map() generic. No functional impact. * Patch 2 (Now patch 4): Incorporates the review comments from Srikar simplifying the changes to update_mask_by_l2() * Patch 3 (Now patch 5): Fix a build errors for 32-bit configs reported by the kernel build bot. Description of the Patchset =========================== The "ibm,thread-groups" device-tree property is an array that is used to indicate if groups of threads within a core share certain properties. It provides details of which property is being shared by which groups of threads. This array can encode information about multiple properties being shared by different thread-groups within the core. Example: Suppose, "ibm,thread-groups" = [1,2,4,8,10,12,14,9,11,13,15,2,2,4,8,10,12,14,9,11,13,15] This can be decomposed up into two consecutive arrays: a) [1,2,4,8,10,12,14,9,11,13,15] b) [2,2,4,8,10,12,14,9,11,13,15] where in, a) provides information of Property "1" being shared by "2" groups, each with "4" threads each. The "ibm,ppc-interrupt-server#s" of the first group is {8,10,12,14} and the "ibm,ppc-interrupt-server#s" of the second group is {9,11,13,15}. Property "1" is indicative of the thread in the group sharing L1 cache, translation cache and Instruction Data flow. b) provides information of Property "2" being shared by "2" groups, each group with "4" threads. The "ibm,ppc-interrupt-server#s" of the first group is {8,10,12,14} and the "ibm,ppc-interrupt-server#s" of the second group is {9,11,13,15}. Property "2" indicates that the threads in each group share the L2-cache. The existing code assumes that the "ibm,thread-groups" encodes information about only one property. Hence even on platforms which encode information about multiple properties being shared by the corresponding groups of threads, the current code will only pick the first one. (In the above example, it will only consider [1,2,4,8,10,12,14,9,11,13,15] but not [2,2,4,8,10,12,14,9,11,13,15]). Furthermore, currently on platforms where groups of threads share L2 cache, we incorrectly create an extra CACHE level sched-domain that maps to all the threads of the core. For example, if "ibm,thread-groups" is 00000001 00000002 00000004 00000000 00000002 00000004 00000006 00000001 00000003 00000005 00000007 00000002 00000002 00000004 00000000 00000002 00000004 00000006 00000001 00000003 00000005 00000007 then, the sub-array [00000002 00000002 00000004 00000000 00000002 00000004 00000006 00000001 00000003 00000005 00000007] indicates that L2 (Property "2") is shared only between the threads of a single group. There are "2" groups of threads where each group contains "4" threads each. The groups being {0,2,4,6} and {1,3,5,7}. However, the sched-domain hierarchy for CPUs 0,1 is CPU0 attaching sched-domain(s): domain-0: span=0,2,4,6 level=SMT domain-1: span=0-7 level=CACHE domain-2: span=0-15,24-39,48-55 level=MC domain-3: span=0-55 level=DIE CPU1 attaching sched-domain(s): domain-0: span=1,3,5,7 level=SMT domain-1: span=0-7 level=CACHE domain-2: span=0-15,24-39,48-55 level=MC domain-3: span=0-55 level=DIE where the CACHE domain reports that L2 is shared across the entire core which is incorrect on such platforms. This patchset remedies these issues by extending the parsing support for "ibm,thread-groups" to discover information about multiple properties being shared by the corresponding groups of threads. In particular we cano now detect if the groups of threads within a core share the L2-cache. On such platforms, we populate the populating the cpu_l2_cache_mask of every CPU to the core-siblings which share L2 with the CPU as specified in the by the "ibm,thread-groups" property array. With the patchset, the sched-domain hierarchy is correctly reported. For eg for CPUs 0,1, with the patchset CPU0 attaching sched-domain(s): domain-0: span=0,2,4,6 level=SMT domain-1: span=0-15,24-39,48-55 level=MC domain-2: span=0-55 level=DIE CPU1 attaching sched-domain(s): domain-0: span=1,3,5,7 level=SMT domain-1: span=0-15,24-39,48-55 level=MC domain-2: span=0-55 level=DIE The CACHE domain with span=0,2,4,6 for CPU 0 (span=1,3,5,7 for CPU 1 resp.) gets degenerated into the SMT domain. Furthermore, the last-level-cache domain gets correctly set to the SMT sched-domain. Testing ========== With the producer-consumer testcase(https://github.com/gautshen/misc/tree/master/producer_consumer) where in the producer thread performs writes to 4096 random locations, and the consumer thread subsequently reads from those 4096 random location. We measure the time taken by the consumer to finish the 4096 reads (called an iteration of the consumer). Thus lower the value, better is the result. The best case occurs when the producer and consumer are affined to the same L2 cache domain (Eg: CPU0, CPU2). On the platform with the thread-groups sharing L2, |-----------------------------------------------| | Without Patch | |-----------|-----------|-----------------------| | Producer | Consumer | Avg time per Consumer | | Affinity | Affinity | Iteration | |-----------|-----------|-----------------------| | CPU0 | CPU2 | 235us | |-----------|-----------|-----------------------| |Not affined|Not affined| 347us | |-----------------------------------------------| We see that out-of-box, the average time per consumer iteration is higher since the tasks can be placed anywhere within the core without them being in the L2 domain. |-----------------------------------------------| | With Patch | |-----------|-----------|-----------------------| | Producer | Consumer | Avg time per Consumer | | Affinity | Affinity | Iteration | |-----------|-----------|-----------------------| | CPU0 | CPU2 | 235us | |-----------|-----------|-----------------------| |Not affined|Not affined| 236us | |-----------------------------------------------| With the patch, since the L2 domain is correctly identified, the scheduler does the right thing by co-locating the producer and consumer on the same L2 domain, thereby yielding the out-of-box performance matching the best case. Finally, this patchset reports the correct shared_cpu_map/list in the sysfs for L2 cache on such platforms. With the patchset for CPUs0, 1, for L2 cache we see the correct shared_cpu_map/list /sys/devices/system/cpu/cpu0/cache/index2/shared_cpu_list:0,2,4,6 /sys/devices/system/cpu/cpu0/cache/index2/shared_cpu_map:000000,00000055 /sys/devices/system/cpu/cpu1/cache/index2/shared_cpu_list:1,3,5,7 /sys/devices/system/cpu/cpu1/cache/index2/shared_cpu_map:000000,000000aa The patchset has been tested on older platforms which encode only the L1 sharing information via "ibm,thread-groups" and there is no regression found. Gautham R. Shenoy (5): powerpc/smp: Parse ibm,thread-groups with multiple properties powerpc/smp: Rename cpu_l1_cache_map as thread_group_l1_cache_map powerpc/smp: Rename init_thread_group_l1_cache_map() to make it generic powerpc/smp: Add support detecting thread-groups sharing L2 cache powerpc/cacheinfo: Print correct cache-sibling map/list for L2 cache arch/powerpc/include/asm/smp.h | 6 + arch/powerpc/kernel/cacheinfo.c | 30 +++-- arch/powerpc/kernel/smp.c | 241 ++++++++++++++++++++++++++++------------ 3 files changed, 198 insertions(+), 79 deletions(-) -- 1.9.4