From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753396AbdATUbQ (ORCPT ); Fri, 20 Jan 2017 15:31:16 -0500 Received: from mail-vk0-f53.google.com ([209.85.213.53]:36842 "EHLO mail-vk0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753262AbdATUak (ORCPT ); Fri, 20 Jan 2017 15:30:40 -0500 MIME-Version: 1.0 In-Reply-To: <20170120092033.GK6515@twins.programming.kicks-ass.net> References: <20170118192454.58008-1-davidcc@google.com> <20170118192454.58008-3-davidcc@google.com> <20170120092033.GK6515@twins.programming.kicks-ass.net> From: David Carrillo-Cisneros Date: Fri, 20 Jan 2017 12:30:38 -0800 Message-ID: Subject: Re: [PATCH v2 2/2] perf/core: Remove perf_cpu_context::unique_pmu To: Peter Zijlstra Cc: linux-kernel , "x86@kernel.org" , Ingo Molnar , Thomas Gleixner , Andi Kleen , Kan Liang , Borislav Petkov , Srinivas Pandruvada , Dave Hansen , Vikas Shivappa , Mark Rutland , Arnaldo Carvalho de Melo , Vince Weaver , Paul Turner , Stephane Eranian Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 20, 2017 at 1:20 AM, Peter Zijlstra wrote: > On Wed, Jan 18, 2017 at 11:24:54AM -0800, David Carrillo-Cisneros wrote: >> cpuctx->unique_pmu was originally introduced as a way to identify cpuctxs >> with shared pmus in order to avoid visiting the same cpuctx more than once >> in a for_each_pmu loop. >> >> cpuctx->unique_pmu == cpuctx->pmu in non-software task contexts since they >> have only one pmu per cpuctx. Since perf_pmu_sched_task is only called in >> hw contexts, this patch replaces cpuctx->unique_pmu by cpuctx->pmu in it. >> >> The change above, together with the previous patch in this series, removed >> the remaining uses of cpuctx->unique_pmu, so we remove it altogether. >> >> Signed-off-by: David Carrillo-Cisneros >> Acked-by: Mark Rutland > > >> @@ -8572,37 +8572,10 @@ static struct perf_cpu_context __percpu *find_pmu_context(int ctxn) >> return NULL; >> } >> >> -static void update_pmu_context(struct pmu *pmu, struct pmu *old_pmu) >> -{ >> - int cpu; >> - >> - for_each_possible_cpu(cpu) { >> - struct perf_cpu_context *cpuctx; >> - >> - cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu); >> - >> - if (cpuctx->unique_pmu == old_pmu) >> - cpuctx->unique_pmu = pmu; >> - } >> -} >> - >> static void free_pmu_context(struct pmu *pmu) >> { >> - struct pmu *i; >> - >> mutex_lock(&pmus_lock); >> - /* >> - * Like a real lame refcount. >> - */ >> - list_for_each_entry(i, &pmus, entry) { >> - if (i->pmu_cpu_context == pmu->pmu_cpu_context) { >> - update_pmu_context(i, pmu); >> - goto out; >> - } >> - } >> - >> free_percpu(pmu->pmu_cpu_context); >> -out: >> mutex_unlock(&pmus_lock); >> } > > This very much relies on us never calling perf_pmu_unregister() on the > software PMUs afaict. A condition not mention in the Changelog. > What's a good way to solve this? Update the Changelog or add code to update ctx->pmu? This issue would go away cleanly if we were to remove the context sharing across pmu's. Would you support work in that direction? Thanks, David