Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1231200ybt; Thu, 18 Jun 2020 03:52:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8lz5K5UwkDF4uVVrBB7HecZAgH82tQm8qtXK6yBxeY5+JXY3fwsQai96V+oRBzq1RHvLL X-Received: by 2002:a17:906:7f95:: with SMTP id f21mr3252145ejr.554.1592477567063; Thu, 18 Jun 2020 03:52:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592477567; cv=none; d=google.com; s=arc-20160816; b=TI/frkkFYfmG8JIa/IOHBqIaISVju0SqGRquD6YXc73IzJnqfCMXd6fzvYxmTYe4Gm J9lAVgS4xU8LVHqMPYYhztvwf2dELKskjbTtMTsp/stg7I/I5Lt6V8hz/K0VfpMj2E7y /w2/aDkkIj93kaSfCScfkSIfyLTkLf6ZTU2Hy60oYgYY+T0975YJx0GvUd5o2IZqCQ1u df+GEr0VA7IHzfQQ4yvjGBAccrdpnpktXZ5WM+Gultn3PLh2X6+WHYtLI63Z0xoChISc O9JGlQQz3W9J6QdPA4jqq+vnIAdtziCIM7sdFrsRu7kz5eoRbWA0qjBJLrHOXXsb/2mA fesg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=8xoQ6boXL49PfRGcncMFjyyvBOIFVwLsNRoKtIzC2Ow=; b=oleUCek/neL5ennW+ui6s7NOytXhy7Co7MqJrIzGxWwjXonSONryJM2P8lrM8ts6Jg 8gAWYSfTJEmtFOkZdrLLSCXNYHtctxHmJ2thbnFqs32EHwzVu3m4gd6o/iOGf4G51g2x cf7ltUVx06MRqu2e6zwvsLpJldh5QTIZxPRk63QB9HPziQihBs2WBd7xxZbr8tEvGMAj j3PGESHVeubHoKRXz7a5JYKr/GE5WFawo9rdiQEAwDJZffGSKyqsACWgosG4RT389Vi8 FY5NFhgxxJYur4uUXeUuk9eZGC0EAypFwmj4Y0SNCKaocoOrJ3t8KrrHBtvoEgfExPh1 0UHg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si1610342edn.427.2020.06.18.03.52.23; Thu, 18 Jun 2020 03:52: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729358AbgFRKuT (ORCPT + 99 others); Thu, 18 Jun 2020 06:50:19 -0400 Received: from foss.arm.com ([217.140.110.172]:47882 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728956AbgFRKuP (ORCPT ); Thu, 18 Jun 2020 06:50:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 85C5431B; Thu, 18 Jun 2020 03:50:14 -0700 (PDT) Received: from [192.168.0.110] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9935A3F71F; Thu, 18 Jun 2020 03:50:12 -0700 (PDT) Subject: Re: [PATCH v5 1/7] arm64: perf: Add missing ISB in armv8pmu_enable_event() To: Stephen Boyd , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: mark.rutland@arm.com, Julien Thierry , Peter Zijlstra , maz@kernel.org, Jiri Olsa , Will Deacon , Arnaldo Carvalho de Melo , Alexander Shishkin , Ingo Molnar , catalin.marinas@arm.com, Namhyung Kim , will@kernel.org, Julien Thierry References: <20200617113851.607706-1-alexandru.elisei@arm.com> <20200617113851.607706-2-alexandru.elisei@arm.com> <159242406774.62212.13909672383879587787@swboyd.mtv.corp.google.com> From: Alexandru Elisei Message-ID: Date: Thu, 18 Jun 2020 11:50:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <159242406774.62212.13909672383879587787@swboyd.mtv.corp.google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stephen, Thank you very much for taking the time to review the patches! Comments below. On 6/17/20 9:01 PM, Stephen Boyd wrote: > Quoting Alexandru Elisei (2020-06-17 04:38:45) >> Writes to the PMXEVTYPER_EL0 register are not self-synchronising. In >> armv8pmu_enable_event(), the PE can reorder configuring the event type >> after we have enabled the counter and the interrupt. This can lead to an >> interrupt being asserted because the of the previous event type that we > 'because the of the' doesn't read properly. Typo on my part, will fix it. > >> were counting, not the one that we've just enabled. >> >> The same rationale applies to writes to the PMINTENSET_EL1 register. The PE >> can reorder enabling the interrupt at any point in the future after we have >> enabled the event. >> >> Prevent both situations from happening by adding an ISB just before we >> enable the event counter. >> >> diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c >> index 4d7879484cec..ee180b2a5b39 100644 >> --- a/arch/arm64/kernel/perf_event.c >> +++ b/arch/arm64/kernel/perf_event.c >> @@ -605,6 +605,7 @@ static void armv8pmu_enable_event(struct perf_event *event) >> * Enable interrupt for this counter >> */ >> armv8pmu_enable_event_irq(event); >> + isb(); > Please add a comment before the isb() explaining the situation. Nobody > knows what this is for when reading the code and they don't want to do > git archaeology to figure it out. That's a good idea, I'll do that. Thanks, Alex