From patchwork Tue Mar 31 12:43:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Athira Rajeev X-Patchwork-Id: 1264739 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48s8QV6zSDz9sPJ for ; Tue, 31 Mar 2020 23:53:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48s8QV5BbWzDrD2 for ; Tue, 31 Mar 2020 23:53:38 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=atrajeev@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48s8CJ07pszDrC0 for ; Tue, 31 Mar 2020 23:43:55 +1100 (AEDT) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02VCctPK081359 for ; Tue, 31 Mar 2020 08:43:53 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 303uj38690-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 31 Mar 2020 08:43:53 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 31 Mar 2020 13:43:39 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 31 Mar 2020 13:43:36 +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 02VChlRC60620960 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Mar 2020 12:43:47 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBF0B4C052; Tue, 31 Mar 2020 12:43:47 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 20D054C04E; Tue, 31 Mar 2020 12:43:47 +0000 (GMT) Received: from localhost.localdomain.localdomain (unknown [9.199.41.176]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 31 Mar 2020 12:43:46 +0000 (GMT) From: Athira Rajeev To: mpe@ellerman.id.au Subject: [PATCH v2] powerpc/perf: Add documentation around use of "ppc_set_pmu_inuse" in PMU core-book3s Date: Tue, 31 Mar 2020 08:43:46 -0400 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 x-cbid: 20033112-4275-0000-0000-000003B6EB81 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20033112-4276-0000-0000-000038CC3B1B Message-Id: <1585658626-17896-1-git-send-email-atrajeev@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-03-31_04:2020-03-31, 2020-03-31 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 impostorscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 phishscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003310110 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maddy@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Madhavan Srinivasan "pmcregs_in_use" flag is part of lppaca (Virtual Process Area), which is used to indicate whether Performance Monitoring Unit (PMU) and PMU sprs are in-use and whether should it be saved/restored by hypervisor. ppc_set_pmu_inuse() is used to set/unset the VPA flag "pmcregs_in_use". "pmcregs_in_use" flag is set in "power_pmu_enable" via ppc_set_pmu_inuse(1) and it is unset when there are no active events (n_events == 0 condition). Patch here adds documentation on the ppc_set_pmu_inuse() usage. Signed-off-by: Madhavan Srinivasan Signed-off-by: Athira Rajeev --- Changes in v2: - Corrected the patch author information arch/powerpc/perf/core-book3s.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index 3086055..48bfdc9 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -1285,6 +1285,11 @@ static void power_pmu_enable(struct pmu *pmu) goto out; if (cpuhw->n_events == 0) { + /* + * Indicate PMU not in-use to Hypervisor. + * We end-up here via "ctx_sched_out()" from common code and + * "power_pmu_del()". + */ ppc_set_pmu_inuse(0); goto out; } @@ -1341,6 +1346,11 @@ static void power_pmu_enable(struct pmu *pmu) * Write the new configuration to MMCR* with the freeze * bit set and set the hardware events to their initial values. * Then unfreeze the events. + * ppc_set_pmu_inuse(1): "power_pmu_enable" will unset the + * "pmcregs_in_use" flag when a previous profiling/sampling session + * is completed and un-setting of flag will notify the Hypervisor to + * drop save/restore of PMU sprs. Now that PMU need to be enabled, first + * set the "pmcregs_in_use" flag in VPA. */ ppc_set_pmu_inuse(1); mtspr(SPRN_MMCRA, cpuhw->mmcr[2] & ~MMCRA_SAMPLE_ENABLE);