From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BD6DC433B4 for ; Fri, 9 Apr 2021 13:50:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 34A6F61178 for ; Fri, 9 Apr 2021 13:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233725AbhDINul (ORCPT ); Fri, 9 Apr 2021 09:50:41 -0400 Received: from mga17.intel.com ([192.55.52.151]:19276 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231402AbhDINui (ORCPT ); Fri, 9 Apr 2021 09:50:38 -0400 IronPort-SDR: ymhl+F89EZZwD1+dO7g3L/JOX9sxAiuf2LHc1V15BnCXvK68yybvH2CRDCm68H+qWSBm4Fu6YL gWHrf0D6JpEQ== X-IronPort-AV: E=McAfee;i="6000,8403,9949"; a="173847065" X-IronPort-AV: E=Sophos;i="5.82,209,1613462400"; d="scan'208";a="173847065" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2021 06:50:23 -0700 IronPort-SDR: AilOT59qBCKyedDDtArYIWIPeeZkMMwb+ewJF7dafOOjfJr/Y4ryBjv5Z3S9Ls7QUj7SpF9K+h 4k+aj1L3Tg+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,209,1613462400"; d="scan'208";a="419536657" Received: from linux.intel.com ([10.54.29.200]) by orsmga007.jf.intel.com with ESMTP; 09 Apr 2021 06:50:22 -0700 Received: from [10.209.7.33] (kliang2-MOBL.ccr.corp.intel.com [10.209.7.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by linux.intel.com (Postfix) with ESMTPS id 5DC85580812; Fri, 9 Apr 2021 06:50:21 -0700 (PDT) Subject: Re: [PATCH V5 16/25] perf/x86: Register hybrid PMUs To: Peter Zijlstra Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, acme@kernel.org, tglx@linutronix.de, bp@alien8.de, namhyung@kernel.org, jolsa@redhat.com, ak@linux.intel.com, yao.jin@linux.intel.com, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com, ricardo.neri-calderon@linux.intel.com References: <1617635467-181510-1-git-send-email-kan.liang@linux.intel.com> <1617635467-181510-17-git-send-email-kan.liang@linux.intel.com> From: "Liang, Kan" Message-ID: <41c7b4ec-b742-2f7c-9991-7b23c9971dc6@linux.intel.com> Date: Fri, 9 Apr 2021 09:50:20 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/9/2021 2:58 AM, Peter Zijlstra wrote: > On Mon, Apr 05, 2021 at 08:10:58AM -0700, kan.liang@linux.intel.com wrote: >> @@ -2089,9 +2119,46 @@ static int __init init_hw_perf_events(void) >> if (err) >> goto out1; >> >> - err = perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW); >> - if (err) >> - goto out2; >> + if (!is_hybrid()) { >> + err = perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW); >> + if (err) >> + goto out2; >> + } else { >> + u8 cpu_type = get_this_hybrid_cpu_type(); >> + struct x86_hybrid_pmu *hybrid_pmu; >> + bool registered = false; >> + int i; >> + >> + if (!cpu_type && x86_pmu.get_hybrid_cpu_type) >> + cpu_type = x86_pmu.get_hybrid_cpu_type(); >> + >> + for (i = 0; i < x86_pmu.num_hybrid_pmus; i++) { >> + hybrid_pmu = &x86_pmu.hybrid_pmu[i]; >> + >> + hybrid_pmu->pmu = pmu; >> + hybrid_pmu->pmu.type = -1; >> + hybrid_pmu->pmu.attr_update = x86_pmu.attr_update; >> + hybrid_pmu->pmu.capabilities |= PERF_PMU_CAP_HETEROGENEOUS_CPUS; >> + >> + err = perf_pmu_register(&hybrid_pmu->pmu, hybrid_pmu->name, >> + (hybrid_pmu->cpu_type == hybrid_big) ? PERF_TYPE_RAW : -1); >> + if (err) >> + continue; >> + >> + if (cpu_type == hybrid_pmu->cpu_type) >> + x86_pmu_update_cpu_context(&hybrid_pmu->pmu, raw_smp_processor_id()); >> + >> + registered = true; >> + } >> + >> + if (!registered) { >> + pr_warn("Failed to register hybrid PMUs\n"); >> + kfree(x86_pmu.hybrid_pmu); >> + x86_pmu.hybrid_pmu = NULL; >> + x86_pmu.num_hybrid_pmus = 0; >> + goto out2; >> + } > > I don't think this is quite right. registered will be true even if one > fails, while I think you meant to only have it true when all (both) > types registered correctly. No, I mean that perf error out only when all types fail to be registered. For the case (1 failure, 1 success), users can still access the registered PMU. When a CPU belongs to the unregistered PMU online, a warning will be displayed. Because in init_hybrid_pmu(), we will check the PMU type before update the CPU mask. if (WARN_ON_ONCE(!pmu || (pmu->pmu.type == -1))) { cpuc->pmu = NULL; return false; } Thanks, Kan