Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751537AbdH3Kar (ORCPT ); Wed, 30 Aug 2017 06:30:47 -0400 Received: from mga04.intel.com ([192.55.52.120]:37999 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751263AbdH3Kaa (ORCPT ); Wed, 30 Aug 2017 06:30:30 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,448,1498546800"; d="scan'208";a="145575902" Subject: Re: [PATCH v6 1/3] perf/core: use rb trees for pinned/flexible groups To: Alexander Shishkin , Peter Zijlstra Cc: Ingo Molnar , Arnaldo Carvalho de Melo , 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> <20170804143628.34c2xqxl2e6k2arj@hirez.programming.kicks-ass.net> <9d2e25c9-209c-f28a-d601-d3f1a71f032f@linux.intel.com> <87lgm2xz0m.fsf@ashishki-desk.ger.corp.intel.com> <87a82hxsrw.fsf@ashishki-desk.ger.corp.intel.com> From: Alexey Budankov Organization: Intel Corp. Message-ID: Date: Wed, 30 Aug 2017 13:30:26 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <87a82hxsrw.fsf@ashishki-desk.ger.corp.intel.com> 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: 1548 Lines: 49 On 30.08.2017 13:18, Alexander Shishkin wrote: > Alexey Budankov writes: > >>>> Iterating cpu specific subtree like this: >>>> >>>> #define for_each_group_event(event, group, cpu, pmu, field) \ >>>> for (event = rb_entry_safe(group_first(group, cpu, pmu), \ >>>> typeof(*event), field); \ >>>> event && event->cpu == cpu && event->pmu == pmu; \ >>>> event = rb_entry_safe(rb_next(&event->field), \ >>>> typeof(*event), field)) >>> >>> Afaict, this assumes that you are also ordering on event->pmu, which >>> should be reflected in your _less function. And also assuming that >>> group_first() is doing the right thing. Can we see the code? >> >> I didn't do ordering by PMU for this patch set. Yet more I implemented >> groups_first() like this: > > Your iterator (quoted above) begs to differ. What do you specifically mean? I am doing iterations like this: /* * Iterate event groups thru the whole tree. */ #define perf_event_groups_for_each(event, groups, node) \ for (event = rb_entry_safe(rb_first(&((groups)->tree)), \ typeof(*event), node); event; \ event = rb_entry_safe(rb_next(&event->node), \ typeof(*event), node)) /* * Iterate event groups with cpu == cpu_id. */ #define perf_event_groups_for_each_cpu(event, key, groups, node) \ for (event = perf_event_groups_first(groups, key); \ event && event->cpu == key; \ event = rb_entry_safe(rb_next(&event->node), \ typeof(*event), node)) > > Regards, > -- > Alex > Thanks, Alexey