From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753848AbdKNH4s (ORCPT ); Tue, 14 Nov 2017 02:56:48 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:36963 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751690AbdKNH4j (ORCPT ); Tue, 14 Nov 2017 02:56:39 -0500 Date: Tue, 14 Nov 2017 08:56:36 +0100 From: Peter Zijlstra To: Wanpeng Li Cc: "linux-kernel@vger.kernel.org" , kvm , Paolo Bonzini , Radim Kr??m???? , Wanpeng Li Subject: Re: [PATCH v4 2/4] KVM: X86: Add paravirt remote TLB flush Message-ID: <20171114075636.rzozbjysqjpomguw@hirez.programming.kicks-ass.net> References: <1510533206-9821-1-git-send-email-wanpeng.li@hotmail.com> <1510533206-9821-3-git-send-email-wanpeng.li@hotmail.com> <20171113080403.ici7nt5r4b5fpxa6@hirez.programming.kicks-ass.net> <20171113104634.62cmjalnj73scfnl@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 14, 2017 at 02:28:56PM +0800, Wanpeng Li wrote: > > - have the TLB invalidate handler do something like: > > > > state = READ_ONCE(src->preempted); > > if (!(state & KVM_VCPU_IPI_PENDING)) > > return; > > > > local_flush_tlb(); > > > > do { > > } while (!try_cmpxchg(&src->preempted, &state, > > state & ~KVM_VCPU_IPI_PENDING)); > > There are a lot of cases handled by flush_tlb_func_remote() -> > flush_tlb_function_common(), so I'm afraid to have hole. Sure, just fix the handler to do what must be done. The above was merely a sketch. The important part is to only clear IPI_PENDING after we do the actual flushing, since the caller is waiting for that bit. So flush_tlb_others() has two callers: - arch_tlbbatch_flush() -- info::end = TLB_FLUSH_ALL - flush_tlb_mm_range() -- info::mm = mm native_flush_tlb_others() does smp_call_function_many( .func=flush_tlb_func_remote) which in turn calls flush_tlb_func_common( .local=false, .reason=TLB_REMOTE_SHOOTDOWN). So something like: struct flush_tlb_info info = { .start = 0, .end = TLB_FLUSH_ALL, }; flush_tlb_func_common(&info, false, TLB_REMOTE_SHOOTDOWN); should work for the new IPI. It 'upgrades' all ranges to full flushes, but meh.