Re: [Xen-devel] [PATCH V3 2/8] xen: Delay remapping memory of pv-domain

From: Andrew Cooper
Date: Tue Nov 11 2014 - 06:45:24 EST


On 11/11/14 05:43, Juergen Gross wrote:
> diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
> index fa75842..f67f8cf 100644
> --- a/arch/x86/xen/p2m.c
> +++ b/arch/x86/xen/p2m.c
> @@ -268,6 +271,22 @@ static void p2m_init(unsigned long *p2m)
> p2m[i] = INVALID_P2M_ENTRY;
> }
>
> +static void * __ref alloc_p2m_page(void)
> +{
> + if (unlikely(use_brk))
> + return extend_brk(PAGE_SIZE, PAGE_SIZE);
> +
> + if (unlikely(!slab_is_available()))
> + return alloc_bootmem_align(PAGE_SIZE, PAGE_SIZE);
> +
> + return (void *)__get_free_page(GFP_KERNEL | __GFP_REPEAT);
> +}
> +
> +static void free_p2m_page(void *p)
> +{
> + free_page((unsigned long)p);
> +}
> +

What guarantees are there that free_p2m_page() is only called on p2m
pages allocated using __get_free_page() ? I can see from this diff that
this is the case, but that doesn't help someone coming along in the future.

At the very least, a comment is warranted about the apparent mismatch
between {alloc,free}_p2m_page().

> @@ -420,6 +439,7 @@ unsigned long __init xen_revector_p2m_tree(void)
> unsigned long *mfn_list = NULL;
> unsigned long size;
>
> + use_brk = 0;
> va_start = xen_start_info->mfn_list;
> /*We copy in increments of P2M_PER_PAGE * sizeof(unsigned long),
> * so make sure it is rounded up to that */
> @@ -484,6 +504,7 @@ unsigned long __init xen_revector_p2m_tree(void)
> #else
> unsigned long __init xen_revector_p2m_tree(void)
> {
> + use_brk = 0;
> return 0;
> }
> #endif

This appears to be a completely orphaned function.

It has a split definition based on CONFIG_X86_64, but the sole caller is
xen_pagetable_p2m_copy() which is X86_64 only.

How does use_brk get cleared for 32bit PV guests?

~Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/