Re: [PATCH 2/8] xen/balloon: Move common memory reservation routines to a module

From: Oleksandr Andrushchenko
Date: Thu May 31 2018 - 10:29:22 EST


On 05/31/2018 10:51 AM, Oleksandr Andrushchenko wrote:
On 05/30/2018 10:24 PM, Boris Ostrovsky wrote:
On 05/30/2018 01:46 PM, Oleksandr Andrushchenko wrote:
On 05/30/2018 06:54 PM, Boris Ostrovsky wrote:

BTW, I also think you can further simplify
xenmem_reservation_va_mapping_* routines by bailing out right away if
xen_feature(XENFEAT_auto_translated_physmap). In fact, you might even
make them inlines, along the lines of

inline void xenmem_reservation_va_mapping_reset(unsigned long count,
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ struct page **pages)
{
#ifdef CONFIG_XEN_HAVE_PVMMU
ÂÂÂÂÂif (!xen_feature(XENFEAT_auto_translated_physmap))
ÂÂÂÂÂÂÂÂ __xenmem_reservation_va_mapping_reset(...)
#endif
}
How about:

#ifdef CONFIG_XEN_HAVE_PVMMU
static inline __xenmem_reservation_va_mapping_reset(struct page *page)
{
[...]
}
#endif

and

void xenmem_reservation_va_mapping_reset(unsigned long count,
ÂÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ Âstruct page **pages)
{
#ifdef CONFIG_XEN_HAVE_PVMMU
ÂÂÂÂ if (!xen_feature(XENFEAT_auto_translated_physmap)) {
ÂÂÂÂ ÂÂÂ int i;

ÂÂÂÂ ÂÂÂ for (i = 0; i < count; i++)
ÂÂÂÂ ÂÂÂ ÂÂÂ __xenmem_reservation_va_mapping_reset(pages[i]);
ÂÂÂÂ }
#endif
}

This way I can use __xenmem_reservation_va_mapping_reset(page);
instead of xenmem_reservation_va_mapping_reset(1, &page);

Sure, this also works.
Could you please take look at the patch attached if this is what we want?
Please ignore it, it is ugly ;)
I have implemented this as you suggested:

static inline void
xenmem_reservation_va_mapping_update(unsigned long count,
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂÂ struct page **pages,
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂÂ xen_pfn_t *frames)
{
#ifdef CONFIG_XEN_HAVE_PVMMU
ÂÂÂ if (!xen_feature(XENFEAT_auto_translated_physmap))
ÂÂÂ ÂÂÂ __xenmem_reservation_va_mapping_update(count, pages, frames);
#endif
}

-boris

Thank you,
Oleksandr