[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 15/18] mini-os: remap p2m list in case of ballooning



Juergen Gross, on Fri 05 Aug 2016 19:35:59 +0200, wrote:
> In case of enabled ballooning we must be prepared for a growing p2m
> list. If the maximum memory size of the domain can't be covered by the
> actual p2m list remap it to the kernel virtual mapping area and leave
> enough space at the end.
> 
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>

Reviewed-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>

> ---
>  arch/arm/balloon.c    |  2 ++
>  arch/x86/balloon.c    | 24 ++++++++++++++++++++++++
>  arch/x86/mm.c         |  3 +++
>  include/balloon.h     |  3 +++
>  include/x86/arch_mm.h |  4 ++++
>  5 files changed, 36 insertions(+)
> 
> diff --git a/arch/arm/balloon.c b/arch/arm/balloon.c
> index dc6270d..a76db3b 100644
> --- a/arch/arm/balloon.c
> +++ b/arch/arm/balloon.c
> @@ -25,4 +25,6 @@
>  
>  #ifdef CONFIG_BALLOON
>  
> +unsigned long virt_kernel_area_end;   /* TODO: find a virtual area */
> +
>  #endif
> diff --git a/arch/x86/balloon.c b/arch/x86/balloon.c
> index dc6270d..db37e8f 100644
> --- a/arch/x86/balloon.c
> +++ b/arch/x86/balloon.c
> @@ -21,8 +21,32 @@
>   * DEALINGS IN THE SOFTWARE.
>   */
>  
> +#include <mini-os/os.h>
>  #include <mini-os/balloon.h>
> +#include <mini-os/lib.h>
> +#include <mini-os/mm.h>
>  
>  #ifdef CONFIG_BALLOON
>  
> +unsigned long virt_kernel_area_end = VIRT_KERNEL_AREA;
> +
> +void arch_remap_p2m(unsigned long max_pfn)
> +{
> +    unsigned long pfn;
> +
> +    if ( p2m_pages(nr_max_pages) <= p2m_pages(max_pfn) )
> +        return;
> +
> +    for ( pfn = 0; pfn < max_pfn; pfn += P2M_ENTRIES )
> +    {
> +        map_frame_rw(virt_kernel_area_end + PAGE_SIZE * (pfn / P2M_ENTRIES),
> +                     virt_to_mfn(phys_to_machine_mapping + pfn));
> +    }
> +
> +    phys_to_machine_mapping = (unsigned long *)virt_kernel_area_end;
> +    printk("remapped p2m list to %p\n", phys_to_machine_mapping);
> +
> +    virt_kernel_area_end += PAGE_SIZE * p2m_pages(nr_max_pages);
> +}
> +
>  #endif
> diff --git a/arch/x86/mm.c b/arch/x86/mm.c
> index a5c8959..8fa3b4c 100644
> --- a/arch/x86/mm.c
> +++ b/arch/x86/mm.c
> @@ -37,6 +37,7 @@
>  #include <mini-os/errno.h>
>  #include <mini-os/os.h>
>  #include <mini-os/hypervisor.h>
> +#include <mini-os/balloon.h>
>  #include <mini-os/mm.h>
>  #include <mini-os/types.h>
>  #include <mini-os/lib.h>
> @@ -626,6 +627,8 @@ void arch_init_p2m(unsigned long max_pfn)
>      HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = 
>          virt_to_mfn(l3_list);
>      HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
> +
> +    arch_remap_p2m(max_pfn);
>  }
>  
>  void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p)
> diff --git a/include/balloon.h b/include/balloon.h
> index e7219f8..b8d9335 100644
> --- a/include/balloon.h
> +++ b/include/balloon.h
> @@ -27,12 +27,15 @@
>  #ifdef CONFIG_BALLOON
>  
>  extern unsigned long nr_max_pages;
> +extern unsigned long virt_kernel_area_end;
>  
>  void get_max_pages(void);
> +void arch_remap_p2m(unsigned long max_pfn);
>  
>  #else /* CONFIG_BALLOON */
>  
>  static inline void get_max_pages(void) { }
> +static inline void arch_remap_p2m(unsigned long max_pfn) { }
>  
>  #endif /* CONFIG_BALLOON */
>  #endif /* _BALLOON_H_ */
> diff --git a/include/x86/arch_mm.h b/include/x86/arch_mm.h
> index 7283f64..e5d9c57 100644
> --- a/include/x86/arch_mm.h
> +++ b/include/x86/arch_mm.h
> @@ -198,6 +198,10 @@ static inline void p2m_chk_pfn(unsigned long pfn)
>          do_exit();
>      }
>  }
> +static inline unsigned long p2m_pages(unsigned long pages)
> +{
> +    return (pages + P2M_ENTRIES - 1) >> L1_P2M_SHIFT;
> +}
>  
>  #include "arch_limits.h"
>  #define PAGE_SIZE       __PAGE_SIZE
> -- 
> 2.6.6
> 

-- 
Samuel
<r> make
<r> oops
<m> make clean

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.