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=-18.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 9CAC7C433FE for ; Wed, 22 Sep 2021 06:32:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81B36611B0 for ; Wed, 22 Sep 2021 06:32:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232823AbhIVGeE (ORCPT ); Wed, 22 Sep 2021 02:34:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49506 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232712AbhIVGeB (ORCPT ); Wed, 22 Sep 2021 02:34:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632292352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QQ8YzZrVP1svLk3AMq6cxZLez6XFnWefi9KQVDYCfgo=; b=fmYLC59k7++KkSe/bCnLfoBH49jP1rYDAvQErwIUR3kdMMo7ClBrp2ITSGlDSsj8cL9ujD wAJxkcHO/VBC5PRsFmoo9VhnDixWkPVKS04GZqhm0BBcIbCogWRxVHnijpt2iCyxcby+R4 D8E9PTytjRgi56qA4zXVHspE23UjzIA= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-453-eCNhti6YOZqiItrOLfcFGw-1; Wed, 22 Sep 2021 02:32:30 -0400 X-MC-Unique: eCNhti6YOZqiItrOLfcFGw-1 Received: by mail-ed1-f72.google.com with SMTP id o18-20020a056402439200b003d2b11eb0a9so1747229edc.23 for ; Tue, 21 Sep 2021 23:32:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QQ8YzZrVP1svLk3AMq6cxZLez6XFnWefi9KQVDYCfgo=; b=44vHS4QpooyehpwMwD39M4uTDj+ZykjY0uUgpgINP+btKqPM9ccLwU6Gz7TeJGvw+z bYZhPNrDqoEbBZ8pDMOVR8vxtOIqkm6txXDR8FmHX+Bl9YzLpd9Yc/YLhZ9e+PkZzKbS bTxWc5hNimnHemrZ26+Id1MDf23J8/Q//1Vu3jviJiBaYW8u+ctCYQJ4zoYQypOeB2tV GIovqj4BUDdQM7bDUxJ1lvZkcOYwyH0a8Kio9aVcnzMPDpVm9by73GTz1BrHDYiqhxnn TOa8sc+5WAw1x9ySOOQ+Wf2o40aZqupRZjpy6EvuVwMC+yeHWEjbtRMICdK8DVBNTkhO vOvw== X-Gm-Message-State: AOAM531LJMovo4EkoJid4IvnVp5YzVSDCu8rTcmcUdGZLKUhAD4X8+Fm RZhFHrYlHcbylDWxwlcal5VMI234hb+aBX46EVEQMUMo5pHo1VfUgj5nIiW2YqZJN/4sK8ovtPN 6QkrPcrVh88+UzDiWiURuecX2 X-Received: by 2002:a17:907:11c5:: with SMTP id va5mr38316020ejb.215.1632292349169; Tue, 21 Sep 2021 23:32:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYtbJQ8octsTI+p+irGuyf7bBUrwOfK9ScnlhWiK83zRobYLAMfdGjMGdI45oS8miuwF0xKA== X-Received: by 2002:a17:907:11c5:: with SMTP id va5mr38315988ejb.215.1632292348952; Tue, 21 Sep 2021 23:32:28 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id yd3sm552542ejb.6.2021.09.21.23.32.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Sep 2021 23:32:28 -0700 (PDT) Subject: Re: [PATCH v3 08/16] perf: Force architectures to opt-in to guest callbacks To: Sean Christopherson , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Will Deacon , Mark Rutland , Marc Zyngier , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Boris Ostrovsky , Juergen Gross Cc: Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Morse , Alexandru Elisei , Suzuki K Poulose , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Stefano Stabellini , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, Artem Kashkanov , Like Xu , Zhu Lingshan References: <20210922000533.713300-1-seanjc@google.com> <20210922000533.713300-9-seanjc@google.com> From: Paolo Bonzini Message-ID: Date: Wed, 22 Sep 2021 08:32:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210922000533.713300-9-seanjc@google.com> 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 22/09/21 02:05, Sean Christopherson wrote: > Introduce GUEST_PERF_EVENTS and require architectures to select it to > allow registering and using guest callbacks in perf. This will hopefully > make it more difficult for new architectures to add useless "support" for > guest callbacks, e.g. via copy+paste. > > Stubbing out the helpers has the happy bonus of avoiding a load of > perf_guest_cbs when GUEST_PERF_EVENTS=n on arm64/x86. > > Signed-off-by: Sean Christopherson > --- > arch/arm64/kvm/Kconfig | 1 + > arch/x86/kvm/Kconfig | 1 + > arch/x86/xen/Kconfig | 1 + > include/linux/perf_event.h | 6 ++++++ > init/Kconfig | 4 ++++ > kernel/events/core.c | 2 ++ > 6 files changed, 15 insertions(+) > > diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig > index a4eba0908bfa..f2121404c7c6 100644 > --- a/arch/arm64/kvm/Kconfig > +++ b/arch/arm64/kvm/Kconfig > @@ -37,6 +37,7 @@ menuconfig KVM > select HAVE_KVM_IRQ_BYPASS > select HAVE_KVM_VCPU_RUN_PID_CHANGE > select SCHED_INFO > + select GUEST_PERF_EVENTS if PERF_EVENTS > help > Support hosting virtualized guest machines. > > diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig > index ac69894eab88..699bf786fbce 100644 > --- a/arch/x86/kvm/Kconfig > +++ b/arch/x86/kvm/Kconfig > @@ -36,6 +36,7 @@ config KVM > select KVM_MMIO > select SCHED_INFO > select PERF_EVENTS > + select GUEST_PERF_EVENTS > select HAVE_KVM_MSI > select HAVE_KVM_CPU_RELAX_INTERCEPT > select HAVE_KVM_NO_POLL > diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig > index afc1da68b06d..d07595a9552d 100644 > --- a/arch/x86/xen/Kconfig > +++ b/arch/x86/xen/Kconfig > @@ -23,6 +23,7 @@ config XEN_PV > select PARAVIRT_XXL > select XEN_HAVE_PVMMU > select XEN_HAVE_VPMU > + select GUEST_PERF_EVENTS > help > Support running as a Xen PV guest. > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index c0a6eaf55fb1..eefa197d5354 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -1238,6 +1238,7 @@ extern void perf_event_bpf_event(struct bpf_prog *prog, > enum perf_bpf_event_type type, > u16 flags); > > +#ifdef CONFIG_GUEST_PERF_EVENTS > extern struct perf_guest_info_callbacks *perf_guest_cbs; > static inline struct perf_guest_info_callbacks *perf_get_guest_cbs(void) > { > @@ -1273,6 +1274,11 @@ static inline unsigned int perf_guest_handle_intel_pt_intr(void) > } > extern void perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *cbs); > extern void perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs); > +#else > +static inline unsigned int perf_guest_state(void) { return 0; } > +static inline unsigned long perf_guest_get_ip(void) { return 0; } > +static inline unsigned int perf_guest_handle_intel_pt_intr(void) { return 0; } > +#endif /* CONFIG_GUEST_PERF_EVENTS */ Reviewed-by: Paolo Bonzini Having perf_guest_handle_intel_pt_intr in generic code is a bit off. Of course it has to be in the struct, but the wrapper might be placed in arch/x86/include/asm/perf_event.h as well (applies to patch 7 as well). Paolo 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=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 8C08FC43217 for ; Wed, 22 Sep 2021 06:32:36 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id F1F176120F for ; Wed, 22 Sep 2021 06:32:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F1F176120F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7B06440573; Wed, 22 Sep 2021 02:32:35 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HFYiVPO7tdBI; Wed, 22 Sep 2021 02:32:34 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 49FB04A19F; Wed, 22 Sep 2021 02:32:34 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 42D0949E57 for ; Wed, 22 Sep 2021 02:32:33 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mZTcFYpSdfYM for ; Wed, 22 Sep 2021 02:32:32 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 363EC40573 for ; Wed, 22 Sep 2021 02:32:32 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632292352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QQ8YzZrVP1svLk3AMq6cxZLez6XFnWefi9KQVDYCfgo=; b=fmYLC59k7++KkSe/bCnLfoBH49jP1rYDAvQErwIUR3kdMMo7ClBrp2ITSGlDSsj8cL9ujD wAJxkcHO/VBC5PRsFmoo9VhnDixWkPVKS04GZqhm0BBcIbCogWRxVHnijpt2iCyxcby+R4 D8E9PTytjRgi56qA4zXVHspE23UjzIA= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-165--2n6MxQSOeuC1dTlIjv9Kg-1; Wed, 22 Sep 2021 02:32:30 -0400 X-MC-Unique: -2n6MxQSOeuC1dTlIjv9Kg-1 Received: by mail-ed1-f71.google.com with SMTP id q17-20020a50c351000000b003d81427d25cso1779335edb.15 for ; Tue, 21 Sep 2021 23:32:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QQ8YzZrVP1svLk3AMq6cxZLez6XFnWefi9KQVDYCfgo=; b=d0128S8dKPe9+E0dXBA5XdHz0ZFmHM7kIWbp/jVzhHHP3c5fpfpf5lBzikJctYGmgn NPCvso2gkhz5KCT95mDsUibf44C2BJJ2z4fjuNGUA5RnqXc0MUJwbzORUiBlJA+OOTdi QTFDlxvlsDY4P4H5XMaFZpmskRGqe1zkSP77xwL09AvdT2bci3oLIUMM9iH52lnIrulm T3nI64Mq72dYnWQiEcSYGd5APn1GiRjFlAcbQSW9u/6gQjlYlYNm0UaBSVo8MoKD9HTq FivmKd5IS90tNo4DSO4sQRbn0Lg+XsqUAa49tIo4Ht/qBruzb8eynu2m/seow7eblFqh IAtA== X-Gm-Message-State: AOAM531muc62uWGS3/hEmTt5T7R8iHPMxzLiCninSiwToSXwXrwBZ9Eb GDzqY8CA8oK4XxwNRhi+pZlCxZ0J4fky/4aJml7WW1ayPD0J9YpbFouCeWW3bwktRyjQfVWxHUx a6fm/7OKwLEavXcpDxnzHKEtE X-Received: by 2002:a17:907:11c5:: with SMTP id va5mr38316024ejb.215.1632292349170; Tue, 21 Sep 2021 23:32:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYtbJQ8octsTI+p+irGuyf7bBUrwOfK9ScnlhWiK83zRobYLAMfdGjMGdI45oS8miuwF0xKA== X-Received: by 2002:a17:907:11c5:: with SMTP id va5mr38315988ejb.215.1632292348952; Tue, 21 Sep 2021 23:32:28 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id yd3sm552542ejb.6.2021.09.21.23.32.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Sep 2021 23:32:28 -0700 (PDT) Subject: Re: [PATCH v3 08/16] perf: Force architectures to opt-in to guest callbacks To: Sean Christopherson , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Will Deacon , Mark Rutland , Marc Zyngier , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Boris Ostrovsky , Juergen Gross References: <20210922000533.713300-1-seanjc@google.com> <20210922000533.713300-9-seanjc@google.com> From: Paolo Bonzini Message-ID: Date: Wed, 22 Sep 2021 08:32:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210922000533.713300-9-seanjc@google.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Cc: Wanpeng Li , kvm@vger.kernel.org, Alexander Shishkin , Vitaly Kuznetsov , linux-riscv@lists.infradead.org, Jiri Olsa , kvmarm@lists.cs.columbia.edu, Stefano Stabellini , Joerg Roedel , linux-csky@vger.kernel.org, xen-devel@lists.xenproject.org, Namhyung Kim , Artem Kashkanov , linux-arm-kernel@lists.infradead.org, Jim Mattson , Like Xu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Zhu Lingshan X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On 22/09/21 02:05, Sean Christopherson wrote: > Introduce GUEST_PERF_EVENTS and require architectures to select it to > allow registering and using guest callbacks in perf. This will hopefully > make it more difficult for new architectures to add useless "support" for > guest callbacks, e.g. via copy+paste. > > Stubbing out the helpers has the happy bonus of avoiding a load of > perf_guest_cbs when GUEST_PERF_EVENTS=n on arm64/x86. > > Signed-off-by: Sean Christopherson > --- > arch/arm64/kvm/Kconfig | 1 + > arch/x86/kvm/Kconfig | 1 + > arch/x86/xen/Kconfig | 1 + > include/linux/perf_event.h | 6 ++++++ > init/Kconfig | 4 ++++ > kernel/events/core.c | 2 ++ > 6 files changed, 15 insertions(+) > > diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig > index a4eba0908bfa..f2121404c7c6 100644 > --- a/arch/arm64/kvm/Kconfig > +++ b/arch/arm64/kvm/Kconfig > @@ -37,6 +37,7 @@ menuconfig KVM > select HAVE_KVM_IRQ_BYPASS > select HAVE_KVM_VCPU_RUN_PID_CHANGE > select SCHED_INFO > + select GUEST_PERF_EVENTS if PERF_EVENTS > help > Support hosting virtualized guest machines. > > diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig > index ac69894eab88..699bf786fbce 100644 > --- a/arch/x86/kvm/Kconfig > +++ b/arch/x86/kvm/Kconfig > @@ -36,6 +36,7 @@ config KVM > select KVM_MMIO > select SCHED_INFO > select PERF_EVENTS > + select GUEST_PERF_EVENTS > select HAVE_KVM_MSI > select HAVE_KVM_CPU_RELAX_INTERCEPT > select HAVE_KVM_NO_POLL > diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig > index afc1da68b06d..d07595a9552d 100644 > --- a/arch/x86/xen/Kconfig > +++ b/arch/x86/xen/Kconfig > @@ -23,6 +23,7 @@ config XEN_PV > select PARAVIRT_XXL > select XEN_HAVE_PVMMU > select XEN_HAVE_VPMU > + select GUEST_PERF_EVENTS > help > Support running as a Xen PV guest. > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index c0a6eaf55fb1..eefa197d5354 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -1238,6 +1238,7 @@ extern void perf_event_bpf_event(struct bpf_prog *prog, > enum perf_bpf_event_type type, > u16 flags); > > +#ifdef CONFIG_GUEST_PERF_EVENTS > extern struct perf_guest_info_callbacks *perf_guest_cbs; > static inline struct perf_guest_info_callbacks *perf_get_guest_cbs(void) > { > @@ -1273,6 +1274,11 @@ static inline unsigned int perf_guest_handle_intel_pt_intr(void) > } > extern void perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *cbs); > extern void perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs); > +#else > +static inline unsigned int perf_guest_state(void) { return 0; } > +static inline unsigned long perf_guest_get_ip(void) { return 0; } > +static inline unsigned int perf_guest_handle_intel_pt_intr(void) { return 0; } > +#endif /* CONFIG_GUEST_PERF_EVENTS */ Reviewed-by: Paolo Bonzini Having perf_guest_handle_intel_pt_intr in generic code is a bit off. Of course it has to be in the struct, but the wrapper might be placed in arch/x86/include/asm/perf_event.h as well (applies to patch 7 as well). Paolo _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 A6E5DC433EF for ; Wed, 22 Sep 2021 06:33:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7238A61178 for ; Wed, 22 Sep 2021 06:33:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7238A61178 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZCF+vPZJTAl85OSLg+5LVoK3SaVWjZpAyQbVv8zn1Mw=; b=IriKNxl8/JXSNk5Y4l1jQcrMuQ 2cLcX1JNTz6Xen/OKNZoodqSAsnuGQ9DTyO2kkY/kRuuj7UL3KYqXcqyBQLA32dg84SamHLjuj+04 +SbYB0hKyC1lNA77TdbUz20bd+QB0cwbfsUaQnS389ox4ZCjSWDBZ0WTCrw3P1VU/k3+PKN8d0vEK qjPdeS0TGHocX4SFY7hX/UGhzpePH3b7XrrOLp+jzseHNGJjWjcW4fz9syZRXjN847CA82LaKxHOl pA1G5nU0vatgD936VyMfQHLfCOxBKauq2cYVdH0blViYVT6DJEsHUqtFOwgNiM7SziFKE+nyDt+Bv e5lBD5eQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSvoy-0074nj-21; Wed, 22 Sep 2021 06:33:32 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSvo1-0074Ss-Gh for linux-riscv@lists.infradead.org; Wed, 22 Sep 2021 06:32:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632292352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QQ8YzZrVP1svLk3AMq6cxZLez6XFnWefi9KQVDYCfgo=; b=fmYLC59k7++KkSe/bCnLfoBH49jP1rYDAvQErwIUR3kdMMo7ClBrp2ITSGlDSsj8cL9ujD wAJxkcHO/VBC5PRsFmoo9VhnDixWkPVKS04GZqhm0BBcIbCogWRxVHnijpt2iCyxcby+R4 D8E9PTytjRgi56qA4zXVHspE23UjzIA= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175-ZW8kXTFrP_CbvgTse6WajA-1; Wed, 22 Sep 2021 02:32:30 -0400 X-MC-Unique: ZW8kXTFrP_CbvgTse6WajA-1 Received: by mail-ed1-f71.google.com with SMTP id e7-20020aa7d7c7000000b003d3e6df477cso1758716eds.20 for ; Tue, 21 Sep 2021 23:32:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QQ8YzZrVP1svLk3AMq6cxZLez6XFnWefi9KQVDYCfgo=; b=XkQuBQsQBdt5tbi2extq/Odva9+oa2+j16czIZ+xafg7IuHHx/fRBIzVyrr+IWmI95 //7yMfdONscr8Wk9bhN18qihdrDgxGX0HafwdlBdaCn8fBIPS5ZtHdZfHVhjRUUpSMT+ HtojQ1EHpn7OiPeYE8qGSdu5Sfmv52N4tD6eTuOHCu50zbiIMnVApx2VEGZht5AyMvBG rTIXWvV/0Hug3pWkmHxwQoF8MXHpvQmK0GIxgaEooViQhJmir2xXQtZqmodkc3x8rIK9 zOjWTpBhEpx9Cn9Mix7RwY0mEJKwouoSutDRNhUKzNzHQR7pgAoDH/zw0PpDw6uBue1O +QGA== X-Gm-Message-State: AOAM530VJUflOyrywSN2E0RgjfiiRAzn+DXG4oWLRVjxMckqjUf//2UV P3vN120G7FnZG5TgP7eYpDxD26QY5jssOn/pxl1oAcL4CtSoJBnKAOyoZOaUb/FxI8DqMt+I3wq AH+Uu6/Gs5eu5mNfcnukOqUHfOgJY X-Received: by 2002:a17:907:11c5:: with SMTP id va5mr38316041ejb.215.1632292349259; Tue, 21 Sep 2021 23:32:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYtbJQ8octsTI+p+irGuyf7bBUrwOfK9ScnlhWiK83zRobYLAMfdGjMGdI45oS8miuwF0xKA== X-Received: by 2002:a17:907:11c5:: with SMTP id va5mr38315988ejb.215.1632292348952; Tue, 21 Sep 2021 23:32:28 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id yd3sm552542ejb.6.2021.09.21.23.32.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Sep 2021 23:32:28 -0700 (PDT) Subject: Re: [PATCH v3 08/16] perf: Force architectures to opt-in to guest callbacks To: Sean Christopherson , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Will Deacon , Mark Rutland , Marc Zyngier , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Boris Ostrovsky , Juergen Gross Cc: Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Morse , Alexandru Elisei , Suzuki K Poulose , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Stefano Stabellini , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, Artem Kashkanov , Like Xu , Zhu Lingshan References: <20210922000533.713300-1-seanjc@google.com> <20210922000533.713300-9-seanjc@google.com> From: Paolo Bonzini Message-ID: Date: Wed, 22 Sep 2021 08:32:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210922000533.713300-9-seanjc@google.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210921_233233_685112_9CD8EB5C X-CRM114-Status: GOOD ( 21.25 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On 22/09/21 02:05, Sean Christopherson wrote: > Introduce GUEST_PERF_EVENTS and require architectures to select it to > allow registering and using guest callbacks in perf. This will hopefully > make it more difficult for new architectures to add useless "support" for > guest callbacks, e.g. via copy+paste. > > Stubbing out the helpers has the happy bonus of avoiding a load of > perf_guest_cbs when GUEST_PERF_EVENTS=n on arm64/x86. > > Signed-off-by: Sean Christopherson > --- > arch/arm64/kvm/Kconfig | 1 + > arch/x86/kvm/Kconfig | 1 + > arch/x86/xen/Kconfig | 1 + > include/linux/perf_event.h | 6 ++++++ > init/Kconfig | 4 ++++ > kernel/events/core.c | 2 ++ > 6 files changed, 15 insertions(+) > > diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig > index a4eba0908bfa..f2121404c7c6 100644 > --- a/arch/arm64/kvm/Kconfig > +++ b/arch/arm64/kvm/Kconfig > @@ -37,6 +37,7 @@ menuconfig KVM > select HAVE_KVM_IRQ_BYPASS > select HAVE_KVM_VCPU_RUN_PID_CHANGE > select SCHED_INFO > + select GUEST_PERF_EVENTS if PERF_EVENTS > help > Support hosting virtualized guest machines. > > diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig > index ac69894eab88..699bf786fbce 100644 > --- a/arch/x86/kvm/Kconfig > +++ b/arch/x86/kvm/Kconfig > @@ -36,6 +36,7 @@ config KVM > select KVM_MMIO > select SCHED_INFO > select PERF_EVENTS > + select GUEST_PERF_EVENTS > select HAVE_KVM_MSI > select HAVE_KVM_CPU_RELAX_INTERCEPT > select HAVE_KVM_NO_POLL > diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig > index afc1da68b06d..d07595a9552d 100644 > --- a/arch/x86/xen/Kconfig > +++ b/arch/x86/xen/Kconfig > @@ -23,6 +23,7 @@ config XEN_PV > select PARAVIRT_XXL > select XEN_HAVE_PVMMU > select XEN_HAVE_VPMU > + select GUEST_PERF_EVENTS > help > Support running as a Xen PV guest. > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index c0a6eaf55fb1..eefa197d5354 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -1238,6 +1238,7 @@ extern void perf_event_bpf_event(struct bpf_prog *prog, > enum perf_bpf_event_type type, > u16 flags); > > +#ifdef CONFIG_GUEST_PERF_EVENTS > extern struct perf_guest_info_callbacks *perf_guest_cbs; > static inline struct perf_guest_info_callbacks *perf_get_guest_cbs(void) > { > @@ -1273,6 +1274,11 @@ static inline unsigned int perf_guest_handle_intel_pt_intr(void) > } > extern void perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *cbs); > extern void perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs); > +#else > +static inline unsigned int perf_guest_state(void) { return 0; } > +static inline unsigned long perf_guest_get_ip(void) { return 0; } > +static inline unsigned int perf_guest_handle_intel_pt_intr(void) { return 0; } > +#endif /* CONFIG_GUEST_PERF_EVENTS */ Reviewed-by: Paolo Bonzini Having perf_guest_handle_intel_pt_intr in generic code is a bit off. Of course it has to be in the struct, but the wrapper might be placed in arch/x86/include/asm/perf_event.h as well (applies to patch 7 as well). Paolo _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 7613FC433F5 for ; Wed, 22 Sep 2021 06:36:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C70361107 for ; Wed, 22 Sep 2021 06:36:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3C70361107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MQ0suuu3GyVmGRHGgjChI30w+84yYb0VIsOepeAEl7Y=; b=Qlc9yY9dC1N4yd4TOU9m1+Sa3C b+OaLS1p7mE2EofuRNSsG+hMsLIlnb06mpkCvT36/q/w7F3OVTY1pahC77uK2yBg0pWwIZjT83X7l x3KSaPxmcCmABGktl8kK3d6YVh4hlg+YMUFyXrFeY/STxI/PzHmtkgVvtFv2mfXy1ZxYVTmqEQBUi X0+HsI29onLFn6FwZx4IS031ZiyBLwxS12lmbPuOrhcWLtWT7MmwTus1AS5tydalgGLVbq4uX69RY WMjU7dXwaAdaKJa7+yilLg585tcown9/QzX4QnxiVivJjiAGIgFHOQ/NoQ3TTI+W6NgOwySVJMagv aUwIWxbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSvoV-0074be-1F; Wed, 22 Sep 2021 06:33:03 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSvo0-0074Si-Vk for linux-arm-kernel@lists.infradead.org; Wed, 22 Sep 2021 06:32:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632292352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QQ8YzZrVP1svLk3AMq6cxZLez6XFnWefi9KQVDYCfgo=; b=fmYLC59k7++KkSe/bCnLfoBH49jP1rYDAvQErwIUR3kdMMo7ClBrp2ITSGlDSsj8cL9ujD wAJxkcHO/VBC5PRsFmoo9VhnDixWkPVKS04GZqhm0BBcIbCogWRxVHnijpt2iCyxcby+R4 D8E9PTytjRgi56qA4zXVHspE23UjzIA= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-165-zmFa5eEJMD2en885Vh1zuw-1; Wed, 22 Sep 2021 02:32:30 -0400 X-MC-Unique: zmFa5eEJMD2en885Vh1zuw-1 Received: by mail-ed1-f70.google.com with SMTP id ec14-20020a0564020d4e00b003cf5630c190so1858125edb.3 for ; Tue, 21 Sep 2021 23:32:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QQ8YzZrVP1svLk3AMq6cxZLez6XFnWefi9KQVDYCfgo=; b=u7RR0csmaFuvT8Ldq33xUL0GEZcV8nYIdkwfaxwaSdS/STOX6eEvrHY62HpfrbGAk6 CATvQ52rDpVyQXaL7mOcwwBNSXIhZdj0+WVxERtYTzQmwS75n5R0VDQcdnimx4Qd9TqK +yxlzKAoSm9Xr72V0gdaMmT+0geQIBsz/I/KGiME6AVsqiU2EHkZbjFeoI9uKLqvsLGz xGL+maVUzRtkbLMAfHWXpCtYEJNbQ53+FizbQ9dQCaWLils9vxNAUuRnKv+ZhCgPoK6e bAER3O3UgJITCjWynmV6Bgh6ORVTgHVQOTZQsDHfMBYFnfVx4tfjEzKCQNV44yG8wHXH zaBw== X-Gm-Message-State: AOAM530GbXRer78qhREF0aZXagNAy2xSPxuLUFjoqiHVW+jfQHKjVQdf t5eI3o0dNv54jBwNjwmKxZh7wA/BJIM67ae60DCT9sq6qvLonMfhCCt+Nc481+uLddbxKXgnRbN KJqmEtEuiyfxT80a9QXeXhY6JuspXRPvARMc= X-Received: by 2002:a17:907:11c5:: with SMTP id va5mr38316013ejb.215.1632292349169; Tue, 21 Sep 2021 23:32:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYtbJQ8octsTI+p+irGuyf7bBUrwOfK9ScnlhWiK83zRobYLAMfdGjMGdI45oS8miuwF0xKA== X-Received: by 2002:a17:907:11c5:: with SMTP id va5mr38315988ejb.215.1632292348952; Tue, 21 Sep 2021 23:32:28 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id yd3sm552542ejb.6.2021.09.21.23.32.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Sep 2021 23:32:28 -0700 (PDT) Subject: Re: [PATCH v3 08/16] perf: Force architectures to opt-in to guest callbacks To: Sean Christopherson , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Will Deacon , Mark Rutland , Marc Zyngier , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Boris Ostrovsky , Juergen Gross Cc: Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Morse , Alexandru Elisei , Suzuki K Poulose , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Stefano Stabellini , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, Artem Kashkanov , Like Xu , Zhu Lingshan References: <20210922000533.713300-1-seanjc@google.com> <20210922000533.713300-9-seanjc@google.com> From: Paolo Bonzini Message-ID: Date: Wed, 22 Sep 2021 08:32:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210922000533.713300-9-seanjc@google.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210921_233233_188373_F364DF12 X-CRM114-Status: GOOD ( 22.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 22/09/21 02:05, Sean Christopherson wrote: > Introduce GUEST_PERF_EVENTS and require architectures to select it to > allow registering and using guest callbacks in perf. This will hopefully > make it more difficult for new architectures to add useless "support" for > guest callbacks, e.g. via copy+paste. > > Stubbing out the helpers has the happy bonus of avoiding a load of > perf_guest_cbs when GUEST_PERF_EVENTS=n on arm64/x86. > > Signed-off-by: Sean Christopherson > --- > arch/arm64/kvm/Kconfig | 1 + > arch/x86/kvm/Kconfig | 1 + > arch/x86/xen/Kconfig | 1 + > include/linux/perf_event.h | 6 ++++++ > init/Kconfig | 4 ++++ > kernel/events/core.c | 2 ++ > 6 files changed, 15 insertions(+) > > diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig > index a4eba0908bfa..f2121404c7c6 100644 > --- a/arch/arm64/kvm/Kconfig > +++ b/arch/arm64/kvm/Kconfig > @@ -37,6 +37,7 @@ menuconfig KVM > select HAVE_KVM_IRQ_BYPASS > select HAVE_KVM_VCPU_RUN_PID_CHANGE > select SCHED_INFO > + select GUEST_PERF_EVENTS if PERF_EVENTS > help > Support hosting virtualized guest machines. > > diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig > index ac69894eab88..699bf786fbce 100644 > --- a/arch/x86/kvm/Kconfig > +++ b/arch/x86/kvm/Kconfig > @@ -36,6 +36,7 @@ config KVM > select KVM_MMIO > select SCHED_INFO > select PERF_EVENTS > + select GUEST_PERF_EVENTS > select HAVE_KVM_MSI > select HAVE_KVM_CPU_RELAX_INTERCEPT > select HAVE_KVM_NO_POLL > diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig > index afc1da68b06d..d07595a9552d 100644 > --- a/arch/x86/xen/Kconfig > +++ b/arch/x86/xen/Kconfig > @@ -23,6 +23,7 @@ config XEN_PV > select PARAVIRT_XXL > select XEN_HAVE_PVMMU > select XEN_HAVE_VPMU > + select GUEST_PERF_EVENTS > help > Support running as a Xen PV guest. > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index c0a6eaf55fb1..eefa197d5354 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -1238,6 +1238,7 @@ extern void perf_event_bpf_event(struct bpf_prog *prog, > enum perf_bpf_event_type type, > u16 flags); > > +#ifdef CONFIG_GUEST_PERF_EVENTS > extern struct perf_guest_info_callbacks *perf_guest_cbs; > static inline struct perf_guest_info_callbacks *perf_get_guest_cbs(void) > { > @@ -1273,6 +1274,11 @@ static inline unsigned int perf_guest_handle_intel_pt_intr(void) > } > extern void perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *cbs); > extern void perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs); > +#else > +static inline unsigned int perf_guest_state(void) { return 0; } > +static inline unsigned long perf_guest_get_ip(void) { return 0; } > +static inline unsigned int perf_guest_handle_intel_pt_intr(void) { return 0; } > +#endif /* CONFIG_GUEST_PERF_EVENTS */ Reviewed-by: Paolo Bonzini Having perf_guest_handle_intel_pt_intr in generic code is a bit off. Of course it has to be in the struct, but the wrapper might be placed in arch/x86/include/asm/perf_event.h as well (applies to patch 7 as well). Paolo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel