Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1585514pxb; Mon, 8 Mar 2021 00:56:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhjVNW1PxDdFUgZEKrQnweFUis6VF4yrOZE0xZTQ8Sba7q7HsXnbnyGewC+H5SvkilNjWw X-Received: by 2002:aa7:d316:: with SMTP id p22mr20231754edq.107.1615193787925; Mon, 08 Mar 2021 00:56:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615193787; cv=none; d=google.com; s=arc-20160816; b=ytDbxeXfO4ALtvbY4vsYVpabgebZqzdo7x5v+Qbqhq2JwwOlqYD+bC0M94Q4FQfd/W uU0dboadqw3ZxH4QYZvKtag32COS5ROWyk3SfQ/KA2KiMvuISQB7rG54uLS/LGo2aoDI +br8sk3oxK9Q2gwulQZpKRocjeCmnUDJ0j0xORAmYfBTcBdy+KN0E2wxbhFkZhmRsU7W qzI4pXlXqvj8Ur418i4ND0bsgMdEcAHPjiPIFqos//A3s/Y2LFpm2984+MY2XnPCETYn D6/gywAedAOWBrmRFwdGPDOkF04I74o3rl1/AwcxUb1mYpnBT/LUEZ8xZE3BqbyE/4mb aiMA== 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=ANaVFRfhdnFocYbReHLCZECtJVt3gnfyZgmlG+L6e9g=; b=tlfp4gqF09Hd3P1TTD50lB0RvQ05rFWezbttlqaJyNiTBnh6rrjfB4XYa/97uiP2WC rYdm/laNrX2LFwvhyaepgwcelhzocISi6Kzg6JQy2350i5qfp/vhVqpQTd6DV9IuYYcI kESpKNXKXj7VCQcmLNwIpRzY1zgDVL4ozPCHBHouBy1rwrSXz8R+KdGnnH8PpUJM9jAq jZA+rHnpZWf27P8XyJOopdvscs4xw/Q0gC7qnrt6c0rfcFGrIGTS7ye6iRa/qsj/qRY4 NA6AohREcWEzjH0ZzbhbuljDJn+6znJhdrBivV0wgPk/M5AVwaE7iG1XynwNttR7MajU VRSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=BO4fm6t9; 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 g25si915285ejx.232.2021.03.08.00.56.05; Mon, 08 Mar 2021 00:56:27 -0800 (PST) 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=casper.20170209 header.b=BO4fm6t9; 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 S229668AbhCHIzC (ORCPT + 99 others); Mon, 8 Mar 2021 03:55:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbhCHIyk (ORCPT ); Mon, 8 Mar 2021 03:54:40 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C27CC06174A; Mon, 8 Mar 2021 00:54:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=ANaVFRfhdnFocYbReHLCZECtJVt3gnfyZgmlG+L6e9g=; b=BO4fm6t9c/hak3Yul5LcR2NTEW SbcjBht12dJpLW3Oavg3bAT/cmkoRHgVvhm72MkA0k/mV0eDg8JWoKP8q3xJKGh4JYYXh6M9hzFwS /Z8sYXGIJcln9AEXXr7uRnMyv2i5h1j7HvF4Ua3tEE//wY8SK5vl/+NtjlgZwUrp5lizKaWF3KL8c LqjRxJXAfd4Kv7NGlg3iUBGmMngwiMBNLI1eI91c46QKbvIT16uPWv/k0oeSe2r23yyV4zcxMo0pt G8QwATc7mf3uC9zFkF1M8Vy8on3ZTioa/w0DrySGlCvCqjx9yTOZd0qaPbtsKoNlVJJi+dw8ThSF6 zQCU/lVw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lJBeF-00FFUW-98; Mon, 08 Mar 2021 08:54:00 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id DB32F300238; Mon, 8 Mar 2021 09:53:52 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BD7FB2BB25DDF; Mon, 8 Mar 2021 09:53:52 +0100 (CET) Date: Mon, 8 Mar 2021 09:53:52 +0100 From: Peter Zijlstra To: "Xu, Like" Cc: Sean Christopherson , Dmitry Vyukov , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , "H. Peter Anvin" , linux-kernel@vger.kernel.org, Like Xu , Paolo Bonzini , Jim Mattson , kvm@vger.kernel.org, "Thomas Gleixner (x86/pti/timer/core/smp/irq/perf/efi/locking/ras/objtool) (x86@kernel.org)" , Borislav Petkov , Arnaldo Carvalho de Melo , Ingo Molnar Subject: Re: [PATCH] x86/perf: Fix guest_get_msrs static call if there is no PMU Message-ID: References: <20210305223331.4173565-1-seanjc@google.com> <053d0a22-394d-90d0-8d3b-3cd37ca3f378@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <053d0a22-394d-90d0-8d3b-3cd37ca3f378@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 08, 2021 at 10:25:59AM +0800, Xu, Like wrote: > On 2021/3/6 6:33, Sean Christopherson wrote: > > Handle a NULL x86_pmu.guest_get_msrs at invocation instead of patching > > in perf_guest_get_msrs_nop() during setup. If there is no PMU, setup > > "If there is no PMU" ... Then you shouldn't be calling this either ofcourse :-) > > @@ -671,7 +671,11 @@ void x86_pmu_disable_all(void) > > struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr) > > { > > - return static_call(x86_pmu_guest_get_msrs)(nr); > > + if (x86_pmu.guest_get_msrs) > > + return static_call(x86_pmu_guest_get_msrs)(nr); > > How about using "static_call_cond" per commit "452cddbff7" ? Given the one user in atomic_switch_perf_msrs() that should work because it doesn't seem to care about nr_msrs when !msrs. Still, it calling atomic_switch_perf_msrs() and intel_pmu_lbr_is_enabled() when there isn't a PMU at all is of course, a complete waste of cycles.