Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1440732

Re: [PATCH v2 04/13] KVM: x86: dynamic kvm_apic_map

Path csiph.com!news.mixmin.net!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Radim Krčmář <rkrcmar@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 04/13] KVM: x86: dynamic kvm_apic_map
Date Mon, 11 Jul 2016 18:00:03 +0200
Message-ID <rTLML-CQ-47@gated-at.bofh.it> (permalink)
References <rSl7X-1t6-7@gated-at.bofh.it> <rSlhF-1y4-39@gated-at.bofh.it> <rTCzL-3d1-3@gated-at.bofh.it> <rTE8y-42b-17@gated-at.bofh.it> <rTGtH-5FU-17@gated-at.bofh.it> <rTJKV-7HY-1@gated-at.bofh.it> <rTKdY-87y-7@gated-at.bofh.it>
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Disposition inline
Content-Transfer-Encoding 8bit
X-Scanned-By MIMEDefang 2.68 on 10.5.11.24
X-Greylist Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 11 Jul 2016 15:52:33 +0000 (UTC)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 44
Organization linux.* mail to news gateway
X-Original-Cc Yang Zhang <yang.zhang.wz@gmail.com>, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, "Lan, Tianyu" <tianyu.lan@intel.com>, Igor Mammedov <imammedo@redhat.com>, Jan Kiszka <jan.kiszka@web.de>, Peter Xu <peterx@redhat.com>
X-Original-Date Mon, 11 Jul 2016 17:52:29 +0200
X-Original-Message-ID <20160711155229.GE21976@potion>
X-Original-References <20160707171550.14675-1-rkrcmar@redhat.com> <20160707171550.14675-5-rkrcmar@redhat.com> <963b542a-1111-db83-8338-c32d44f98874@gmail.com> <c7aa9f72-33d4-ccea-2e63-049d7121e771@redhat.com> <3a5d86b6-9f1a-a6cf-8af4-ef6bf3936996@gmail.com> <20160711134837.GD21976@potion> <6dda9370-e538-2c7c-e95e-b6a6f1518bbf@redhat.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1440732

Show key headers only | View raw


2016-07-11 16:14+0200, Paolo Bonzini:
> On 11/07/2016 15:48, Radim Krčmář wrote:
>>>> I guess the easiest solution is to replace kvm_apic_id with a field in
>>>> struct kvm_lapic, which is already shifted right by 24 in xAPIC mode.
>> 
>> (I guess the fewest LOC is to look at vcpu->vcpu_id, which is equal to
>>  x2apic id.  xapic id cannot be greater than 255 and all of those are
>>  covered by the initial value of max_id.)
> 
> Yes, this would work too.  Or even better perhaps, look at vcpu->vcpu_id
> in kvm_apic_id?

APIC ID is writeable in xAPIC mode, which would make the implementation
weird without an extra variable.  Always read-only APIC ID would be
best, IMO.

>>> Or we can just simply put the assignment of apic_base to the end.
>> 
>> Yes, this would work, I'd also remove recalculates from
>> kvm_apic_set_*apic_id() and add a compiler barrier with comment for good
>> measure, even though set_virtual_x2apic_mode() serves as one.
> 
> Why a compiler barrier?

True, it should be a proper pair of smp_wmb() and smp_rmb() in
recalculate ... and current kvm_apic_id() reads in a wrong order, so
changing the apic_base alone update wouldn't get rid of this race.

>> (What makes a bit wary is that it doesn't avoid the same problem if we
>>  changed KVM to reset apic id to xapic id first when disabling apic.)
> 
> Yes, this is why I prefer it fixed once and for all in kvm_apic_id...

Seems most reasonable.  We'll need to be careful to have a correct value
in the apic page, but there shouldn't be any races there.

>> Races in recalculation and APIC ID changes also lead to invalid physical
>> maps, which haven't been taken care of properly ...
> 
> Hmm, true, but can be fixed separately.  Probably the mutex should be
> renamed so that it can be taken outside recalculate_apic_map...

Good point, it'll make reasoning easier and shouldn't introduce any
extra scalability issues.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v2 04/13] KVM: x86: dynamic kvm_apic_map Yang Zhang <yang.zhang.wz@gmail.com> - 2016-07-11 08:10 +0200
  Re: [PATCH v2 04/13] KVM: x86: dynamic kvm_apic_map Paolo Bonzini <pbonzini@redhat.com> - 2016-07-11 09:50 +0200
    Re: [PATCH v2 04/13] KVM: x86: dynamic kvm_apic_map Yang Zhang <yang.zhang.wz@gmail.com> - 2016-07-11 12:20 +0200
      Re: [PATCH v2 04/13] KVM: x86: dynamic kvm_apic_map Radim Krčmář <rkrcmar@redhat.com> - 2016-07-11 15:50 +0200
        Re: [PATCH v2 04/13] KVM: x86: dynamic kvm_apic_map Paolo Bonzini <pbonzini@redhat.com> - 2016-07-11 16:20 +0200
          Re: [PATCH v2 04/13] KVM: x86: dynamic kvm_apic_map Radim Krčmář <rkrcmar@redhat.com> - 2016-07-11 18:00 +0200
            Re: [PATCH v2 04/13] KVM: x86: dynamic kvm_apic_map Paolo Bonzini <pbonzini@redhat.com> - 2016-07-11 18:10 +0200
            Re: [PATCH v2 04/13] KVM: x86: dynamic kvm_apic_map Yang Zhang <yang.zhang.wz@gmail.com> - 2016-07-12 05:30 +0200

csiph-web