Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1766950imm; Wed, 10 Oct 2018 22:34:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV61lGWQJgZUHcHqSC1m+pWu+shE241WllNFV3L5Kbc9PvkAE8sTuwKCTGjD3u1poq3Qz6xBD X-Received: by 2002:a63:5f05:: with SMTP id t5-v6mr127578pgb.352.1539236081432; Wed, 10 Oct 2018 22:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539236081; cv=none; d=google.com; s=arc-20160816; b=joQ0PXrcqs/wQc/ddOvakuZIFu/TRAHH7n7JvJkfNMFAFOp6XSevxnqbqk31WEGsWl yJXTS7PfhUGPUDUfwkOU7RmmtS3mx8hkDlp51PCShXHO2fbAgqQn5U/dtSVFuPVfnX+E nLwIjd+7y4xTUf4qPxNUE2aqId9ve85ORseZJQgVmRx3mhckcc9qwp6cFxmaIEgdlcy/ 8x8bqUdzomu0koHooM3bBQdAzMZ12D6KxcLlssw52lxdEAJCG2VaDBTKi7fvQN1/kToG YQWGHUSPE/Hvn5L4cEfCnmrpFXYRWYwahnq+ScfTvFTPV89/cl6ZjQMd2EXJnseetuPL z67A== 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=qdE++JewazKdZzUo10GJ10ykX1VXSZ02C9lrvZvj4bw=; b=VJL708pX5dr657koGlwDqgUtSiEXTOPQvIlrS0h9I20LlggmqmWFnY7xps20yQLoxx 3sdwkaO4Dj/Xx8T9H9LgZc36UeJ8UKPSeKARlCkUzVAI/ZBn+okbmdAKqna+Qkv68rz4 pd2rBesE86Udsb3TT7wzoS+5gUAGJV1PpqfhKkbBhcx88eMqZDQDwDtsk8w1IoR9+jyS XF1DHxossh4VZlgWjIOBlL+Nf/Z29E7KEPhqWuLmZnHbPx9L96BkeDW4346caB/CI+Ni yYSTRuJFpZUOmwrPcL8MjgIWYuScDmGpdHGIjchEZpBnnu2PZWnc5D7RvBlgGbWDCm3S DEJQ== 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 g5-v6si26433854pgf.565.2018.10.10.22.34.26; Wed, 10 Oct 2018 22:34:41 -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 S1727847AbeJKM7I (ORCPT + 99 others); Thu, 11 Oct 2018 08:59:08 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39874 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727245AbeJKM6x (ORCPT ); Thu, 11 Oct 2018 08:58:53 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9B5Swe2065050 for ; Thu, 11 Oct 2018 01:33:17 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n1wcmxex4-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 e35.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 b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e35.co.us.ibm.com (192.168.1.135) 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 b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9B5XBbj27263052 (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 293C4BE04F; 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 D200ABE054; 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 4D3B62E3D80; 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 3/3] powerpc/cacheinfo: Report the correct shared_cpu_map on big-cores Date: Thu, 11 Oct 2018 11:03:03 +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-0012-0000-0000-000016C613D4 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-0013-0000-0000-000054B666B1 Message-Id: <1539235983-25259-4-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=817 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" Currently on POWER9 SMT8 cores systems, in sysfs, we report the shared_cache_map for L1 caches (both data and instruction) to be the cpu-ids of the threads in SMT8 cores. This is incorrect since on POWER9 SMT8 cores there are two groups of threads, each of which shares its own L1 cache. This patch addresses this by reporting the shared_cpu_map correctly in sysfs for L1 caches. Before the patch /sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_map : 000000ff /sys/devices/system/cpu/cpu0/cache/index1/shared_cpu_map : 000000ff /sys/devices/system/cpu/cpu1/cache/index0/shared_cpu_map : 000000ff /sys/devices/system/cpu/cpu1/cache/index1/shared_cpu_map : 000000ff After the patch /sys/devices/system/cpu/cpu0/cache/index0/shared_cpu_map : 00000055 /sys/devices/system/cpu/cpu0/cache/index1/shared_cpu_map : 00000055 /sys/devices/system/cpu/cpu1/cache/index0/shared_cpu_map : 000000aa /sys/devices/system/cpu/cpu1/cache/index1/shared_cpu_map : 000000aa Signed-off-by: Gautham R. Shenoy --- arch/powerpc/kernel/cacheinfo.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c index a8f20e5..be57bd0 100644 --- a/arch/powerpc/kernel/cacheinfo.c +++ b/arch/powerpc/kernel/cacheinfo.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include "cacheinfo.h" @@ -627,17 +629,48 @@ static ssize_t level_show(struct kobject *k, struct kobj_attribute *attr, char * static struct kobj_attribute cache_level_attr = __ATTR(level, 0444, level_show, NULL); +static unsigned int index_dir_to_cpu(struct cache_index_dir *index) +{ + struct kobject *index_dir_kobj = &index->kobj; + struct kobject *cache_dir_kobj = index_dir_kobj->parent; + struct kobject *cpu_dev_kobj = cache_dir_kobj->parent; + struct device *dev = kobj_to_dev(cpu_dev_kobj); + + return dev->id; +} + +/* + * On big-core systems, each core has two groups of CPUs each of which + * has its own L1-cache. The thread-siblings which share l1-cache with + * @cpu can be obtained via cpu_smallcore_mask(). + */ +static const struct cpumask *get_big_core_shared_cpu_map(int cpu, struct cache *cache) +{ + if (cache->level == 1) + return cpu_smallcore_mask(cpu); + + return &cache->shared_cpu_map; +} + static ssize_t shared_cpu_map_show(struct kobject *k, struct kobj_attribute *attr, char *buf) { struct cache_index_dir *index; struct cache *cache; - int ret; + const struct cpumask *mask; + int ret, cpu; index = kobj_to_cache_index_dir(k); cache = index->cache; + if (has_big_cores) { + cpu = index_dir_to_cpu(index); + mask = get_big_core_shared_cpu_map(cpu, cache); + } else { + mask = &cache->shared_cpu_map; + } + ret = scnprintf(buf, PAGE_SIZE - 1, "%*pb\n", - cpumask_pr_args(&cache->shared_cpu_map)); + cpumask_pr_args(mask)); buf[ret++] = '\n'; buf[ret] = '\0'; return ret; -- 1.9.4