Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1376997imu; Wed, 28 Nov 2018 08:40:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/XK0DM9EiwIVA1ViraJ3Fu1fBYpMSveJbqfK0TjGFHwSEnPWyyufqR0ur/d6Z7OBciaDco6 X-Received: by 2002:a63:e19:: with SMTP id d25mr33653830pgl.272.1543423230298; Wed, 28 Nov 2018 08:40:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543423230; cv=none; d=google.com; s=arc-20160816; b=TGBJkiZdh5LVWUmg0Cp9vnCIEFRLZACn9/7LnraxP2wrWVdZ/3fGqWBjqpZvJ+vmRS k1myw413otzF5l5/fVVFFGiKeV2ZMDkXJkdXT9ijZK5KYPazTjHWkweSqkJb22QCm92G Q6/e3cwkJS9t4AdsxZUXe0L8JHqy29dFJYeTRSkakaPb59QAKObNkbZo0fpFb0P+sZCj Kty4XhQpk64GDO8DD8kAivyWkAwzrVKUuI5IxfGIPiFtTIEuA1qbmAnDqLc5NP8j6KRY AzOc5zLASWb/RbBP65LUtr9hQgqHlQE8rm5D0O66Upi7Zep/IJKe37y1ToocijYZZQrV 8EXQ== 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=oWuWoweYcWR29K9Bgv0SOnSp4t1HIhwTfEDDs60P0xo=; b=Kll98kCI3wKPgl2fXgmEKB1edjM1G4gwHbdUQc/rGLi42K8CplTV/AQ81KNd+aIbNn 0XfNgseoqScd9j5cNIp+DPxBAREoCThPHqJZwnSCv9dXhUjLr6nOKFMmBosw45NcB4GU dNncKrBryPxzG2kkWRN7wtKjEDlWda+m6HReZQCxfz08pQwpcK2ThaBnodTwi1RnKRuz YXXw40mqSFFJY1Dxb6WUgLmQIAUNBDfaI3fdmCmBVO/s1KyDTNPdTGX3CqvS/jb2f7if 6g6qoG9Es0upYtDkHbgEean4iP7ycHhTg4RDtc7wOGTNaFWOWJnTC8Oy4dMxXx+IeJAH S74Q== 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 p185si8530473pfg.112.2018.11.28.08.40.10; Wed, 28 Nov 2018 08:40:30 -0800 (PST) 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 S1729112AbeK2DkP (ORCPT + 99 others); Wed, 28 Nov 2018 22:40:15 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38876 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728141AbeK2DkO (ORCPT ); Wed, 28 Nov 2018 22:40:14 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wASGbpIQ063337 for ; Wed, 28 Nov 2018 11:37:58 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2p1wqguaw0-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 28 Nov 2018 11:37:56 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 28 Nov 2018 16:37:48 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 28 Nov 2018 16:37:47 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wASGbk8E15925432 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 28 Nov 2018 16:37:46 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A791AE056; Wed, 28 Nov 2018 16:37:46 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC536AE053; Wed, 28 Nov 2018 16:37:44 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.145.3.14]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 28 Nov 2018 16:37:44 +0000 (GMT) From: Anju T Sudhakar To: mpe@ellerman.id.au, linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, maddy@linux.vnet.ibm.com, anju@linux.vnet.ibm.com Subject: [PATCH 2/4] powerpc/perf: Rearrange setting of ldbar for thread-imc Date: Wed, 28 Nov 2018 22:07:33 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181128163735.29607-1-anju@linux.vnet.ibm.com> References: <20181128163735.29607-1-anju@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112816-0016-0000-0000-0000022E12ED X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112816-0017-0000-0000-0000328671A6 Message-Id: <20181128163735.29607-3-anju@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-28_09:,, 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=1011 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-1811280144 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 --- 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 f292a3f284f1..3bef46f8417d 100644 --- a/arch/powerpc/perf/imc-pmu.c +++ b/arch/powerpc/perf/imc-pmu.c @@ -806,8 +806,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: * @@ -825,7 +828,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) { @@ -842,9 +845,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; } @@ -995,6 +996,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); @@ -1003,6 +1005,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. @@ -1034,11 +1039,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]; @@ -1057,6 +1058,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.1