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=-9.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 0C82DC432BE for ; Fri, 27 Aug 2021 10:49:06 +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 59F8160FDA for ; Fri, 27 Aug 2021 10:49:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 59F8160FDA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org 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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fOJzljzsKnSEGeBVHma6loY7BcdCNYdVY+cIxRmX3/c=; b=TFQmaUj0xFEMi/ lEx2eUo7ApaZ0uTvwPlLmI8sf+VpSunxvoePE3NcTpl0PsTAGwr32Ek9KudXhwiu6ymN5fFC+z8Gl EJW2xZgj/EHTHWF19tUggw3Jqyuiil/aUB7128u1sx8yP9icJuXlTk+huuUsttoWENYhh2u1RIPwS xa2IVfnrvI1MQyaPZ7beUgKm7J2OFhOVSNhN1/g/BpmBK1J4fz1xDCd3sh9E8vsEef9DtxQEnRR7/ hR4vmxQ+xj8OP+V+3kGllSOw8F1mh23cG+6cmXHAnSUwr5e8bWShLhNW0OJDrZRYPzdnh+EUQ6cPz EazxmPkUZOXApdJyGuZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJZPL-00CIM3-Ot; Fri, 27 Aug 2021 10:48:23 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJZPA-00CILd-H6; Fri, 27 Aug 2021 10:48:12 +0000 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=OvP4Yc4jC04J0qjspa8OOFxuL+jnhRGg3XpJSSUjD4o=; b=dSa6gg/k/uLkIao8HV8YKHe55R QJNUW1DSGmJFIQkoPB+Yq9DSt+RE29HdMkm2cJByn2hw71NQjxJsEPWO+21wDTQDfhVhvu8BkQjf+ L2krqmyZ3aAWLWTmA2aYMCQduTwu64ujYtSfjBEUhfAlVzmTqYLy4o2Ws9e1IwuEUwmRG03uA93za 1BcwsEtY0TALxF7lF4k1iZju+DOeaUy6K5KSj20dObZE8KmsuxkJigtb+xm3AzeIgXlZyxOHnS/+B 4KvrvAwWmfWEjBAXOKEuxfukFtVoVnSRlyFVxwDa8h8JGPBd0g9VYSiib1uZ+XvyETPfQlMGdpOrv 2P9m3iwg==; 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 #2 (Red Hat Linux)) id 1mJZOS-00ESWc-Uh; Fri, 27 Aug 2021 10:47:37 +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 69DD6300024; Fri, 27 Aug 2021 12:47:25 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4ECD229A12A47; Fri, 27 Aug 2021 12:47:25 +0200 (CEST) Date: Fri, 27 Aug 2021 12:47:25 +0200 From: Peter Zijlstra To: Like Xu Cc: Sean Christopherson , Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Morse , Alexandru Elisei , Suzuki K Poulose , "H. Peter Anvin" , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Stefano Stabellini , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.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 , Zhu Lingshan , Will Deacon , Mark Rutland , Ingo Molnar , Arnaldo Carvalho de Melo , Catalin Marinas , Marc Zyngier , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Borislav Petkov , x86@kernel.org, Paolo Bonzini , Boris Ostrovsky , Juergen Gross , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel Subject: Re: [PATCH 00/15] perf: KVM: Fix, optimize, and clean up callbacks Message-ID: References: <20210827005718.585190-1-seanjc@google.com> <3bd4955a-1219-20b0-058b-d23f1e30aa77@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3bd4955a-1219-20b0-058b-d23f1e30aa77@gmail.com> 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Fri, Aug 27, 2021 at 04:01:45PM +0800, Like Xu wrote: > On 27/8/2021 3:44 pm, Peter Zijlstra wrote: > > You just have to make sure all static_call() invocations that started > > before unreg are finished before continuing with the unload. > > synchronize_rcu() can help with that. > > Do you mean something like that: > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 64e310ff4f3a..e7d310af7509 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -8465,6 +8465,7 @@ void kvm_arch_exit(void) > #endif > kvm_lapic_exit(); > perf_unregister_guest_info_callbacks(&kvm_guest_cbs); > + synchronize_rcu(); > > if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) > cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block, > diff --git a/kernel/events/core.c b/kernel/events/core.c > index e466fc8176e1..63ae56c5d133 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -6508,6 +6508,7 @@ EXPORT_SYMBOL_GPL(perf_register_guest_info_callbacks); > int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs) > { > perf_guest_cbs = NULL; > + arch_perf_update_guest_cbs(); I'm thinking the synchronize_rcu() should go here, and access to perf_guest_cbs should be wrapped to yell when called with preemption enabled. But yes.. > return 0; > } > EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks); > > > > > This is module unload 101. Nothing specific to static_call(). > > _______________________________________________ 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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 7C197C432BE for ; Fri, 27 Aug 2021 10:51:25 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id F07EC60F39 for ; Fri, 27 Aug 2021 10:51:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F07EC60F39 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org 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 79E234B0E3; Fri, 27 Aug 2021 06:51:24 -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=@infradead.org 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 AjFZBT3G7L5H; Fri, 27 Aug 2021 06:51:20 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 4C3DB4B10B; Fri, 27 Aug 2021 06:51:20 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 09D824B0E7 for ; Fri, 27 Aug 2021 06:51:19 -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 T9ubJs1V+CJk for ; Fri, 27 Aug 2021 06:51:14 -0400 (EDT) Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id B98D74B0E3 for ; Fri, 27 Aug 2021 06:51:14 -0400 (EDT) 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=OvP4Yc4jC04J0qjspa8OOFxuL+jnhRGg3XpJSSUjD4o=; b=dSa6gg/k/uLkIao8HV8YKHe55R QJNUW1DSGmJFIQkoPB+Yq9DSt+RE29HdMkm2cJByn2hw71NQjxJsEPWO+21wDTQDfhVhvu8BkQjf+ L2krqmyZ3aAWLWTmA2aYMCQduTwu64ujYtSfjBEUhfAlVzmTqYLy4o2Ws9e1IwuEUwmRG03uA93za 1BcwsEtY0TALxF7lF4k1iZju+DOeaUy6K5KSj20dObZE8KmsuxkJigtb+xm3AzeIgXlZyxOHnS/+B 4KvrvAwWmfWEjBAXOKEuxfukFtVoVnSRlyFVxwDa8h8JGPBd0g9VYSiib1uZ+XvyETPfQlMGdpOrv 2P9m3iwg==; 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 #2 (Red Hat Linux)) id 1mJZOS-00ESWc-Uh; Fri, 27 Aug 2021 10:47:37 +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 69DD6300024; Fri, 27 Aug 2021 12:47:25 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4ECD229A12A47; Fri, 27 Aug 2021 12:47:25 +0200 (CEST) Date: Fri, 27 Aug 2021 12:47:25 +0200 From: Peter Zijlstra To: Like Xu Subject: Re: [PATCH 00/15] perf: KVM: Fix, optimize, and clean up callbacks Message-ID: References: <20210827005718.585190-1-seanjc@google.com> <3bd4955a-1219-20b0-058b-d23f1e30aa77@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3bd4955a-1219-20b0-058b-d23f1e30aa77@gmail.com> Cc: Wanpeng Li , kvm@vger.kernel.org, Alexander Shishkin , Catalin Marinas , Josh Poimboeuf , Guo Ren , "H. Peter Anvin" , linux-riscv@lists.infradead.org, Vincent Chen , Jiri Olsa , kvmarm@lists.cs.columbia.edu, Stefano Stabellini , Will Deacon , Joerg Roedel , x86@kernel.org, linux-csky@vger.kernel.org, Ingo Molnar , Steven Rostedt , xen-devel@lists.xenproject.org, Juergen Gross , Albert Ou , Zhu Lingshan , Arnaldo Carvalho de Melo , Jason Baron , Borislav Petkov , Greentime Hu , Paul Walmsley , Namhyung Kim , Thomas Gleixner , Artem Kashkanov , linux-arm-kernel@lists.infradead.org, Jim Mattson , Boris Ostrovsky , Nick Hu , Sean Christopherson , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Palmer Dabbelt , Marc Zyngier , Paolo Bonzini , Vitaly Kuznetsov 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Fri, Aug 27, 2021 at 04:01:45PM +0800, Like Xu wrote: > On 27/8/2021 3:44 pm, Peter Zijlstra wrote: > > You just have to make sure all static_call() invocations that started > > before unreg are finished before continuing with the unload. > > synchronize_rcu() can help with that. > > Do you mean something like that: > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 64e310ff4f3a..e7d310af7509 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -8465,6 +8465,7 @@ void kvm_arch_exit(void) > #endif > kvm_lapic_exit(); > perf_unregister_guest_info_callbacks(&kvm_guest_cbs); > + synchronize_rcu(); > > if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) > cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block, > diff --git a/kernel/events/core.c b/kernel/events/core.c > index e466fc8176e1..63ae56c5d133 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -6508,6 +6508,7 @@ EXPORT_SYMBOL_GPL(perf_register_guest_info_callbacks); > int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs) > { > perf_guest_cbs = NULL; > + arch_perf_update_guest_cbs(); I'm thinking the synchronize_rcu() should go here, and access to perf_guest_cbs should be wrapped to yell when called with preemption enabled. But yes.. > return 0; > } > EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks); > > > > > This is module unload 101. Nothing specific to static_call(). > > _______________________________________________ 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=-9.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 479CFC432BE for ; Fri, 27 Aug 2021 10:50:45 +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 0CCFF60FE7 for ; Fri, 27 Aug 2021 10:50:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0CCFF60FE7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org 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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7HAPm5d/HI608XFocFhXwqaLtd0nknrvr/qLFQQ8Ls0=; b=j35GT6NF0QSN7a DdyyUL3a3L9fIZMfbIWLLdGk9+pX78imc2VcPD92hGWk+Nui3RoRUGpUWH4l0XYC+er9FDJteHcYm /groi3Xhf6UyD8/5cRsN0LHyzNM7m+siqooVXhcU66nnOF4CJ83DURe2XTTCdahZj/f34zy+Ue0sW 2YTt2rPOmc8YinpxUfHLzdKC9sBqVUxvDOCW+gfHLWi/l2gy/aPhP6KH5k3PzvhluNdUb8RAcTr6L AFnmTz/u96jNlQKhVA5UQ22x+9JTthKy5kvor4HRc7CdXCX4edBjxbUlNqQS/qXzmtgFpD2KLPckC jew6EgIRVord90qE22Pw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJZPC-00CILo-JV; Fri, 27 Aug 2021 10:48:14 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJZPA-00CILd-H6; Fri, 27 Aug 2021 10:48:12 +0000 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=OvP4Yc4jC04J0qjspa8OOFxuL+jnhRGg3XpJSSUjD4o=; b=dSa6gg/k/uLkIao8HV8YKHe55R QJNUW1DSGmJFIQkoPB+Yq9DSt+RE29HdMkm2cJByn2hw71NQjxJsEPWO+21wDTQDfhVhvu8BkQjf+ L2krqmyZ3aAWLWTmA2aYMCQduTwu64ujYtSfjBEUhfAlVzmTqYLy4o2Ws9e1IwuEUwmRG03uA93za 1BcwsEtY0TALxF7lF4k1iZju+DOeaUy6K5KSj20dObZE8KmsuxkJigtb+xm3AzeIgXlZyxOHnS/+B 4KvrvAwWmfWEjBAXOKEuxfukFtVoVnSRlyFVxwDa8h8JGPBd0g9VYSiib1uZ+XvyETPfQlMGdpOrv 2P9m3iwg==; 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 #2 (Red Hat Linux)) id 1mJZOS-00ESWc-Uh; Fri, 27 Aug 2021 10:47:37 +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 69DD6300024; Fri, 27 Aug 2021 12:47:25 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4ECD229A12A47; Fri, 27 Aug 2021 12:47:25 +0200 (CEST) Date: Fri, 27 Aug 2021 12:47:25 +0200 From: Peter Zijlstra To: Like Xu Cc: Sean Christopherson , Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Morse , Alexandru Elisei , Suzuki K Poulose , "H. Peter Anvin" , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Stefano Stabellini , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.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 , Zhu Lingshan , Will Deacon , Mark Rutland , Ingo Molnar , Arnaldo Carvalho de Melo , Catalin Marinas , Marc Zyngier , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Borislav Petkov , x86@kernel.org, Paolo Bonzini , Boris Ostrovsky , Juergen Gross , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel Subject: Re: [PATCH 00/15] perf: KVM: Fix, optimize, and clean up callbacks Message-ID: References: <20210827005718.585190-1-seanjc@google.com> <3bd4955a-1219-20b0-058b-d23f1e30aa77@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3bd4955a-1219-20b0-058b-d23f1e30aa77@gmail.com> 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Aug 27, 2021 at 04:01:45PM +0800, Like Xu wrote: > On 27/8/2021 3:44 pm, Peter Zijlstra wrote: > > You just have to make sure all static_call() invocations that started > > before unreg are finished before continuing with the unload. > > synchronize_rcu() can help with that. > > Do you mean something like that: > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 64e310ff4f3a..e7d310af7509 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -8465,6 +8465,7 @@ void kvm_arch_exit(void) > #endif > kvm_lapic_exit(); > perf_unregister_guest_info_callbacks(&kvm_guest_cbs); > + synchronize_rcu(); > > if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) > cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block, > diff --git a/kernel/events/core.c b/kernel/events/core.c > index e466fc8176e1..63ae56c5d133 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -6508,6 +6508,7 @@ EXPORT_SYMBOL_GPL(perf_register_guest_info_callbacks); > int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs) > { > perf_guest_cbs = NULL; > + arch_perf_update_guest_cbs(); I'm thinking the synchronize_rcu() should go here, and access to perf_guest_cbs should be wrapped to yell when called with preemption enabled. But yes.. > return 0; > } > EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks); > > > > > This is module unload 101. Nothing specific to static_call(). > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 652ADC43214 for ; Fri, 27 Aug 2021 10:52:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A00560F6C for ; Fri, 27 Aug 2021 10:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244998AbhH0Kxj (ORCPT ); Fri, 27 Aug 2021 06:53:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244860AbhH0Kxi (ORCPT ); Fri, 27 Aug 2021 06:53:38 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A8D9C061757; Fri, 27 Aug 2021 03:52:49 -0700 (PDT) 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=OvP4Yc4jC04J0qjspa8OOFxuL+jnhRGg3XpJSSUjD4o=; b=dSa6gg/k/uLkIao8HV8YKHe55R QJNUW1DSGmJFIQkoPB+Yq9DSt+RE29HdMkm2cJByn2hw71NQjxJsEPWO+21wDTQDfhVhvu8BkQjf+ L2krqmyZ3aAWLWTmA2aYMCQduTwu64ujYtSfjBEUhfAlVzmTqYLy4o2Ws9e1IwuEUwmRG03uA93za 1BcwsEtY0TALxF7lF4k1iZju+DOeaUy6K5KSj20dObZE8KmsuxkJigtb+xm3AzeIgXlZyxOHnS/+B 4KvrvAwWmfWEjBAXOKEuxfukFtVoVnSRlyFVxwDa8h8JGPBd0g9VYSiib1uZ+XvyETPfQlMGdpOrv 2P9m3iwg==; 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 #2 (Red Hat Linux)) id 1mJZOS-00ESWc-Uh; Fri, 27 Aug 2021 10:47:37 +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 69DD6300024; Fri, 27 Aug 2021 12:47:25 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4ECD229A12A47; Fri, 27 Aug 2021 12:47:25 +0200 (CEST) Date: Fri, 27 Aug 2021 12:47:25 +0200 From: Peter Zijlstra To: Like Xu Cc: Sean Christopherson , Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Morse , Alexandru Elisei , Suzuki K Poulose , "H. Peter Anvin" , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Stefano Stabellini , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.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 , Zhu Lingshan , Will Deacon , Mark Rutland , Ingo Molnar , Arnaldo Carvalho de Melo , Catalin Marinas , Marc Zyngier , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Borislav Petkov , x86@kernel.org, Paolo Bonzini , Boris Ostrovsky , Juergen Gross , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel Subject: Re: [PATCH 00/15] perf: KVM: Fix, optimize, and clean up callbacks Message-ID: References: <20210827005718.585190-1-seanjc@google.com> <3bd4955a-1219-20b0-058b-d23f1e30aa77@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3bd4955a-1219-20b0-058b-d23f1e30aa77@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 27, 2021 at 04:01:45PM +0800, Like Xu wrote: > On 27/8/2021 3:44 pm, Peter Zijlstra wrote: > > You just have to make sure all static_call() invocations that started > > before unreg are finished before continuing with the unload. > > synchronize_rcu() can help with that. > > Do you mean something like that: > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 64e310ff4f3a..e7d310af7509 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -8465,6 +8465,7 @@ void kvm_arch_exit(void) > #endif > kvm_lapic_exit(); > perf_unregister_guest_info_callbacks(&kvm_guest_cbs); > + synchronize_rcu(); > > if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) > cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block, > diff --git a/kernel/events/core.c b/kernel/events/core.c > index e466fc8176e1..63ae56c5d133 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -6508,6 +6508,7 @@ EXPORT_SYMBOL_GPL(perf_register_guest_info_callbacks); > int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs) > { > perf_guest_cbs = NULL; > + arch_perf_update_guest_cbs(); I'm thinking the synchronize_rcu() should go here, and access to perf_guest_cbs should be wrapped to yell when called with preemption enabled. But yes.. > return 0; > } > EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks); > > > > > This is module unload 101. Nothing specific to static_call(). > >