xen/setup: Remap Xen Identity Mapped RAM
Subsystems (2)
PATCH 1/1 xen/setup: Remap Xen Identity Mapped RAM
Instead of ballooning up and down dom0 memory this remaps the existing mfns that were replaced by the identity map. The reason for this is that the existing implementation ballooned memory up and and down which caused dom0 to have discontiguous pages. In some cases this resulted in the use of bounce buffers which reduced network I/O performance by up to 15%. This change will honor the existing order of the pages with the exception of some boundary conditions.
To do this we need to update both the Linux p2m table and the Xen m2p table. Particular care must be taken when updating the p2m table since it's important to limit table memory consumption and reuse the existing leaf pages which get freed when an entire leaf page is set to the identity map. To implement this, mapping updates are grouped into blocks with table entries getting cached temporarily and then released.
On my test system before:
Total pages: 2105014
Total contiguous: 1640635
After:
Total pages: 2105014
Total contiguous: 2098904
--- arch/x86/xen/p2m.c | 20 ++- arch/x86/xen/p2m.h | 15 ++ arch/x86/xen/setup.c | 378 ++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 311 insertions(+), 102 deletions(-) create mode 100644 arch/x86/xen/p2m.h
arch/x86/xen/p2m.c +8 -12
@@ -164,6 +164,7 @@#include <xen/balloon.h> #include <xen/grant_table.h> +#include "p2m.h" #include "multicalls.h" #include "xen-ops.h"
@@ -171,12 +172,6 @@ static void __init m2p_override_init(void);unsigned long xen_max_p2m_pfn__read_mostly ; -#define P2M_PER_PAGE (PAGE_SIZE / sizeof(unsigned long)) -#define P2M_MID_PER_PAGE (PAGE_SIZE / sizeof(unsigned long *)) -#define P2M_TOP_PER_PAGE (PAGE_SIZE / sizeof(unsigned long **)) - -#define MAX_P2M_PFN (P2M_TOP_PER_PAGE * P2M_MID_PER_PAGE * P2M_PER_PAGE) -/* Placeholders for holes in the address space */ static RESERVE_BRK_ARRAY(unsigned long, p2m_missing, P2M_PER_PAGE); static RESERVE_BRK_ARRAY(unsigned long *, p2m_mid_missing, P2M_MID_PER_PAGE);
@@ -191,9 +186,11 @@ static RESERVE_BRK_ARRAY(unsigned long, p2m_identity, P2M_PER_PAGE);RESERVE_BRK (p2m_mid,PAGE_SIZE * (MAX_DOMAIN_PAGES / (P2M_PER_PAGE *P2M_MID_PER_PAGE )));RESERVE_BRK (p2m_mid_mfn,PAGE_SIZE * (MAX_DOMAIN_PAGES / (P2M_PER_PAGE *P2M_MID_PER_PAGE ))); -/* We might hit two boundary violations at the start and end, at max each -* boundary violation will require three middle nodes. */ -RESERVE_BRK (p2m_mid_identity,PAGE_SIZE *2 *3 ); +/* We may lose up to three pages due to boundary violations for each pfn range +* we identity map. We use a reasonable default to define the max number of +* these ranges that are possible. +*/ +RESERVE_BRK (p2m_mid_identity,PAGE_SIZE *3 *MAX_REMAP_RANGES );/* When we populate back during bootup, the amount of pages can vary. The * max we have is seen is 395979, but that does not mean it can't be more.
@@ -797,10 +794,9 @@ unsigned long __init set_phys_range_identity(unsigned long pfn_s,if (!__set_phys_to_machine (pfn,IDENTITY_FRAME (pfn)))break ; -if (!WARN ((pfn - pfn_s) != (pfn_e - pfn_s), +WARN ((pfn - pfn_s) != (pfn_e - pfn_s),"Identity mapping failed. We are %ld short of 1-1 mappings!\n" , - (pfn_e - pfn_s) - (pfn - pfn_s))) -printk (KERN_DEBUG "1-1 mapping on %lx->%lx\n" , pfn_s, pfn); + (pfn_e - pfn_s) - (pfn - pfn_s));return pfn - pfn_s; }
arch/x86/xen/p2m.h new file +15 -0
@@ -0,0 +1,15 @@ +#ifndef _XEN_P2M_H +#define _XEM_P2M_H + +#define P2M_PER_PAGE (PAGE_SIZE / sizeof(unsigned long)) +#define P2M_MID_PER_PAGE (PAGE_SIZE / sizeof(unsigned long *)) +#define P2M_TOP_PER_PAGE (PAGE_SIZE / sizeof(unsigned long **)) + +#define MAX_P2M_PFN (P2M_TOP_PER_PAGE * P2M_MID_PER_PAGE * P2M_PER_PAGE) + +#define MAX_REMAP_RANGES 10 + +extern unsigned long __init set_phys_range_identity (unsigned long pfn_s, +unsigned long pfn_e); + +#endif /* _XEN_P2M_H */
arch/x86/xen/setup.c +288 -90
468 lines not on this page · raw message
Signature · 1 line
1.7.9.5