On 07.07.2022 11:22, Penny Zheng wrote:
> @@ -2692,6 +2690,14 @@ void free_domstatic_page(struct page_info *page)
>  
>      free_staticmem_pages(page, 1, need_scrub);
>  
> +    if ( likely(d) )
> +    {
> +        /* Add page on the resv_page_list *after* it has been freed. */
> +        if ( !drop_dom_ref )
> +            put_static_page(d, page);

I'm not happy about this name - it suggests similarity with put_page(),
but is entirely different. But: Do we really need an helper macro here
in the first place? This is static-mem specific code and hence ...

> --- a/xen/include/xen/mm.h
> +++ b/xen/include/xen/mm.h
> @@ -91,6 +91,12 @@ void free_staticmem_pages(struct page_info *pg, unsigned 
> long nr_mfns,
>  void free_domstatic_page(struct page_info *page);
>  int acquire_domstatic_pages(struct domain *d, mfn_t smfn, unsigned int 
> nr_mfns,
>                              unsigned int memflags);
> +#ifdef CONFIG_STATIC_MEMORY
> +#define put_static_page(d, page) \
> +    page_list_add_tail((page), &(d)->resv_page_list)

... this can live right at the use site since ...

> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -381,6 +381,9 @@ struct domain
>      struct page_list_head page_list;  /* linked list */
>      struct page_list_head extra_page_list; /* linked list (size extra_pages) 
> */
>      struct page_list_head xenpage_list; /* linked list (size xenheap_pages) 
> */
> +#ifdef CONFIG_STATIC_MEMORY
> +    struct page_list_head resv_page_list; /* linked list */
> +#endif

... this field is consistently available (i.e. it's all the same config
option that controls things).

Otherwise a nit on the macro: While the parentheses around d are needed,
the ones around page are not.

Jan

Reply via email to