Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3013938yba; Tue, 16 Apr 2019 02:51:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSsmDJy0lQnZ+/U7+uoMAyp6aJwNYrb0/ifxTWqojP3VMgtKLquY6VlFSVgFKE71tXpOrD X-Received: by 2002:a63:525f:: with SMTP id s31mr75241944pgl.172.1555408260204; Tue, 16 Apr 2019 02:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555408260; cv=none; d=google.com; s=arc-20160816; b=TUyO5Xb6hKMMNTT5GYzxSvubCRqS0JVfG/qk+HYwMylPwo8JKg572YFuS0EvkCHaiB X6TFmalCSsJdvrCX20I4kxUjVUa/IL50xJHCXSzQNznQBMaGrvvS5iZcQ2lcNwqpILzF LKebrVFyrVoh+VKqQjISgbdmvn/I1wzzZw/yAYHl3S17U5zWzhdMSeTpXfvZ8xOMW1lh RzArqm5Bmn2NOXsLyLBNJ7qC6e74x72hBnKCf/92yuDbx6yVCnyj/ixeVJ9qzLdBcH9z sI+elLh0N9G/KaVb3N6mvVzcDadRK191mkTGqfiJXyOWp1NUefv4U/tM/6e/oUbaIS+E fPRw== 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=N82AoNbwkYx9zJbx6rOwIt/XgGW+TQmEarXlrYm9uT0=; b=xU3YnWx5RIU/1o5r9JCmSXAZGJt58Z/V/mWJEKwePIqpA6Kv7O4FSaCKzT0pPAif3k YgPZNI+SUtZuYnuSPdEoz/Py9c2YERbnOr/+hYfV72ICwkStThR/M4mYcf5TFwXIvvhv mRN0DqGqaRD+ydDgF3SwulyxP/NbqqD8onkP4tDWY6v7oAbujB64eaIasWWImyC676yw SZVIR/8RXeOfunia8JM6GnAx6s02dpTEENu9jWhv7ckJHxirH4kJ9iDqP8Q9h+/HPRXH oIMR3rNS5UJXhjoF47zcTe/YxdFKglii8lbxRrxieouGPVGcu21lmIHbpVcY//otHYJW CVjA== 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 j25si35344067pga.22.2019.04.16.02.50.44; Tue, 16 Apr 2019 02:51: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 S1728952AbfDPJst (ORCPT + 99 others); Tue, 16 Apr 2019 05:48:49 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51482 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726895AbfDPJss (ORCPT ); Tue, 16 Apr 2019 05:48:48 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3G9irSr066880 for ; Tue, 16 Apr 2019 05:48:47 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rwcf68tvk-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 16 Apr 2019 05:48:47 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Apr 2019 10:48:45 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 16 Apr 2019 10:48:42 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3G9mfKD43843742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Apr 2019 09:48:41 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4968C4C063; Tue, 16 Apr 2019 09:48:41 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 320A84C073; Tue, 16 Apr 2019 09:48:40 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.145.144.43]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 16 Apr 2019 09:48:40 +0000 (GMT) From: Anju T Sudhakar To: mpe@ellerman.id.au Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, maddy@linux.vnet.ibm.com, anju@linux.vnet.ibm.com Subject: [PATCH v4 2/5] powerpc/perf: Rearrange setting of ldbar for thread-imc Date: Tue, 16 Apr 2019 15:18:28 +0530 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190416094831.7264-1-anju@linux.vnet.ibm.com> References: <20190416094831.7264-1-anju@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19041609-0028-0000-0000-00000361597D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19041609-0029-0000-0000-000024209024 Message-Id: <20190416094831.7264-3-anju@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-16_03:,, 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 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904160067 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org LDBAR holds the memory address allocated for each cpu. For thread-imc the mode bit (i.e bit 1) of LDBAR is set to accumulation. Currently, ldbar is loaded with per cpu memory address and mode set to accumulation at boot time. To enable trace-imc, the mode bit of ldbar should be set to 'trace'. So to accommodate trace-mode of IMC, reposition setting of ldbar for thread-imc to thread_imc_event_add(). Also reset ldbar at thread_imc_event_del(). Signed-off-by: Anju T Sudhakar Reviewed-by: Madhavan Srinivasan --- arch/powerpc/perf/imc-pmu.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c index b1c37cc3fa98..51f1d3eaaa6d 100644 --- a/arch/powerpc/perf/imc-pmu.c +++ b/arch/powerpc/perf/imc-pmu.c @@ -788,8 +788,11 @@ static int core_imc_event_init(struct perf_event *event) } /* - * Allocates a page of memory for each of the online cpus, and write the - * physical base address of that page to the LDBAR for that cpu. + * Allocates a page of memory for each of the online cpus, and load + * LDBAR with 0. + * The physical base address of the page allocated for a cpu will be + * written to the LDBAR for that cpu, when the thread-imc event + * is added. * * LDBAR Register Layout: * @@ -807,7 +810,7 @@ static int core_imc_event_init(struct perf_event *event) */ static int thread_imc_mem_alloc(int cpu_id, int size) { - u64 ldbar_value, *local_mem = per_cpu(thread_imc_mem, cpu_id); + u64 *local_mem = per_cpu(thread_imc_mem, cpu_id); int nid = cpu_to_node(cpu_id); if (!local_mem) { @@ -824,9 +827,7 @@ static int thread_imc_mem_alloc(int cpu_id, int size) per_cpu(thread_imc_mem, cpu_id) = local_mem; } - ldbar_value = ((u64)local_mem & THREAD_IMC_LDBAR_MASK) | THREAD_IMC_ENABLE; - - mtspr(SPRN_LDBAR, ldbar_value); + mtspr(SPRN_LDBAR, 0); return 0; } @@ -977,6 +978,7 @@ static int thread_imc_event_add(struct perf_event *event, int flags) { int core_id; struct imc_pmu_ref *ref; + u64 ldbar_value, *local_mem = per_cpu(thread_imc_mem, smp_processor_id()); if (flags & PERF_EF_START) imc_event_start(event, flags); @@ -985,6 +987,9 @@ static int thread_imc_event_add(struct perf_event *event, int flags) return -EINVAL; core_id = smp_processor_id() / threads_per_core; + ldbar_value = ((u64)local_mem & THREAD_IMC_LDBAR_MASK) | THREAD_IMC_ENABLE; + mtspr(SPRN_LDBAR, ldbar_value); + /* * imc pmus are enabled only when it is used. * See if this is triggered for the first time. @@ -1016,11 +1021,7 @@ static void thread_imc_event_del(struct perf_event *event, int flags) int core_id; struct imc_pmu_ref *ref; - /* - * Take a snapshot and calculate the delta and update - * the event counter values. - */ - imc_event_update(event); + mtspr(SPRN_LDBAR, 0); core_id = smp_processor_id() / threads_per_core; ref = &core_imc_refc[core_id]; @@ -1039,6 +1040,11 @@ static void thread_imc_event_del(struct perf_event *event, int flags) ref->refc = 0; } mutex_unlock(&ref->lock); + /* + * Take a snapshot and calculate the delta and update + * the event counter values. + */ + imc_event_update(event); } /* update_pmu_ops : Populate the appropriate operations for "pmu" */ -- 2.17.2