From: Roman Kagan Subject: Re: [PATCH v2 2/5] KVM: x86: hyperv: introduce vp_index_to_vcpu_idx mapping Date: Fri, 29 Jun 2018 18:55:32 +0300 Message-ID: <20180629155532.GF15656@rkaganb.sw.ru> References: <20180628135313.17468-1-vkuznets@redhat.com> <20180628135313.17468-3-vkuznets@redhat.com> <20180629101134.GA15656@rkaganb.sw.ru> <87y3exdh2o.fsf@vitty.brq.redhat.com> <20180629111227.GB15656@rkaganb.sw.ru> <87tvplddrr.fsf@vitty.brq.redhat.com> <20180629125216.GC15656@rkaganb.sw.ru> <87h8lld9hl.fsf@vitty.brq.redhat.com> <20180629143212.GD15656@rkaganb.sw.ru> <878t6xd37f.fsf@vitty.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, x86@kernel.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Mohammed Gamal , Cathy Avery , Wanpeng Li , linux-kernel@vger.kernel.org To: Vitaly Kuznetsov Return-path: Content-Disposition: inline In-Reply-To: <878t6xd37f.fsf@vitty.brq.redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Fri, Jun 29, 2018 at 05:25:56PM +0200, Vitaly Kuznetsov wrote: > Roman Kagan writes: > > > On Fri, Jun 29, 2018 at 03:10:14PM +0200, Vitaly Kuznetsov wrote: > >> Roman Kagan writes: > >> > >> > On Fri, Jun 29, 2018 at 01:37:44PM +0200, Vitaly Kuznetsov wrote: > >> >> The problem we're trying to solve here is: with PV TLB flush and IPI we > >> >> need to walk through the supplied list of VP_INDEXes and get VCPU > >> >> ids. Usually they match. But in case they don't [...] > >> > > >> > Why wouldn't they *in practice*? Only if the userspace wanted to be > >> > funny and assigned VP_INDEXes randomly? I'm not sure we need to > >> > optimize for this case. > >> > >> Can someone please remind me why we allow userspace to change it in the > >> first place? > > > > I can ;) > > > > We used not to, and reported KVM's vcpu index as the VP_INDEX. However, > > later we realized that VP_INDEX needed to be persistent across > > migrations and otherwise also known to userspace. Relying on the kernel > > to always initialize its indices in the same order was unacceptable, and > > we came up with no better way of synchronizing VP_INDEX between the > > userspace and the kernel than to let the former to set it explicitly. > > > > However, this is basically a future-proofing feature; in practice, both > > QEMU and KVM initialize their indices in the same order. > > > Thanks! > > But in the theoretical case when these indices start to differ after > migration, users will notice a slowdown which will be hard to explain, > right? That's exactly why I suggested a warning on VP_INDEX != vcpu index in kvm_hv_set_msr. > Does it justify the need for vp_idx_to_vcpu_idx? I'd personally prefer being pointed at a scenario where this becomes relevant first. Roman.