From patchwork Thu Nov 2 14:04:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Walbon X-Patchwork-Id: 833365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3ySRgX2pf0z9sNw; Fri, 3 Nov 2017 01:05:28 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1eAG7Y-0002HV-Mx; Thu, 02 Nov 2017 14:05:24 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] helo=mx0a-001b2d01.pphosted.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1eAG7W-0002Cx-4f for kernel-team@lists.ubuntu.com; Thu, 02 Nov 2017 14:05:22 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA2E4XDe003893 for ; Thu, 2 Nov 2017 10:05:21 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0b-001b2d01.pphosted.com with ESMTP id 2e01bc5uh5-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 02 Nov 2017 10:05:20 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 2 Nov 2017 10:05:19 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 2 Nov 2017 10:05:18 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vA2E5Gil34341028; Thu, 2 Nov 2017 14:05:17 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CD7FAE03B; Thu, 2 Nov 2017 10:06:04 -0400 (EDT) Received: from localhost (unknown [9.85.138.60]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id BE52DAE034; Thu, 2 Nov 2017 10:06:03 -0400 (EDT) From: Gustavo Walbon To: kernel-team@lists.ubuntu.com Subject: [Artful][PATCH 07/12] powerpc/perf/imc: Fix nest events on muti socket system Date: Thu, 2 Nov 2017 12:04:56 -0200 X-Mailer: git-send-email 2.13.3 In-Reply-To: <20171102140501.87671-1-gwalbon@linux.vnet.ibm.com> References: <20171102140501.87671-1-gwalbon@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17110214-0048-0000-0000-000001FF6933 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007997; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00940090; UDB=6.00474019; IPR=6.00720346; BA=6.00005666; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017836; XFM=3.00000015; UTC=2017-11-02 14:05:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110214-0049-0000-0000-0000430E79F0 Message-Id: <20171102140501.87671-8-gwalbon@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-02_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1711020178 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Anju T BugLink: https://bugs.launchpad.net/bugs/1481347 In a multi node system with discontiguous node ids, nest event values are not showing up properly. eg. lscpu output: NUMA node0 CPU(s): 0-15 NUMA node8 CPU(s): 16-31 Nest event values on such systems can be counted on CPUs <= 15: $./perf stat -e 'nest_powerbus0_imc/PM_PB_CYC/' -C 0-14 -I 1000 sleep 1000 # time counts unit events 1.000294577 30,17,24,42,880 nest_powerbus0_imc/PM_PB_CYC/ But not on CPUs >= 16: $./perf stat -e 'nest_powerbus0_imc/PM_PB_CYC/' -C 16-28 -I 1000 sleep 1000 # time counts unit events 1.000049902 nest_powerbus0_imc/PM_PB_CYC/ This is because, when fetching the reference count, the node id (which may be sparse) is used as the array index, not the node number (which is 0 based and contiguous). Fix it by using the node number as the array index. $./perf stat -e 'nest_powerbus0_imc/PM_PB_CYC/' -C 16-28 -I 1000 sleep 1000 # time counts unit events 1.000241961 26,12,35,28,704 nest_powerbus0_imc/PM_PB_CYC/ Signed-off-by: Anju T Sudhakar [mpe: Change log tweaks for clarity and brevity] Signed-off-by: Michael Ellerman (cherry-picked from 7efbae90892b7858f1d4873d34ffffbeb460ed8b) Signed-off-by: Gustavo Walbon --- arch/powerpc/perf/imc-pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c index 52017f6eafd9..a8f95f96d54b 100644 --- a/arch/powerpc/perf/imc-pmu.c +++ b/arch/powerpc/perf/imc-pmu.c @@ -1064,7 +1064,7 @@ static int init_nest_pmu_ref(void) */ for_each_possible_cpu(cpu) { nid = cpu_to_node(cpu); - for_each_online_node(i) { + for (i = 0; i < num_possible_nodes(); i++) { if (nest_imc_refc[i].id == nid) { per_cpu(local_nest_imc_refc, cpu) = &nest_imc_refc[i]; break;