Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1454785pxf; Fri, 9 Apr 2021 08:49:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySEPu1M14pCl6+MlIjwEiHLuumm1V/JFQHfHt+zbHlDM2Y47jecBJC1dEyQc8oji/4UhcL X-Received: by 2002:a05:6402:274d:: with SMTP id z13mr18389558edd.344.1617983357450; Fri, 09 Apr 2021 08:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617983357; cv=none; d=google.com; s=arc-20160816; b=nBGC+h3ctDwy9mrwV64nS3Ff83cJgKRRHHepa6XZun4TQUCHzmUFL0vJSsHXCZ8WRo qF8UXduZxLlimoqSkD4c6i3I3j+uTt/+B3mTRrNvAN1y35cogh4gd9WAhlYik3e4lS0c vF3pYngioZICGZ1jxUA9291ZZs41V0T+s/XmzcfZN2IRB/J0eWP/8Ptsle/vuCrUu3BK v9L4msEFav0xTjBanaJzB9bDCCc+dzit3i8Fn5qVW9TwWeQ2CWH2KrrwiRcFm7XE6XrK PJg/AgyDGyyHnP95nXU2h+hofanlPR3nVfMDtF1vTD8fpPxrq58d2V7nJcnT/gOqFC2x guuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ccacilQpw8gp06qfs/99roXEeahKogw23vAA74hgdvo=; b=M2TUkHuzgjRqkkG9jL8KLOHMRnC+H3gX7XQow2qax2B42/1ZEHNx9ZDQ1C+EFdTTJU c5gdlaXtNlvmbKeAiNtaGkofzYFSlKOE9rlICEmyQOmAVxlJPwghe50MjoZASJYjNcl8 e3nZR90VmgIXdAOkyr3MfzlWynSNzUfi9f90mkleLdZcTQcgNLh9U7CmqRgLEnYgkr25 UnOEkXawFCGrZcNQfctAtO40WWLozj1QJU8RMtcdUJx6paUhZil8XAILG8tqzfagA36t M27jGqe2tvOOGTFp+pVjuWqDvQlPCYh1eft1LsjXXtfPgKaLJamz64XhtlM6s66icnBe +Y9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Lt5gnjW5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cz23si2416566edb.378.2021.04.09.08.48.53; Fri, 09 Apr 2021 08:49:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Lt5gnjW5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233440AbhDIPp6 (ORCPT + 99 others); Fri, 9 Apr 2021 11:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232796AbhDIPp5 (ORCPT ); Fri, 9 Apr 2021 11:45:57 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77CB4C061760 for ; Fri, 9 Apr 2021 08:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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; bh=ccacilQpw8gp06qfs/99roXEeahKogw23vAA74hgdvo=; b=Lt5gnjW56W4zdS9TCXUP0VLqKq UQ6r757R95oVk5leaf9pAafNW2F0ShHEJWJHWKwz/kFFraISRl5oK9RP3v9hTzWIYKWi+Qzu6Qbfx VfFCpLRvNqgBZDP4dVjWngl4Gpqv1mZzJCj6AXkQhPBFN+EvDyF9TkDDs9isOGs/ytR0BsLEcPNk5 hdOZrq/PH1u8ldAwzZAqGbkTRLjcs6+fFT7zrjfQDdQH6DW1Fu4gfobLfpBuvcLa55icd4hu9wNQ5 8kcVRV34GpvJ5+6VVinlbhkuwzEZQyCdMYpmGe/nB3EKUlN7Zw0OhqW1jpJomUtDQo2jhocM3/apj nPVZzGgw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lUtK6-0012JJ-Bs; Fri, 09 Apr 2021 15:45:30 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 9240830001B; Fri, 9 Apr 2021 17:45:28 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 802B52BE951AC; Fri, 9 Apr 2021 17:45:28 +0200 (CEST) Date: Fri, 9 Apr 2021 17:45:28 +0200 From: Peter Zijlstra To: "Liang, Kan" 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 Subject: Re: [PATCH V5 16/25] perf/x86: Register hybrid PMUs Message-ID: References: <1617635467-181510-1-git-send-email-kan.liang@linux.intel.com> <1617635467-181510-17-git-send-email-kan.liang@linux.intel.com> <41c7b4ec-b742-2f7c-9991-7b23c9971dc6@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <41c7b4ec-b742-2f7c-9991-7b23c9971dc6@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 09, 2021 at 09:50:20AM -0400, Liang, Kan wrote: > > > 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. All or nothing seems a better approach to me. There really isn't a good reason for any one of them to fail.