Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A50BC4360F for ; Wed, 3 Apr 2019 07:26:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0622E20830 for ; Wed, 3 Apr 2019 07:26:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kf7TXPUa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0622E20830 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=H/4z8LFU232TkJUVdox4z6awogRKiAXuEeiv8TBg7UM=; b=kf7TXPUa4QyOCs FF3LCPP0PLEI5qIbM3HJk7IErUfBXO+G7ohnWONnGs5TrpNSRXwTMkellluwEui6QxWuaSbSRkPaJ uD16/cGXrN5Lagphub5lZN8w+ptZQ6SIWgavgfB+Y/5gWEGgE8Hs8cB5f0hLWikkALmySdBd2XsvC v3Z5aMorR6LAFYYebmr654Z64+oTsdCTd4p6a6c2ybrYalGVTBBh4REXokW1wZkMKTpDyrhCWmzH+ Wh8R17wwBb527DeOllwwzKHo8CB7y4ElpYghpULGlipagpYzCmCaxrD2QJ2pqEe8lGr8euGOA99uH BFHix2H1EfkNqOcN453g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBaI0-0000JX-Tw; Wed, 03 Apr 2019 07:26:28 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBaHx-0000J7-Of for linux-arm-kernel@lists.infradead.org; Wed, 03 Apr 2019 07:26:27 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 35C8080D; Wed, 3 Apr 2019 00:26:24 -0700 (PDT) Received: from [10.1.197.45] (e112298-lin.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1B7D93F68F; Wed, 3 Apr 2019 00:26:21 -0700 (PDT) Subject: Re: [PATCH] arm64: perf: Do not write event type for cycle counter To: Mark Rutland References: <1553766545-27692-1-git-send-email-julien.thierry@arm.com> <20190401080217.r27dgjc43xa5ruzr@blommer> <399b05e9-e309-d5c5-4d41-a672eb4c5d5c@arm.com> <20190403031058.ouek6ecs2xy4dyct@blommer> From: Julien Thierry Message-ID: <2e42ec1f-cc16-d33b-5419-4407c1075d6a@arm.com> Date: Wed, 3 Apr 2019 08:26:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190403031058.ouek6ecs2xy4dyct@blommer> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190403_002625_807314_6EBC036A X-CRM114-Status: GOOD ( 20.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , Catalin Marinas , Jiri Olsa , Will Deacon , Arnaldo Carvalho de Melo , Alexander Shishkin , Ingo Molnar , huawei.libin@huawei.com, guohanjun@huawei.com, Namhyung Kim , liwei391@huawei.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 03/04/2019 04:10, Mark Rutland wrote: > On Tue, Apr 02, 2019 at 04:42:58PM +0100, Julien Thierry wrote: >> >> >> On 01/04/2019 09:02, Mark Rutland wrote: >>> On Thu, Mar 28, 2019 at 09:49:05AM +0000, Julien Thierry wrote: >>>> Perf events using the dedicated cycle counter do not need to program the >>>> event type, the counter only ever counts that kind of events. >>> >>> Good catch! >>> >>>> Even worse, trying to program an event type without excluding the >>>> cycle counter index might end up in the modification of the type of >>>> event counted by another perf event. >>> >>> IIUC, we shouldn't affect an unrelated event. The ARM ARM says: >>> >>> When PMSELR_EL0.SEL == 31, this register accesses PMCCFILTR_EL0. >>> >> >> Ah yes, I missed that fact. >> >>> ... and AFAICT we program PMSELR_EL0 appropriately to select the cycle counter. >>> >>> I think we're erroneously programming the RES0 bits of PMCCFILTR_EL0, but we're >>> also relying on this write to clear all the filter controls in the high bits of >>> PMCCFILTR_EL0, which otherwise reset to UNKNOWN values. >>> >>> Given that, I think we also need to explicitly reset PMCCFILTR_EL0 in >>> armv8pmu_reset(). >>> >> >> I just realized that for the PMCCFILTR_EL0 there is also the exclude >> control bits for the event. Do those not need to be set when we enable >> the event rather than on reset? > > Yes, you're right. We will need to configure thos, so just doing the reset > isn't enough. > >> Now, I'm thinking what we need is to use a different mask than >> EVTYPE_MASK (one that excludes the event bits) when setting >> PMCCFILTR_EL0, but still do that when enabling an event using the cycle >> counter. >> >> Does that approach sound correct? Or am I missing something that would >> allow us to only set that upon reset? > > That sounds right to me! > > It would perhaps be nicer if we could configure event->hwc.config_base to be > the raw register value in all cases, but it looks like that's going to be more > painful than special-casing the cycle counter here. > Right, I'm gonna need to special case the cycle counter to adapt the event type writing to this patch[1]. But since this is not as critical/beneficial as I initially thought, I'll just incorporate the special-casing to the PMU interrupt as NMI series. [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2019-March/640535.html Thanks, -- Julien Thierry _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel