Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-18 Thread Gleb Natapov
On Fri, Jul 18, 2014 at 05:05:20PM +0800, Tang Chen wrote: > Hi Gleb, > > On 07/17/2014 09:57 PM, Gleb Natapov wrote: > >On Thu, Jul 17, 2014 at 09:34:20PM +0800, Tang Chen wrote: > >>Hi Gleb, > >> > >>On 07/15/2014 08:40 PM, Gleb Natapov wrote: > >>.. > > And yes, we have the

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-18 Thread Tang Chen
Hi Gleb, On 07/17/2014 09:57 PM, Gleb Natapov wrote: On Thu, Jul 17, 2014 at 09:34:20PM +0800, Tang Chen wrote: Hi Gleb, On 07/15/2014 08:40 PM, Gleb Natapov wrote: .. And yes, we have the problem you said here. We can migrate the page while L2 vm is running. So I think we should

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-18 Thread Tang Chen
Hi Gleb, On 07/17/2014 09:57 PM, Gleb Natapov wrote: On Thu, Jul 17, 2014 at 09:34:20PM +0800, Tang Chen wrote: Hi Gleb, On 07/15/2014 08:40 PM, Gleb Natapov wrote: .. And yes, we have the problem you said here. We can migrate the page while L2 vm is running. So I think we should

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-18 Thread Gleb Natapov
On Fri, Jul 18, 2014 at 05:05:20PM +0800, Tang Chen wrote: Hi Gleb, On 07/17/2014 09:57 PM, Gleb Natapov wrote: On Thu, Jul 17, 2014 at 09:34:20PM +0800, Tang Chen wrote: Hi Gleb, On 07/15/2014 08:40 PM, Gleb Natapov wrote: .. And yes, we have the problem you said here. We can

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-17 Thread Gleb Natapov
On Thu, Jul 17, 2014 at 09:34:20PM +0800, Tang Chen wrote: > Hi Gleb, > > On 07/15/2014 08:40 PM, Gleb Natapov wrote: > .. > >> > >>And yes, we have the problem you said here. We can migrate the page while L2 > >>vm is running. > >>So I think we should enforce L2 vm to exit to L1. Right ? >

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-17 Thread Tang Chen
Hi Gleb, On 07/15/2014 08:40 PM, Gleb Natapov wrote: .. And yes, we have the problem you said here. We can migrate the page while L2 vm is running. So I think we should enforce L2 vm to exit to L1. Right ? We can request APIC_ACCESS_ADDR reload during L2->L1 vmexit emulation, so if

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-17 Thread Tang Chen
Hi Gleb, Sorry for the delay. Please see below. On 07/15/2014 10:40 PM, Gleb Natapov wrote: .. We can request APIC_ACCESS_ADDR reload during L2->L1 vmexit emulation, so if APIC_ACCESS_ADDR changes while L2 is running it will be reloaded for L1 too. apic pages for L2 and L1 are not the

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-17 Thread Tang Chen
Hi Gleb, Sorry for the delay. Please see below. On 07/15/2014 10:40 PM, Gleb Natapov wrote: .. We can request APIC_ACCESS_ADDR reload during L2-L1 vmexit emulation, so if APIC_ACCESS_ADDR changes while L2 is running it will be reloaded for L1 too. apic pages for L2 and L1 are not the

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-17 Thread Tang Chen
Hi Gleb, On 07/15/2014 08:40 PM, Gleb Natapov wrote: .. And yes, we have the problem you said here. We can migrate the page while L2 vm is running. So I think we should enforce L2 vm to exit to L1. Right ? We can request APIC_ACCESS_ADDR reload during L2-L1 vmexit emulation, so if

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-17 Thread Gleb Natapov
On Thu, Jul 17, 2014 at 09:34:20PM +0800, Tang Chen wrote: Hi Gleb, On 07/15/2014 08:40 PM, Gleb Natapov wrote: .. And yes, we have the problem you said here. We can migrate the page while L2 vm is running. So I think we should enforce L2 vm to exit to L1. Right ? We can request

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 08:54:01PM +0800, Tang Chen wrote: > On 07/15/2014 08:40 PM, Gleb Natapov wrote: > >On Tue, Jul 15, 2014 at 08:28:22PM +0800, Tang Chen wrote: > >>On 07/15/2014 08:09 PM, Gleb Natapov wrote: > >>>On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: > >>.. >

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 03:10:15PM +0200, Jan Kiszka wrote: > On 2014-07-15 14:40, Gleb Natapov wrote: > >> > >> .. > >> 7922 if (!vmx->nested.apic_access_page) > >> 7923 exec_control &= > >> 7924 ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Jan Kiszka
On 2014-07-15 14:40, Gleb Natapov wrote: >> >> .. >> 7922 if (!vmx->nested.apic_access_page) >> 7923 exec_control &= >> 7924 ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; >> 7925 else >> 7926

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Tang Chen
On 07/15/2014 08:40 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 08:28:22PM +0800, Tang Chen wrote: On 07/15/2014 08:09 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: .. I cannot follow your concerns yet. Specifically, how should APIC_ACCESS_ADDR

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 08:28:22PM +0800, Tang Chen wrote: > On 07/15/2014 08:09 PM, Gleb Natapov wrote: > >On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: > .. > >> > >>I cannot follow your concerns yet. Specifically, how should > >>APIC_ACCESS_ADDR (the VMCS field, right?) change

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Tang Chen
On 07/15/2014 08:09 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: .. I cannot follow your concerns yet. Specifically, how should APIC_ACCESS_ADDR (the VMCS field, right?) change while L2 is running? We currently pin/unpin on L1->L2/L2->L1,

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Tang Chen
On 07/15/2014 07:52 PM, Jan Kiszka wrote: On 2014-07-14 16:58, Gleb Natapov wrote: .. + struct page *page = gfn_to_page_no_pin(vcpu->kvm, + APIC_DEFAULT_PHYS_BASE>> PAGE_SHIFT); If you do not use kvm->arch.apic_access_page to get current

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: > On 2014-07-14 16:58, Gleb Natapov wrote: > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index ffbe557..7080eda 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -5929,6 +5929,18 @@

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Jan Kiszka
On 2014-07-14 16:58, Gleb Natapov wrote: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ffbe557..7080eda 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5929,6 +5929,18 @@ static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu)

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Jan Kiszka
On 2014-07-14 16:58, Gleb Natapov wrote: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ffbe557..7080eda 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5929,6 +5929,18 @@ static void vcpu_scan_ioapic(struct kvm_vcpu *vcpu) kvm_apic_update_tmr(vcpu, tmr); }

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: On 2014-07-14 16:58, Gleb Natapov wrote: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ffbe557..7080eda 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5929,6 +5929,18 @@ static void

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Tang Chen
On 07/15/2014 07:52 PM, Jan Kiszka wrote: On 2014-07-14 16:58, Gleb Natapov wrote: .. + struct page *page = gfn_to_page_no_pin(vcpu-kvm, + APIC_DEFAULT_PHYS_BASE PAGE_SHIFT); If you do not use kvm-arch.apic_access_page to get current address

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Tang Chen
On 07/15/2014 08:09 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: .. I cannot follow your concerns yet. Specifically, how should APIC_ACCESS_ADDR (the VMCS field, right?) change while L2 is running? We currently pin/unpin on L1-L2/L2-L1, respectively.

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 08:28:22PM +0800, Tang Chen wrote: On 07/15/2014 08:09 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: .. I cannot follow your concerns yet. Specifically, how should APIC_ACCESS_ADDR (the VMCS field, right?) change while L2 is

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Tang Chen
On 07/15/2014 08:40 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 08:28:22PM +0800, Tang Chen wrote: On 07/15/2014 08:09 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: .. I cannot follow your concerns yet. Specifically, how should APIC_ACCESS_ADDR

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Jan Kiszka
On 2014-07-15 14:40, Gleb Natapov wrote: .. 7922 if (!vmx-nested.apic_access_page) 7923 exec_control = 7924 ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; 7925 else 7926

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 03:10:15PM +0200, Jan Kiszka wrote: On 2014-07-15 14:40, Gleb Natapov wrote: .. 7922 if (!vmx-nested.apic_access_page) 7923 exec_control = 7924 ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; 7925

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 08:54:01PM +0800, Tang Chen wrote: On 07/15/2014 08:40 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 08:28:22PM +0800, Tang Chen wrote: On 07/15/2014 08:09 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: .. I cannot follow

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-14 Thread Gleb Natapov
CCing Jan to check my nested kvm findings below. On Mon, Jul 14, 2014 at 03:57:09PM +0800, Tang Chen wrote: > Hi Gleb, > > Thanks for the reply. Please see below. > > On 07/12/2014 04:04 PM, Gleb Natapov wrote: > >On Tue, Jul 08, 2014 at 09:01:32PM +0800, Tang Chen wrote: > >>apic access page

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-14 Thread Tang Chen
Hi Gleb, Thanks for the reply. Please see below. On 07/12/2014 04:04 PM, Gleb Natapov wrote: On Tue, Jul 08, 2014 at 09:01:32PM +0800, Tang Chen wrote: apic access page is pinned in memory. As a result, it cannot be migrated/hot-removed. Actually, it is not necessary to be pinned. The hpa

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-14 Thread Tang Chen
Hi Gleb, Thanks for the reply. Please see below. On 07/12/2014 04:04 PM, Gleb Natapov wrote: On Tue, Jul 08, 2014 at 09:01:32PM +0800, Tang Chen wrote: apic access page is pinned in memory. As a result, it cannot be migrated/hot-removed. Actually, it is not necessary to be pinned. The hpa

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-14 Thread Gleb Natapov
CCing Jan to check my nested kvm findings below. On Mon, Jul 14, 2014 at 03:57:09PM +0800, Tang Chen wrote: Hi Gleb, Thanks for the reply. Please see below. On 07/12/2014 04:04 PM, Gleb Natapov wrote: On Tue, Jul 08, 2014 at 09:01:32PM +0800, Tang Chen wrote: apic access page is pinned

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-12 Thread Gleb Natapov
On Tue, Jul 08, 2014 at 09:01:32PM +0800, Tang Chen wrote: > apic access page is pinned in memory. As a result, it cannot be > migrated/hot-removed. > Actually, it is not necessary to be pinned. > > The hpa of apic access page is stored in VMCS APIC_ACCESS_ADDR pointer. When > the page is

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-12 Thread Gleb Natapov
On Tue, Jul 08, 2014 at 09:01:32PM +0800, Tang Chen wrote: apic access page is pinned in memory. As a result, it cannot be migrated/hot-removed. Actually, it is not necessary to be pinned. The hpa of apic access page is stored in VMCS APIC_ACCESS_ADDR pointer. When the page is migrated,