Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5501234imm; Tue, 16 Oct 2018 11:11:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV62vGHBvSLJP4X/mevbS/k5x8s8e7ahnqoHjJRlAqsR4eNE11Rky9NgyY70mp6h7Dh4aK7qS X-Received: by 2002:a63:1b0b:: with SMTP id b11-v6mr20968542pgb.66.1539713483276; Tue, 16 Oct 2018 11:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539713483; cv=none; d=google.com; s=arc-20160816; b=Mi31Ei2pBeObR16fm1noWKziOATs05eElJoO0jTdYokTIv9pY30TFFZ4suEFHulhmY Ei3G381cU9EPeRfR0BgoIPttNls/t/hNcLEN6wA41CWvNuKNEf4otqZeR62/ZVKHewSf 0OSUDEnSmGSIhn1OIp4TyYYnfbAqZaKZtHbLaMuSzRNxReyrOwn7tojsGanI/eJDzumu ajZUqle35S/gu4NlQ+xu1JO0cD8gCKNPaDkQRMd6RW4FOF7PMufKo0JbKT9/H+F7ZXfJ eEP+7ThFK22+pr4Y1eQ3sZij05YXtyUoWN2yCA/ru3QTvjMVrfLbtEvGZbIE8S4XfQqe DCAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8OUUaLS5INAkW9peW/lnB520svb/cSOG0gE2dRdwHSI=; b=ISxpHwBGHHRpfN7CARfmMsqXJxTZBMzshawzJIn3Fnno2bHzZxo98FOzo/WtDwhlMF EJ/fa/og2bA9LNBxeaqR9e8QWoaJ4xn1kI6Vllm8tE1LbMwPV+6aGIHHG/UelOCAbEdm kckfMN9WzAKxO8H14XGhzBgLbchZejBI3KHMQPtaLuy3cTbMIqAOduarWNIfbtQRJLFx JQHGFEo+KmozXvWp2HG7/bA9sY7tlHIy10mlQ4GBQwWzucijGFr+QXZauwvFYHH+eS9M ckwIPOk50esE/R760crbhLrzu1Qq6zKLN+LbiQ9S1dKgTfTLciVpU7diYFdvZLddLLFp lYzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="unvCz86/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k28-v6si5840536pgl.221.2018.10.16.11.11.07; Tue, 16 Oct 2018 11:11:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="unvCz86/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727306AbeJQCCD (ORCPT + 99 others); Tue, 16 Oct 2018 22:02:03 -0400 Received: from merlin.infradead.org ([205.233.59.134]:34962 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727247AbeJQCCD (ORCPT ); Tue, 16 Oct 2018 22:02:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8OUUaLS5INAkW9peW/lnB520svb/cSOG0gE2dRdwHSI=; b=unvCz86/T3jWamR8BrQYcO8nL PKnUcNFbo6xN9TQ4Us1b/vNknhUKTXP8XuoTsbDU5NOeqTHQayrGabDCDCVC7jgklUO+WWxZNB1FV /PjGKyxAaceaJqOM40Vzlnwo/mxLu7hAtbjJKyQ7Fajyf8xqdxusOAh3o2lrjcBTSHfr8TWI5qB45 F70frwWUm/cLLFduSngQDbwKhaDvOXrdEWT2BJju39Gngoh5VR19Sq1UbjyKyc/IWaejfwHmSShPR aJb2gAcJSCE6EyNToPShNOVA0WwTmAqTeRhSnVCROPIVG2+KGvUUCZtLjbvptmkhAR+XRTh2cyaL8 m0UpHO7WQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCTnN-0004NF-7e; Tue, 16 Oct 2018 18:10:17 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 88ED82029900B; Tue, 16 Oct 2018 20:10:15 +0200 (CEST) Date: Tue, 16 Oct 2018 20:10:15 +0200 From: Peter Zijlstra To: Song Liu Cc: Ingo Molnar , lkml , "acme@kernel.org" , "alexander.shishkin@linux.intel.com" , "jolsa@redhat.com" , "eranian@google.com" , "tglx@linutronix.de" , "alexey.budankov@linux.intel.com" , "mark.rutland@arm.com" , "megha.dey@intel.com" , "frederic@kernel.org" Subject: Re: [RFC][PATCH] perf: Rewrite core context handling Message-ID: <20181016181015.GD3121@hirez.programming.kicks-ass.net> References: <20181010104559.GO5728@hirez.programming.kicks-ass.net> <20181011092913.GA9848@hirez.programming.kicks-ass.net> <70079805-1CAE-4CAA-813A-F8DDB929F22B@fb.com> <20181012095001.GG9867@hirez.programming.kicks-ass.net> <20181016095056.GE4030@hirez.programming.kicks-ass.net> <9865C981-0E8C-4419-AE8C-638DCD40D74E@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9865C981-0E8C-4419-AE8C-638DCD40D74E@fb.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 16, 2018 at 04:34:05PM +0000, Song Liu wrote: > >> 3. perf_event_pmu_context owns RB tree of events. Since we don't > >> need rotation across multiple hardware PMUs, the rotation is > >> within same perf_event_pmu_context. > > > > By keeping the RB trees in perf_event_context, we get bigger trees, > > which is more efficient (log(n+m) < log(n) + log(m)) > > > > Also, specifically, it means we only need a single merge sort / > > iteration to schedule in a full context, instead of (again) doing 'n' of > > them. > > > > Also, given a context and a pmu, it is cheaper for finding the relevant > > events; this is needed for big.little for instance. Something the > > proposed patch doesn't fully flesh out. > > Would it be faster if we add a perf_event_pmu_context pointer to the > perf_event? + pmu_ctx = find_get_pmu_context(pmu, ctx, event); + if (IS_ERR(pmu_ctx)) { + err = PTR_ERR(pmu_ctx); + goto err_locked; + } + event->pmu_ctx = pmu_ctx; Like that?