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

Re: [Xen-devel] [PATCH] xen: simplify balloon_first_page() with list_first_entry_or_null()



On 13/11/13 11:44, Jeff Liu wrote:
> From: Jie Liu <jeff.liu@xxxxxxxxxx>
> 
> Simplify the code logic of balloon_first_page() by replacing
> the combination of list_empty() and list_first_entry() with
> list_first_entry_or_null().  As a net win, we can change this
> routine to inline as now it's one line.
> 
> Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
> 
> ---
>  drivers/xen/balloon.c |    7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
> index b232908..0e4ca20 100644
> --- a/drivers/xen/balloon.c
> +++ b/drivers/xen/balloon.c
> @@ -157,11 +157,10 @@ static struct page *balloon_retrieve(bool 
> prefer_highmem)
>       return page;
>  }
>  
> -static struct page *balloon_first_page(void)
> +static inline struct page *balloon_first_page(void)
>  {
> -     if (list_empty(&ballooned_pages))
> -             return NULL;
> -     return list_entry(ballooned_pages.next, struct page, lru);
> +     return list_first_entry_or_null(&ballooned_pages,
> +                                     struct page, lru);
>  }

There's only one user of balloon_first_page(), can you remove
balloon_first_page() and just use list_first_entry_or_null()?

David

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


 


Rackspace

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