From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751745AbdLAA4C (ORCPT ); Thu, 30 Nov 2017 19:56:02 -0500 Received: from mail-ot0-f196.google.com ([74.125.82.196]:33954 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751125AbdLAA4B (ORCPT ); Thu, 30 Nov 2017 19:56:01 -0500 X-Google-Smtp-Source: AGs4zMbWvM+fbkVc65KVKjvpbWGLAdaupqSSE0GpXJNQos5s6bj59zWS9R2q//TfnQIS/gsfijZk+2beGYyUrh6q/Bk= MIME-Version: 1.0 In-Reply-To: <20171130151715.GB1399@flask> References: <1512021674-9880-1-git-send-email-wanpeng.li@hotmail.com> <1512021674-9880-3-git-send-email-wanpeng.li@hotmail.com> <20171130151715.GB1399@flask> From: Wanpeng Li Date: Fri, 1 Dec 2017 08:55:59 +0800 Message-ID: Subject: Re: [PATCH v7 2/4] KVM: X86: Add Paravirt TLB Shootdown To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Cc: "linux-kernel@vger.kernel.org" , kvm , Paolo Bonzini , Peter Zijlstra , Wanpeng Li Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id vB10u70A032547 2017-11-30 23:17 GMT+08:00 Radim Krčmář : > 2017-11-29 22:01-0800, Wanpeng Li: >> From: Wanpeng Li >> --- >> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c >> @@ -498,6 +498,34 @@ static void __init kvm_apf_trap_init(void) >> update_intr_gate(X86_TRAP_PF, async_page_fault); >> } >> >> +static DEFINE_PER_CPU(cpumask_var_t, __pv_tlb_mask); >> + >> +static void kvm_flush_tlb_others(const struct cpumask *cpumask, >> + const struct flush_tlb_info *info) >> +{ >> + u8 state; >> + int cpu; >> + struct kvm_steal_time *src; >> + struct cpumask *flushmask = this_cpu_cpumask_var_ptr(__pv_tlb_mask); >> + >> + cpumask_copy(flushmask, cpumask); > > Is it impossible to call this function before the allocation? > > I was guessing that early_initcall might allow us to avoid a (static) > condition as there is no point in calling when there are no others, but > expected the worst ... kernel_init() -> kernel_init_freeable() -> do_basic_setup() -> do_initcalls() -> async_synchronize_full() => finish all async __init code -> try_to_run_init_process() All the async __init codes can guarantee to be completed before init task is created, so I think arch_initcall() is fine. Regards, Wanpeng Li