Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751809AbdHGPXF (ORCPT ); Mon, 7 Aug 2017 11:23:05 -0400 Received: from mga04.intel.com ([192.55.52.120]:52605 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751247AbdHGPXE (ORCPT ); Mon, 7 Aug 2017 11:23:04 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,338,1498546800"; d="scan'208";a="136682700" Subject: Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups To: Peter Zijlstra Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Andi Kleen , Kan Liang , Dmitri Prokhorov , Valery Cherepennikov , Mark Rutland , Stephane Eranian , David Carrillo-Cisneros , linux-kernel References: <96c7776f-1f17-a39e-23e9-658596216d6b@linux.intel.com> <20170803130002.oatczvnaalplrsep@hirez.programming.kicks-ass.net> <86cbe0b0-a1ec-4d5f-addc-87bccf2e97d7@linux.intel.com> <20170804145324.tb3d377f4kkeqhho@hirez.programming.kicks-ass.net> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Mon, 7 Aug 2017 18:22:59 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170804145324.tb3d377f4kkeqhho@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1382 Lines: 32 On 04.08.2017 17:53, Peter Zijlstra wrote: > On Thu, Aug 03, 2017 at 11:30:09PM +0300, Alexey Budankov wrote: >> On 03.08.2017 16:00, Peter Zijlstra wrote: >>> On Wed, Aug 02, 2017 at 11:13:54AM +0300, Alexey Budankov wrote: > >>>> @@ -2759,13 +2932,13 @@ static void ctx_sched_out(struct perf_event_context *ctx, >>>> >>>> perf_pmu_disable(ctx->pmu); >>>> if (is_active & EVENT_PINNED) { >>>> - list_for_each_entry(event, &ctx->pinned_groups, group_entry) >>>> - group_sched_out(event, cpuctx, ctx); >>>> + perf_event_groups_iterate(&ctx->pinned_groups, >>>> + group_sched_out_callback, ¶ms); >>> >>> So here I would expect to not iterate events where event->cpu != >>> smp_processor_id() (and ideally not where event->pmu != ctx->pmu). >>> >> >> We still need to iterate thru all groups on thread context switch in >> and out as well as iterate thru cpu == -1 list (software events) additionally >> to smp_processor_id() list from multiplexing timer interrupt handler. > > Well, just doing the @cpu=-1 and @cpu=this_cpu subtrees is less work > than iterating _everything_, right? Right. That is actually the aim of this whole patch set - to avoid iterating "_everything_". > > The rest will not survive event_filter_match() anyway, so iterating them > is complete waste of time, and once we have them in a tree, its actually > easy to find this subset. >