Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp423713imm; Fri, 12 Oct 2018 00:05:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV61JlmOJQ5XFjeEvNQj9NGAUV3asD44dLcMyF02fh6UyJ8u3qZkgjBNu+vHw+6XthPh0d0zs X-Received: by 2002:a63:ec4b:: with SMTP id r11-v6mr4346403pgj.295.1539327916521; Fri, 12 Oct 2018 00:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539327916; cv=none; d=google.com; s=arc-20160816; b=0ndxSys4+E96ZbZU/ZpKcJj38aiezrCOmwaqoZU8eokMnyYNooulH++U5kArRRChfe bTyYoDPklGjDJnnMG+hXviZhG59z7X6SBCebgmje5W0kqPMHH8spI8YeQAGiN6G8t1E7 083tVTrt3NP/1BIAWg9kQ2zFfg6VIIhhxgZ+6sCf9sNLeOKTtnLaBJ9pjB0/i4i3TQxX qOByOyR7TmjsEnPDyqvcx2IpBAPIuR/KBUI2ERC46YcFxSsVagGsrY5MImvo2ycYEBBD gXmL4hf9DwOzStCO/tTvupuld44ZhkdAebQGC0O2geuuSJKpM0YK/wZvKf3bY912wcfA pRYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=Xa8x+vWnB/1puQteX56OTfrD/lD2gqIsaPjiEjizrVw=; b=Z4LqcKC0bRA/k4+G1ujmIiZRej65TYNgixPQKDabwwIewfMaxI3cCxdG8Eq0c/HOOa Um213qXMiBAX0Zv3HPCo6ExGevjqzje83Iw6EX891NdxyC61c1LY9K17CJrmKhyy0LZ7 FYui6X3s+xgtkFHzDwOP/QumOBWfOexzWuNBds02UxrYTQPKFX2i5RKJH1YpglohN9Kz Ep5U9nG8VyxblJcw7NBfFrAVrr4X33JKKngoTgm/jv7o0UtuOprYwVrngXz9v2N3k2VG KzV/kLMRdYp3QUrSU+M89/kiXytZJsC3Gju1XVM9wmAcBsnJhKeEKQIPQwlgDaXZQEDe BpUw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5-v6si341339plp.186.2018.10.12.00.05.01; Fri, 12 Oct 2018 00:05:16 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727563AbeJLOfm (ORCPT + 99 others); Fri, 12 Oct 2018 10:35:42 -0400 Received: from mga05.intel.com ([192.55.52.43]:57543 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727434AbeJLOfm (ORCPT ); Fri, 12 Oct 2018 10:35:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2018 00:04:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,371,1534834800"; d="scan'208";a="240733462" Received: from linux.intel.com ([10.54.29.200]) by orsmga004.jf.intel.com with ESMTP; 12 Oct 2018 00:04:40 -0700 Received: from [10.125.251.247] (abudanko-mobl.ccr.corp.intel.com [10.125.251.247]) by linux.intel.com (Postfix) with ESMTP id 43CEE58015C; Fri, 12 Oct 2018 00:04:37 -0700 (PDT) Subject: Re: [RFC][PATCH] perf: Rewrite core context handling To: Peter Zijlstra , Song Liu Cc: Ingo Molnar , lkml , "acme@kernel.org" , "alexander.shishkin@linux.intel.com" , "jolsa@redhat.com" , "eranian@google.com" , "tglx@linutronix.de" , "mark.rutland@arm.com" , "megha.dey@intel.com" , "frederic@kernel.org" References: <20181010104559.GO5728@hirez.programming.kicks-ass.net> <20181011092913.GA9848@hirez.programming.kicks-ass.net> From: Alexey Budankov Organization: Intel Corp. Message-ID: <162cce00-745c-6e30-f859-497d9307059d@linux.intel.com> Date: Fri, 12 Oct 2018 10:04:36 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181011092913.GA9848@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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 11.10.2018 12:29, Peter Zijlstra wrote: > On Thu, Oct 11, 2018 at 07:50:23AM +0000, Song Liu wrote: >> Hi Peter, >> >> I am trying to understand this. Pardon me if any question is silly. >> >> I am not sure I fully understand the motivation here. I guess we >> see problem when there are two (or more) independent hardware PMUs >> per cpu? Then on a given cpu, there are two (or more) >> perf_cpu_context, but only one task context? > > Right. > >> If this is correct (I really doubt...), I guess perf_rotate_context() >> is the problem? > > No, everything comes apart. Where would you put the events of the second > PMU? > > The thing most often proposed it pretending the second PMU is a > 'software' PMU and sticking the events on the software PMU context. > > But because software PMUs must never fail to schedule an event, that > results in some quite horrible things -- including that we cannot RR the > events. > > Similarly the big.little guys have the problem that the PMUs are not the > same between big and little cores, and they fudge something horrible. By > having clear ordering on PMU, that can be cleaned up too. > >> And if this is still correct, this patch may not help, >> as we are doing rotation for each perf_cpu_pmu_context? (or rotation >> per perf_event_context is the next step?). > > We do indeed to rotation per perf_cpu_pmu_context, however: > > - perf_cpu_pmu_context embeds a cpu scope perf_event_pmu_context, > - perf_cpu_pmu_context tracks the currently associated task scope > perf_event_pmu_context. > > So it can rotate all current events for a particular PMU. > >> Or step back a little... I see two big changes: >> >> 1. struct perf_ctx_context is now per cpu (instead of per pmu per cpu); >> 2. one perf_event_ctxp per task_struct (instead of 2). > > Correct, we reduce to 1 cpu context and 1 task context at all times. > This in fact simplifies quite a bit of things. And what is currently missing is some markup of the per cpu event list into per pmu sublists and capability to rotate or not rotate the sublists independently, right? Thanks, Alexey > >> I think #1 is a bigger change than #2. Is this correct? > > They're the 'same' change. But yes the primary purpose was 2, but having > only a single cpu context is a direct consequence. > >> Could you please help me understand it better? > > I hope this helps to understand, please feel free to ask more. >