xen: refactor physical address space compression support into common code
A message that is not in the archive (sent off-list or not yet received): [email protected]
RFC PATCH 1/2 xen: refactor physical address space compression support into common code
The "pdx compression" functionality will be useful on ARM as well.
Move the code to common code+header and introduce HAS_PDX to control when it is built. L2_PAGETABLE_SHIFT is x86 specific, so introduce PDX_GROUP_SHIFT to abstract it out.
ARM has no need for superpage compression (yet?) and lacks SUPERPAGE_SHIFT so those functions (spage_to_mfn et al) are not moved.
No affect on x86 and no change for ARM (yet).
--- xen/Rules.mk | 1 + xen/arch/x86/Rules.mk | 1 + xen/arch/x86/mm.c | 3 -- xen/arch/x86/setup.c | 10 ---- xen/arch/x86/x86_64/mm.c | 53 -------------------- xen/common/Makefile | 1 + xen/common/pdx.c | 99 +++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/mm.h | 4 +- xen/include/asm-x86/page.h | 2 - xen/include/asm-x86/x86_64/page.h | 25 +--------- xen/include/xen/pdx.h | 47 ++++++++++++++++++ 11 files changed, 152 insertions(+), 94 deletions(-) create mode 100644 xen/common/pdx.c create mode 100644 xen/include/xen/pdx.h
xen/Rules.mk +1 -0
@@ -59,6 +59,7 @@ CFLAGS-$(HAS_PASSTHROUGH) += -DHAS_PASSTHROUGH CFLAGS-$(HAS_DEVICE_TREE) += -DHAS_DEVICE_TREE CFLAGS-$(HAS_PCI) += -DHAS_PCI CFLAGS-$(HAS_IOPORTS) += -DHAS_IOPORTS +CFLAGS-$(HAS_PDX) += -DHAS_PDX CFLAGS-$(frame_pointer) += -fno-omit-frame-pointer -DCONFIG_FRAME_POINTER ifneq ($(max_phys_cpus),)
xen/arch/x86/Rules.mk +1 -0
@@ -12,6 +12,7 @@ HAS_NS16550 := y HAS_EHCI := y HAS_KEXEC := y HAS_GDBSX := y +HAS_PDX := y xenoprof := y #
xen/arch/x86/mm.c +0 -3
@@ -147,9 +147,6 @@ struct domain *dom_xen, *dom_io, *dom_cow;unsigned long max_page;unsigned long total_pages; -unsigned long __read_mostly pdx_group_valid[BITS_TO_LONGS ( - (FRAMETABLE_NR +PDX_GROUP_COUNT -1 ) /PDX_GROUP_COUNT )] = { [0 ] =1 }; -bool_t __read_mostly machine_to_phys_mapping_valid =0 ;struct rangeset *__read_mostly mmio_ro_ranges;
xen/arch/x86/setup.c +0 -10
@@ -393,16 +393,6 @@ static void __init setup_max_pdx(unsigned long top_page) max_page =pdx_to_pfn (max_pdx -1 ) +1 ; } -void set_pdx_range (unsigned long smfn,unsigned long emfn) -{ -unsigned long idx, eidx; - - idx =pfn_to_pdx (smfn) /PDX_GROUP_COUNT ; - eidx = (pfn_to_pdx (emfn -1 ) +PDX_GROUP_COUNT ) /PDX_GROUP_COUNT ; -for ( ; idx < eidx; ++idx ) -__set_bit (idx, pdx_group_valid); -} -/* A temporary copy of the e820 map that we can mess with during bootstrap. */ static struct e820map __initdata boot_e820;
xen/arch/x86/x86_64/mm.c +0 -53
71 lines not on this page · raw message
xen/common/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-y += tmem_xen.o obj-y += radix-tree.o obj-y += rbtree.o obj-y += lzo.o +obj-$(HAS_PDX) += pdx.o obj-bin-$(CONFIG_X86) += $(foreach n,decompress bunzip2 unxz unlzma unlzo unlz4 earlycpio,$(n).init.o)
xen/common/pdx.c new file +99 -0
99 lines not on this page · raw message
xen/include/asm-x86/mm.h +1 -3
@@ -280,9 +280,7 @@ extern unsigned long max_page;extern unsigned long total_pages;void init_frametable (void ); -#define PDX_GROUP_COUNT ((1 << L2_PAGETABLE_SHIFT) / \ - (sizeof(*frame_table) & -sizeof(*frame_table))) -extern unsigned long pdx_group_valid[]; +#define PDX_GROUP_SHIFT L2_PAGETABLE_SHIFT/* Convert between Xen-heap virtual addresses and page-info structures. */ static inline struct page_info *__virt_to_page (const void *v)
xen/include/asm-x86/page.h +0 -2
@@ -334,8 +334,6 @@ void *alloc_xen_pagetable(void);void free_xen_pagetable (void *v);l1_pgentry_t *virt_to_xen_l1e (unsigned long v); -extern void set_pdx_range (unsigned long smfn,unsigned long emfn); -/* Convert between PAT/PCD/PWT embedded in PTE flags and 3-bit cacheattr. */ static inline uint32_t pte_flags_to_cacheattr (uint32_t flags) {
xen/include/asm-x86/x86_64/page.h +2 -23
@@ -35,17 +35,10 @@#include <xen/config.h> #include <asm/types.h> -extern unsigned long xen_virt_end; +#include <xen/pdx.h> -extern unsigned long max_pdx; -extern unsigned long pfn_pdx_bottom_mask, ma_va_bottom_mask; -extern unsigned int pfn_pdx_hole_shift; -extern unsigned long pfn_hole_mask; -extern unsigned long pfn_top_mask, ma_top_mask; -extern void pfn_pdx_hole_setup (unsigned long ); +extern unsigned long xen_virt_end; -#define page_to_pdx (pg) ((pg) - frame_table) -#define pdx_to_page (pdx) (frame_table + (pdx))#define spage_to_pdx (spg) (((spg) - spage_table)<<(SUPERPAGE_SHIFT-PAGE_SHIFT))#define pdx_to_spage (pdx) (spage_table + ((pdx)>>(SUPERPAGE_SHIFT-PAGE_SHIFT)))/*
@@ -57,20 +50,6 @@ extern void pfn_pdx_hole_setup(unsigned long);#define pdx_to_virt (pdx) ((void *)(DIRECTMAP_VIRT_START + \ ((unsigned long)(pdx) << PAGE_SHIFT))) -extern int __mfn_valid (unsigned long mfn); - -static inline unsigned long pfn_to_pdx (unsigned long pfn) -{ -return (pfn & pfn_pdx_bottom_mask) | - ((pfn & pfn_top_mask) >> pfn_pdx_hole_shift); -} - -static inline unsigned long pdx_to_pfn (unsigned long pdx) -{ -return (pdx & pfn_pdx_bottom_mask) | - ((pdx << pfn_pdx_hole_shift) & pfn_top_mask); -} -static inline unsigned long pfn_to_sdx (unsigned long pfn) {return pfn_to_pdx (pfn) >> (SUPERPAGE_SHIFT -PAGE_SHIFT );
xen/include/xen/pdx.h new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
1.7.10.4
A message that is not in the archive (sent off-list or not yet received): [email protected]
Jan Beulich
Acked-byQuoted 7 lines
Quoted 1 line
Quoted 1 line · On 31.07.14 at 13:01, <[email protected]> wrote:
The "pdx compression" functionality will be useful on ARM as well.
Move the code to common code+header and introduce
HAS_PDXto control when it is built.L2_PAGETABLE_SHIFTis x86 specific, so introducePDX_GROUP_SHIFTto abstract it out.
Quoted 6 lines
ARM has no need for superpage compression (yet?) and lacks
SUPERPAGE_SHIFTso those functions (spage_to_mfnet al) are not moved.No affect on x86 and no change for ARM (yet).
Signed-off-by Ian Campbell <[email protected]>
On the basis this is, as it looks to be, pure code motion except for the few obvious places where other adjustments are needed:
Re: [PATCH RFC 0/2] Support for spare physical address space on ARM
In reply to a message not in the archiveQuoted 2 lines · Ian Campbell
This series refactors the x86 "pdx" stuff (phys address space compression) into common code and makes use of it on ARM.
In case anyone was wondering $subject should say "sparse", not "spare".
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Ian,
Quoted 34 lines · Ian Campbell
xen/include/xen/pdx.h new file +28
-0@@ -0,0 +1,47 @@ +#ifndef __XEN_PDX_H__ +#define __XEN_PDX_H__ + +#ifdef HAS_PDX + +extern unsigned long max_pdx; +extern unsigned long pfn_pdx_bottom_mask, ma_va_bottom_mask; +extern unsigned int pfn_pdx_hole_shift; +extern unsigned long pfn_hole_mask; +extern unsigned long pfn_top_mask, ma_top_mask; + +#define PDX_GROUP_COUNT ((1 << PDX_GROUP_SHIFT) / \ + (sizeof(*frame_table) & -sizeof(*frame_table))) +extern unsigned long pdx_group_valid[]; + +extern void set_pdx_range (unsigned long smfn,unsigned long emfn); + +#define page_to_pdx (pg) ((pg) - frame_table) +#define pdx_to_page (pdx) (frame_table + (pdx)) + +extern int __mfn_valid (unsigned long mfn); + +static inline unsigned long pfn_to_pdx (unsigned long pfn) +{ +return (pfn & pfn_pdx_bottom_mask) | + ((pfn & pfn_top_mask) >> pfn_pdx_hole_shift); +} +
xen/include/xen/pdx.h line 38
Quoted 10 lines
xen/include/xen/pdx.h new file +10
-0+static inline unsigned long pdx_to_pfn (unsigned long pdx) +{ +return (pdx & pfn_pdx_bottom_mask) | + ((pdx << pfn_pdx_hole_shift) & pfn_top_mask); +} + +extern void pfn_pdx_hole_setup (unsigned long ); + +#endif /* HAVE_PDX */ +#endif /* __XEN_PAGING_H__ */
NIT: I think the comment should be /* __XEN_PDX_H__ */
Regards,
Signature · 1 line
Julien Grall