From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752315AbcHHMMx (ORCPT ); Mon, 8 Aug 2016 08:12:53 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:44098 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752014AbcHHMMv (ORCPT ); Mon, 8 Aug 2016 08:12:51 -0400 Date: Mon, 8 Aug 2016 14:12:46 +0200 From: Peter Zijlstra To: Mark Rutland Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin Subject: Re: [PATCH] perf: sched out groups atomically Message-ID: <20160808121246.GD6879@twins.programming.kicks-ass.net> References: <1469553141-28314-1-git-send-email-mark.rutland@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1469553141-28314-1-git-send-email-mark.rutland@arm.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 26, 2016 at 06:12:21PM +0100, Mark Rutland wrote: > Groups of events are supposed to be scheduled atomically, such that it > is possible to derive meaningful ratios between their values. > > We take great pains to achieve this when scheduling event groups to a > PMU in group_sched_in(), calling {start,commit}_txn() (which fall back > to perf_pmu_{disable,enable}() if necessary) to provide this guarantee. > However we don't mirror this in group_sched_out(), and in some cases > events will not be scheduled out atomically. > > For example, if we disable an event group with PERF_EVENT_IOC_DISABLE, > we'll cross-call __perf_event_disable() for the group leader, and will > call group_sched_out() without having first disabled the relevant PMU. > We will disable/enable the PMU around each pmu->del() call, but between > each call the PMU will be enabled and events may count. > > Avoid this by explicitly disabling and enabling the PMU around event > removal in group_sched_out(), mirroring what we do in group_sched_in(). Thanks!