Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4955641imm; Tue, 16 Oct 2018 02:53:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV63MZiuJ/IG3Elfb+RQy3klZW0SGU7v+JG6mwotDjvC5b9yK5Pgl/n29ChMuVkf3oqpUbQy0 X-Received: by 2002:a63:2e47:: with SMTP id u68-v6mr19786282pgu.294.1539683636385; Tue, 16 Oct 2018 02:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539683636; cv=none; d=google.com; s=arc-20160816; b=p156wwo+ZYPmDcRRdO533HCZqcEaKhVXskMTflG9G24nhpuDQAMzP7SnIbK+lbtsIk GTZgQB/KeJDup0eXzIjp7xAhZ6lHNqG+JGSUj5Q7EueF6P6LnLaD5GdvYckQrLpyD0Q+ OfmE4CXkeP+RDghHTmFFUSP7Y8vzx6S9f7SeHMqUhrjDWNSd2RyNC+jO10/D1q9HerjC heMNAZ4EHv8DVMCPdSN+s+rqy4aPgjJfLUzTgjY3mWuDMCcHwqmmMJ7lnpuX3sQ1QCzM 3UsP3+jN3l7hv7iuFATtF2g/SWtF+LyHL05bAyJ6OZ/BTjk4UpFL/rFt5Xz+itIWIIbK 8o0g== 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=ZZRDi0AjdzF8tHWmAMnIdoX7YoLwRyOdaRpRaARwdhY=; b=J7Pr3mCQjyfzpeByNyDY0wWIvrl/Jnh/ncv6RS26GTeb+72BoHG+z1phb4dYp0FMPc ndfkYlP04jvT73MeGOsSwTRAG2MrB2p3mPxnaIBNmRTXaZWzOXo4IzG9a2UgS+99DLqU dyJNGokPBHfYPGOVs1RHdWIhuzO6ntnQwrpoIRTrRmlHDmrAV0bLdNcz8OQDhPaa2qdR m+wqkrZNzoq2Mrp0NmvW2iTiBEtROh4TFjXts95xTPPzG9CirSRjKF2HWQxY22b6b4Ae mXMXLFuP8SB55K6RYiiiU1Cz0eKEhjvovJhhaLS3KCkPeC2s87TclOwM1mVRhvXAYBhU +47A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=UrDHjrqH; 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 15-v6si13615021pfr.242.2018.10.16.02.53.38; Tue, 16 Oct 2018 02:53:56 -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=bombadil.20170209 header.b=UrDHjrqH; 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 S1727093AbeJPRkv (ORCPT + 99 others); Tue, 16 Oct 2018 13:40:51 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52676 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbeJPRkv (ORCPT ); Tue, 16 Oct 2018 13:40:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=ZZRDi0AjdzF8tHWmAMnIdoX7YoLwRyOdaRpRaARwdhY=; b=UrDHjrqHqKdPan/fLM572EdPB sqsEEhVS/D/vwEGl4kTNx52qHjwAuA6mAfJjLuvo/6wJHsJb9ao2i9+hMS0uZgU8QsXQLu4YdhsSh GEl2mGND0KpY7NkDBfbJxkKZB9VskdR8sPLRhNXxjaep/MgSkLhtmCWcVX1b5bVOgcsTiTSauvj5F yvmjNwFillwAwTnYFOLiXrkNUvRgCRm32rdqS/H6DC77q9PqSuzpZ0wdoH3A5bzi9005DalI9556q 2LU5KHKnSGLCrMijE06UBpa926OuM/hcABsk9mUDStVWouGAY0yGInT+bnU3Mu34dRILG7TzggJqP 107t7Cjsg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCM0B-0002NE-J1; Tue, 16 Oct 2018 09:50:59 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E752520295866; Tue, 16 Oct 2018 11:50:56 +0200 (CEST) Date: Tue, 16 Oct 2018 11:50:56 +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: <20181016095056.GE4030@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Sat, Oct 13, 2018 at 08:31:37AM +0000, Song Liu wrote: > The only suggestion I have right now is on which struct owns which > data: > > 1. perf_cpu_context owns two perf_event_context: ctx and *task_ctx. > This is the same as right now. > 2. perf_event_context owns multiple perf_event_pmu_context: > One perf_event_pmu_context for software groups; > One perf_event_pmu_context for each hardware PMU. It does now already, right? Through the pmu_ctx_list we can, given an perf_event_context, find all associated perf_event_pmu_context's. > 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. > 4. perf_cpu_context owns multiple perf_cpu_pmu_context: > One perf_cpu_pmu_context for each hardware PMU. What would we need that relation for? > perf_cpu_pmu_context is tot needed for software only groups(?). Yes, that is a very good question; it mostly centers around what we want to do with perf_event_attr::exclusive for software events -- which is currently dodgy at best. Also, allocating the structure and keeping it around is probably less code than explicitly not doing it. > 5. perf_cpu_pmu_context has two pointers of perf_event_pmu_context. Instead of embedding the thing? Yeah, not sure. Either way around we'd not want to free the CPU perf_event_pmu_context that is associated with the perf_cpu_pmu_context, and embedding it saves a pointer chase. Not sure it actually makes a lot of difference either way around.