Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3159150pxk; Mon, 21 Sep 2020 06:46:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypHjjkuUIDcdWCw3fAH0BszRKds5BD61oKqQV+5axAN1fCxzqf4O6a0gISO9DFCvjhbyzf X-Received: by 2002:a50:fc83:: with SMTP id f3mr50803551edq.256.1600696007150; Mon, 21 Sep 2020 06:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600696007; cv=none; d=google.com; s=arc-20160816; b=gN876jPvHDsg1piZVZfsltiLOE8UPuv7R1Fx/QQ2RupoTI0T4MdhG6zEzNLcUja3Zw 9IXAszeID7hE7UObW/NvrI8W3TtbR9JoBvdQ4KetjR28omuVQPw87RVTPjB3Y+VnXRsP CNYfdaOAFSJcGk3r7RwJCgxvC5L2EHNumTpL8/Y1mYBwI0r/noiEqipDvTEBA2TOr2lP G2SLUzz7LbOuRKEmvB1NhaBlCgSqEjFIQWpWhutKUlkhuLNJa0Vmjiljq4B7Kzn9TKlG pro09nIQhs5ojth4wPIOjPvqmrHaIQnJAzEAQrMKfKGLeAGBQiDu/m2x1u1M8ThtbFtv JT4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=lViwxF4OzwDbbBvJdXU55WeSqgE4vaYWxXPLhLKc4d0=; b=JvL/gZVar0Y7UAghdXl1L2zduHqcNBoHvNCARvZ/bk7NAAg5zhi91spkty+Qf8fy3H sF8AZkG7ABwAes5s24hpNHS6OdyzjBsfOEvlwcHHSGOYbfRAnxvPAKgVRWQcsspzZCV5 jDSn28wFjT8675EySvP4Lf3SeUt7B7xiwpZ4ip2zwLJTNaFWcND2jyud7YiEwICTwKAF SMK+swjXcDu7FTPV56VyJfzLiR0LI+JiUyzeDlMUi0gFMZ42gn98cZ0eqevpjJCcl4+g +qjQzwBkd4ldDuHOPiSrh3Lc8UQT0A5hm/Itu2kJ8Sr6sjha8HoihS5jUrR7vQ4TJ/Cr UdTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=glGVInNp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m11si5515260edp.265.2020.09.21.06.46.23; Mon, 21 Sep 2020 06:46:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=glGVInNp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727339AbgIUNoJ (ORCPT + 99 others); Mon, 21 Sep 2020 09:44:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:56670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726830AbgIUNoF (ORCPT ); Mon, 21 Sep 2020 09:44:05 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B269220888; Mon, 21 Sep 2020 13:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600695844; bh=MWMbTeQXgsSrcke9ClQCdlLOJJmrD/yGsUoAPqwbB1c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=glGVInNpxoukIMGGUaJ7ob5aWbbmyaI3ZQ0mPg5DXA71utsj8OfFA/4d6AD47Gn3h ee1v1lAsMEkPgVJWp0qDUrlMre9NV6ogj4CXNgd+OVS7lNP+AnmAXrmlOg8xlOo6sM FLIUhvOeKaR2/dW/EY0bbeqkzOOHXbaDFSykNsoM= Date: Mon, 21 Sep 2020 14:43:58 +0100 From: Will Deacon To: Alexandru Elisei Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, maz@kernel.org, catalin.marinas@arm.com, swboyd@chromium.org, sumit.garg@linaro.org, Julien Thierry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Julien Thierry Subject: Re: [PATCH v6 2/7] arm64: perf: Avoid PMXEV* indirection Message-ID: <20200921134357.GL2139@willie-the-truck> References: <20200819133419.526889-1-alexandru.elisei@arm.com> <20200819133419.526889-3-alexandru.elisei@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200819133419.526889-3-alexandru.elisei@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 02:34:14PM +0100, Alexandru Elisei wrote: > From: Mark Rutland > > Currently we access the counter registers and their respective type > registers indirectly. This requires us to write to PMSELR, issue an ISB, > then access the relevant PMXEV* registers. > > This is unfortunate, because: > > * Under virtualization, accessing one register requires two traps to > the hypervisor, even though we could access the register directly with > a single trap. > > * We have to issue an ISB which we could otherwise avoid the cost of. > > * When we use NMIs, the NMI handler will have to save/restore the select > register in case the code it preempted was attempting to access a > counter or its type register. > > We can avoid these issues by directly accessing the relevant registers. > This patch adds helpers to do so. > > In armv8pmu_enable_event() we still need the ISB to prevent the PE from > reordering the write to PMINTENSET_EL1 register. If the interrupt is > enabled before we disable the counter and the new event is configured, > we might get an interrupt triggered by the previously programmed event > overflowing, but which we wrongly attribute to the event that we are > enabling. > > In the process, remove the comment that refers to the ARMv7 PMU. > > Cc: Julien Thierry > Cc: Will Deacon > Cc: Peter Zijlstra > Cc: Ingo Molnar > Cc: Arnaldo Carvalho de Melo > Cc: Alexander Shishkin > Cc: Jiri Olsa > Cc: Namhyung Kim > Cc: Catalin Marinas > Signed-off-by: Mark Rutland > [Julien T.: Don't inline read/write functions to avoid big code-size > increase, remove unused read_pmevtypern function, > fix counter index issue.] > Signed-off-by: Julien Thierry > [Removed comment, removed trailing semicolons in macros, added ISB] nit: but it's customary to prefix these with your name, so it's easy to figure out who made changes (like Julien did above). (similar comment for other patches in this series) > @@ -620,9 +686,14 @@ static void armv8pmu_enable_event(struct perf_event *event) > * Disable counter > */ > armv8pmu_disable_event_counter(event); > + /* > + * Make sure the effects of disabling the counter are visible before we > + * start configuring the event. > + */ > + isb(); With the isb() added by patch 1, why don't we just make these implicit in armv8_{enable,disable}_event_counter() ? Will