Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4135253pxu; Wed, 9 Dec 2020 09:11:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0t+R88IxpPwVwXPCClDXzZMbQIdBTM481oaDT4r2IGjs7xU8O4RJELZLgRkdFcwaa/wG8 X-Received: by 2002:a17:906:76cd:: with SMTP id q13mr2404484ejn.67.1607533917563; Wed, 09 Dec 2020 09:11:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607533917; cv=none; d=google.com; s=arc-20160816; b=ci1f9YdH58d/UYb47PBHIxO4Pxkr6MqYx8qHSYfvxwwSx3rcvGRLFllkTVJPJifIz3 jpychqd3l5O355C48gLzItK0er3E6uh1TERZoFXSvAmiaBjUoCWvmhoMQ3mZGpc+GfC3 Gau/xGzeFng+CFRaxeYy9zKdgyHKRlQ0q3JQ3jME8Xw8U4K0e9lPIwMa85Vqckh1g7Jf m2u6gyt1vQkib1yTAs9HOtHlqUK/uqe2p4BPBxhCrEL2hLXAviZV7iieQ0IzinwlVJ1D mGR+VLjsEsuLw+zfyVHkcU3B94AOiYGt6qkfYxtGlEV84FldUNDp4hFfRG2y4KhLmLSw XWAQ== 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=HGxCZ4JNYCq3gVpScan/Ogqigeh6hIBTvZskcKvfeBU=; b=ofUy6d+nCQHDWdgbqf8oNsfSJTASdLB5TVBiPDvi5EzGnc4z5IR0HKLnF97O3Wyakz BWsgcyQKZadarqcWy7IOzj0VpyduNO0jvQ1X4Vcwspsp7rimTdAdcFkEv81SNzAaVocD bArM3C2u9NyNlCB3TOxD9zDMDNFzZVyKSV5EFfOQPpYguIDohXojzU9VnQugnwaalT12 4lWtXR+V57xfSSgyeUxKBBBnBQ3F6FCSxdyZKA97fALaWZ5Gkso8WzGkNrOa2cCnZGP7 /oWxrMx2uOSZPd6lMKaVVfWg4qBT+u3Mpw/WOUDTp9n1/O7JyCZgeaM3o2jIqRnAJgEw lFvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DRZRSP4n; 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 el22si1069302ejc.362.2020.12.09.09.11.33; Wed, 09 Dec 2020 09:11:57 -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=DRZRSP4n; 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 S1731866AbgLIRJt (ORCPT + 99 others); Wed, 9 Dec 2020 12:09:49 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:3632 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730993AbgLIRJc (ORCPT ); Wed, 9 Dec 2020 12:09:32 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0B9H2jvh064768; Wed, 9 Dec 2020 12:08:35 -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=HGxCZ4JNYCq3gVpScan/Ogqigeh6hIBTvZskcKvfeBU=; b=DRZRSP4nDWzlPeLni/WMS+orvFC9XZJDd8yPIldr2bsR4+S3ek+Q2X2Gz9KreRcEalEj gKfH8z0e2zRJqLcKUYfAfz7Q3ZbWd38jRjoW37PtcpSUzBUOCeYXQbFdPo1reVxn7ssO 8rCZ55aeykPd4oxQPzq0oxjau1aX7rQcnEJkSrzVlga+wmHXEW7G8UTpXjJ0Rr2eHE1F gIaKkvaKeRh03tcMp1xx+IOdvEsqkHcjBAObbcqDYIhmLMGsgi6j2eLfVnycPNy6WxFm eTXa2dDZr53SOAEPqdRHQSUIXBzEIWTkZ56TfuU85iJsjuwI3OQcKsSS3DfXWGRJbINV SQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35b20tsbxy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 12:08:35 -0500 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0B9H2qBN065423; Wed, 9 Dec 2020 12:08:34 -0500 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 35b20tsbxq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 12:08:34 -0500 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B9H225l004510; Wed, 9 Dec 2020 17:08:33 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma01dal.us.ibm.com with ESMTP id 3581u9hb3s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 17:08:33 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B9H8WII27132238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Dec 2020 17:08:32 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DE6D7805E; Wed, 9 Dec 2020 17:08:32 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B33EB7805F; Wed, 9 Dec 2020 17:08:31 +0000 (GMT) Received: from sofia.ibm.com (unknown [9.199.58.223]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 9 Dec 2020 17:08:31 +0000 (GMT) Received: by sofia.ibm.com (Postfix, from userid 1000) id 548652E35A0; Wed, 9 Dec 2020 22:38:28 +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 v2 0/5] Extend Parsing "ibm,thread-groups" for Shared-L2 information Date: Wed, 9 Dec 2020 22:38:15 +0530 Message-Id: <1607533700-5546-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-09_14:2020-12-09,2020-12-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 spamscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 impostorscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012090116 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 v1 can be found here : https://lore.kernel.org/linuxppc-dev/1607057327-29822-1-git-send-email-ego@linux.vnet.ibm.com/T/#m0fabffa1ea1a2807b362f25c849bb19415216520 The key changes from v1 are as follows to 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 | 1 + arch/powerpc/kernel/cacheinfo.c | 34 ++++-- arch/powerpc/kernel/smp.c | 241 ++++++++++++++++++++++++++++------------ 3 files changed, 197 insertions(+), 79 deletions(-) -- 1.9.4