Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1952089AbdDYR2H convert rfc822-to-8bit (ORCPT ); Tue, 25 Apr 2017 13:28:07 -0400 Received: from mga14.intel.com ([192.55.52.115]:62460 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1951817AbdDYR17 (ORCPT ); Tue, 25 Apr 2017 13:27:59 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,250,1488873600"; d="scan'208";a="93673022" From: "Liang, Kan" To: David Carrillo-Cisneros , "linux-kernel@vger.kernel.org" CC: "x86@kernel.org" , Ingo Molnar , "Thomas Gleixner" , Andi Kleen , "Peter Zijlstra" , Borislav Petkov , "Srinivas Pandruvada" , Dave Hansen , Vikas Shivappa , Mark Rutland , Arnaldo Carvalho de Melo , Vince Weaver , Paul Turner , Stephane Eranian , "Budankov, Alexey" Subject: RE: [RFC 0/6] optimize ctx switch with rb-tree Thread-Topic: [RFC 0/6] optimize ctx switch with rb-tree Thread-Index: AQHSayvxfT6zq1YGtkSnpdL7j43oA6HW+iMw Date: Tue, 25 Apr 2017 17:27:55 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F077536E6010@SHSMSX103.ccr.corp.intel.com> References: <20170110102502.106187-1-davidcc@google.com> In-Reply-To: <20170110102502.106187-1-davidcc@google.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2MwZTk4ZmEtNjYyZC00N2M5LThiZGQtZGNjM2FhMmQ0NTMxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlhHb3BUa2F0YVwvTFQ1Z2wzZ0t4VUJzcjlHdFVoanlYK0VDQnFMOU1hV1RjPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2491 Lines: 60 Hi David, Is there any update about the patch series? We recently encountered another performance issue on KNL. I think the RB-tree solution also has benefits for it. Thanks, Kan > Subject: [RFC 0/6] optimize ctx switch with rb-tree > > Following the discussion in: > https://patchwork.kernel.org/patch/9420035/ > > This is is an early version of a series of perf context switches optimizations. > > The main idea is to create and maintain a list of inactive events sorted by > timestamp, and a rb-tree index to index it. The rb-tree's key are > {cpu,flexible,stamp} for task contexts and {cgroup,flexible,stamp} for CPU > contexts. > > The rb-tree provides functions to find intervals in the inactive event list so > that ctx_sched_in only has to visit the events that can be potentially be > scheduled (i.e. avoid iterations over events bound to CPUs or cgroups that > are not current). > > Since the inactive list is sort by timestamp, rotation can be done by simply > scheduling out and in the events. This implies that each timer interrupt, the > events will rotate by q events (where q is the number of hardware counters). > This changes the current behavior of rotation. > Feedback welcome! > > I haven't profiled the new approach. I am only assuming it will be superior > when the number of per-cpu or distict cgroup events is large. > > The last patch shows how perf_iterate_ctx can use the new rb-tree index to > reduce the number of visited events. I haven't looked carefully if locking and > other things are correct. > > If this changes are in the right direction. A next version could remove some > existing code, specifically the lists ctx->pinned_groups and > ctx->flexible_groups could be removed. Also, event_filter_match could be > simplified when called on events groups filtered using the rb-tree, since both > perform similar checks. > > David Carrillo-Cisneros (6): > perf/core: create active and inactive event groups > perf/core: add a rb-tree index to inactive_groups > perf/core: use rb-tree to sched in event groups > perf/core: avoid rb-tree traversal when no inactive events > perf/core: rotation no longer neccesary. Behavior has changed. Beware > perf/core: use rb-tree index to optimize filtered perf_iterate_ctx > > include/linux/perf_event.h | 13 ++ > kernel/events/core.c | 466 > +++++++++++++++++++++++++++++++++++++++------ > 2 files changed, 426 insertions(+), 53 deletions(-) > > -- > 2.11.0.390.gc69c2f50cf-goog