Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933559AbcKJOLR (ORCPT ); Thu, 10 Nov 2016 09:11:17 -0500 Received: from foss.arm.com ([217.140.101.70]:49356 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933033AbcKJOLQ (ORCPT ); Thu, 10 Nov 2016 09:11:16 -0500 Date: Thu, 10 Nov 2016 14:10:37 +0000 From: Mark Rutland To: Peter Zijlstra Cc: kan.liang@intel.com, mingo@redhat.com, linux-kernel@vger.kernel.org, acme@kernel.org, tglx@linutronix.de, alexander.shishkin@linux.intel.com, vince@deater.net, eranian@google.com, andi@firstfloor.org Subject: Re: [PATCH] perf/core: introduce context per CPU event list Message-ID: <20161110141037.GE4418@leverpostej> References: <1478718286-12824-1-git-send-email-kan.liang@intel.com> <20161110083355.GO3568@worktop.programming.kicks-ass.net> <20161110110516.GA4418@leverpostej> <20161110113704.GU3142@twins.programming.kicks-ass.net> <20161110120423.GC4418@leverpostej> <20161110121253.GX3142@twins.programming.kicks-ass.net> <20161110122618.GD4418@leverpostej> <20161110125804.GT3117@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161110125804.GT3117@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1757 Lines: 45 On Thu, Nov 10, 2016 at 01:58:04PM +0100, Peter Zijlstra wrote: > On Thu, Nov 10, 2016 at 12:26:18PM +0000, Mark Rutland wrote: > > On Thu, Nov 10, 2016 at 01:12:53PM +0100, Peter Zijlstra wrote: > > > > Ah, so the tree would in fact only contain 'INACTIVE' events :-) > > > > Ah. :) > > > > That explains some of the magic, but... > > > > > That is, when no events are on the hardware, all events (if there are > > > any) are INACTIVE. > > > > > > Then on sched-in, we find the relevant subtree, and linearly try and > > > program all events from that subtree onto the PMU. Once adding an event > > > fails programming, we stop (like we do now). > > > > > > These programmed events transition from INACTIVE to ACTIVE, and we take > > > them out of the tree. > > > > > > Then on sched-out, we remove all events from the hardware, increase the > > > events their runtime value by however long they were ACTIVE, flip them > > > to INACTIVE and stuff them back in the tree. > > > > ... per the above, won't the tree also contain 'OFF' events (and > > 'ERROR', etc)? > > > > ... or do we keep them somewhere else (another list or sub-tree)? > > I don't think those need be tracked at all, they're immaterial for > actual scheduling. Once we ioctl() them back to life we can insert them > into the tree. Sure, that sounds fine for scheduling (including big.LITTLE). I might still be misunderstanding something, but I don't think that helps Kan's case: since INACTIVE events which will fail their filters (including the CPU check) will still be in the tree, they will still have to be iterated over. That is, unless we also sort the tree by event->cpu, or if in those cases we only care about ACTIVE events and can use an active list. Thanks, Mark.