diff mbox

[Vivid/Wily,SRU] x86/xen/p2m: hint at the last populated P2M entry

Message ID 1454955189-2020-1-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner Feb. 8, 2016, 6:13 p.m. UTC
From: David Vrabel <david.vrabel@citrix.com>

BugLink: http://bugs.launchpad.net/bugs/1542941

With commit 633d6f17cd91ad5bf2370265946f716e42d388c6 (x86/xen: prepare
p2m list for memory hotplug) the P2M may be sized to accomdate a much
larger amount of memory than the domain currently has.

When saving a domain, the toolstack must scan all the P2M looking for
populated pages.  This results in a performance regression due to the
unnecessary scanning.

Instead of reporting (via shared_info) the maximum possible size of
the P2M, hint at the last PFN which might be populated.  This hint is
increased as new leaves are added to the P2M (in the expectation that
they will be used for populated entries).

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Cc: <stable@vger.kernel.org> # 4.0+
(back ported from commit 98dd166ea3a3c3b57919e20d9b0d1237fcd0349d)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>

Conflicts:
	arch/x86/xen/p2m.c
---
 arch/x86/xen/p2m.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Kamal Mostafa Feb. 8, 2016, 7:44 p.m. UTC | #1
ACK for Vivid/Wily SRU.

(I will also queue up this backport for 3.19- and 4.2- stable.)

 -Kamal
Andy Whitcroft Feb. 9, 2016, 5:47 p.m. UTC | #2
On Mon, Feb 08, 2016 at 11:13:09AM -0700, tim.gardner@canonical.com wrote:
> From: David Vrabel <david.vrabel@citrix.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1542941
> 
> With commit 633d6f17cd91ad5bf2370265946f716e42d388c6 (x86/xen: prepare
> p2m list for memory hotplug) the P2M may be sized to accomdate a much
> larger amount of memory than the domain currently has.
> 
> When saving a domain, the toolstack must scan all the P2M looking for
> populated pages.  This results in a performance regression due to the
> unnecessary scanning.
> 
> Instead of reporting (via shared_info) the maximum possible size of
> the P2M, hint at the last PFN which might be populated.  This hint is
> increased as new leaves are added to the P2M (in the expectation that
> they will be used for populated entries).
> 
> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
> Cc: <stable@vger.kernel.org> # 4.0+
> (back ported from commit 98dd166ea3a3c3b57919e20d9b0d1237fcd0349d)

I think that is in a non-standard form.  Using the standard forms helps
things like the autotriager which read them.

> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> 
> Conflicts:
> 	arch/x86/xen/p2m.c

I'd move those two up between the (backported ...) and Tim's SOB.

> ---
>  arch/x86/xen/p2m.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
> index 8b7f18e..912b123 100644
> --- a/arch/x86/xen/p2m.c
> +++ b/arch/x86/xen/p2m.c
> @@ -108,6 +108,15 @@ static unsigned long *p2m_identity;
>  static pte_t *p2m_missing_pte;
>  static pte_t *p2m_identity_pte;
>  
> +/*
> + * Hint at last populated PFN.
> + *
> + * Used to set HYPERVISOR_shared_info->arch.max_pfn so the toolstack
> + * can avoid scanning the whole P2M (which may be sized to account for
> + * hotplugged memory).
> + */
> +static unsigned long xen_p2m_last_pfn;
> +
>  static inline unsigned p2m_top_index(unsigned long pfn)
>  {
>  	BUG_ON(pfn >= MAX_P2M_PFN);
> @@ -262,7 +271,7 @@ void xen_setup_mfn_list_list(void)
>  
>  	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
>  		virt_to_mfn(p2m_top_mfn);
> -	HYPERVISOR_shared_info->arch.max_pfn = xen_max_p2m_pfn;
> +	HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn;
>  }
>  
>  /* Set up p2m_top to point to the domain-builder provided p2m pages */
> @@ -394,6 +403,8 @@ void __init xen_vmalloc_p2m_tree(void)
>  	static struct vm_struct vm;
>  	unsigned long p2m_limit;
>  
> +	xen_p2m_last_pfn = xen_max_p2m_pfn;
> +
>  	p2m_limit = (phys_addr_t)P2M_LIMIT * 1024 * 1024 * 1024 / PAGE_SIZE;
>  	vm.flags = VM_ALLOC;
>  	vm.size = ALIGN(sizeof(unsigned long) * max(xen_max_p2m_pfn, p2m_limit),
> @@ -590,6 +601,12 @@ static bool alloc_p2m(unsigned long pfn)
>  			free_p2m_page(p2m);
>  	}
>  
> +	/* Expanded the p2m? */
> +	if (pfn > xen_p2m_last_pfn) {
> +		xen_p2m_last_pfn = pfn;
> +		HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn;
> +	}
> +
>  	return true;
>  }
>  

Acked-by: Andy Whitcroft <apw@canonical.com>

-apw
Kamal Mostafa Feb. 9, 2016, 6:55 p.m. UTC | #3
Applied to [V,W] master-next.

 -Kamal
Tim Gardner Feb. 9, 2016, 8:40 p.m. UTC | #4
On 02/09/2016 09:47 AM, Andy Whitcroft wrote:
> On Mon, Feb 08, 2016 at 11:13:09AM -0700, tim.gardner@canonical.com wrote:
>> From: David Vrabel <david.vrabel@citrix.com>
>>
>> BugLink: http://bugs.launchpad.net/bugs/1542941
>>
>> With commit 633d6f17cd91ad5bf2370265946f716e42d388c6 (x86/xen: prepare
>> p2m list for memory hotplug) the P2M may be sized to accomdate a much
>> larger amount of memory than the domain currently has.
>>
>> When saving a domain, the toolstack must scan all the P2M looking for
>> populated pages.  This results in a performance regression due to the
>> unnecessary scanning.
>>
>> Instead of reporting (via shared_info) the maximum possible size of
>> the P2M, hint at the last PFN which might be populated.  This hint is
>> increased as new leaves are added to the P2M (in the expectation that
>> they will be used for populated entries).
>>
>> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
>> Cc: <stable@vger.kernel.org> # 4.0+
>> (back ported from commit 98dd166ea3a3c3b57919e20d9b0d1237fcd0349d)
> 
> I think that is in a non-standard form.  Using the standard forms helps
> things like the autotriager which read them.
> 

What is standard form ? 'backported' v.s. 'back ported' ?
Brad Figg Feb. 11, 2016, 6:10 p.m. UTC | #5
On Tue, Feb 09, 2016 at 12:40:20PM -0800, Tim Gardner wrote:
> On 02/09/2016 09:47 AM, Andy Whitcroft wrote:
> > On Mon, Feb 08, 2016 at 11:13:09AM -0700, tim.gardner@canonical.com wrote:
> >> From: David Vrabel <david.vrabel@citrix.com>
> >>
> >> BugLink: http://bugs.launchpad.net/bugs/1542941
> >>
> >> With commit 633d6f17cd91ad5bf2370265946f716e42d388c6 (x86/xen: prepare
> >> p2m list for memory hotplug) the P2M may be sized to accomdate a much
> >> larger amount of memory than the domain currently has.
> >>
> >> When saving a domain, the toolstack must scan all the P2M looking for
> >> populated pages.  This results in a performance regression due to the
> >> unnecessary scanning.
> >>
> >> Instead of reporting (via shared_info) the maximum possible size of
> >> the P2M, hint at the last PFN which might be populated.  This hint is
> >> increased as new leaves are added to the P2M (in the expectation that
> >> they will be used for populated entries).
> >>
> >> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
> >> Cc: <stable@vger.kernel.org> # 4.0+
> >> (back ported from commit 98dd166ea3a3c3b57919e20d9b0d1237fcd0349d)
> > 
> > I think that is in a non-standard form.  Using the standard forms helps
> > things like the autotriager which read them.
> > 
> 
> What is standard form ? 'backported' v.s. 'back ported' ?
> -- 
> Tim Gardner tim.gardner@canonical.com
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

Looking at some of our git repos we have been using "backported".
diff mbox

Patch

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 8b7f18e..912b123 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -108,6 +108,15 @@  static unsigned long *p2m_identity;
 static pte_t *p2m_missing_pte;
 static pte_t *p2m_identity_pte;
 
+/*
+ * Hint at last populated PFN.
+ *
+ * Used to set HYPERVISOR_shared_info->arch.max_pfn so the toolstack
+ * can avoid scanning the whole P2M (which may be sized to account for
+ * hotplugged memory).
+ */
+static unsigned long xen_p2m_last_pfn;
+
 static inline unsigned p2m_top_index(unsigned long pfn)
 {
 	BUG_ON(pfn >= MAX_P2M_PFN);
@@ -262,7 +271,7 @@  void xen_setup_mfn_list_list(void)
 
 	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
 		virt_to_mfn(p2m_top_mfn);
-	HYPERVISOR_shared_info->arch.max_pfn = xen_max_p2m_pfn;
+	HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn;
 }
 
 /* Set up p2m_top to point to the domain-builder provided p2m pages */
@@ -394,6 +403,8 @@  void __init xen_vmalloc_p2m_tree(void)
 	static struct vm_struct vm;
 	unsigned long p2m_limit;
 
+	xen_p2m_last_pfn = xen_max_p2m_pfn;
+
 	p2m_limit = (phys_addr_t)P2M_LIMIT * 1024 * 1024 * 1024 / PAGE_SIZE;
 	vm.flags = VM_ALLOC;
 	vm.size = ALIGN(sizeof(unsigned long) * max(xen_max_p2m_pfn, p2m_limit),
@@ -590,6 +601,12 @@  static bool alloc_p2m(unsigned long pfn)
 			free_p2m_page(p2m);
 	}
 
+	/* Expanded the p2m? */
+	if (pfn > xen_p2m_last_pfn) {
+		xen_p2m_last_pfn = pfn;
+		HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn;
+	}
+
 	return true;
 }