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

Re: [Xen-devel] [PATCH] provide a single, common implementation for get_order_from_{bytes, pages}()


  • To: Jan Beulich <JBeulich@xxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxx>
  • From: Keir Fraser <keir@xxxxxxx>
  • Date: Wed, 07 Mar 2012 10:20:49 +0000
  • Delivery-date: Wed, 07 Mar 2012 10:21:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>
  • Thread-index: Acz8S/dhICqr2ElidUu7VVL2oNtVUg==
  • Thread-topic: [Xen-devel] [PATCH] provide a single, common implementation for get_order_from_{bytes, pages}()

On 07/03/2012 09:56, "Jan Beulich" <JBeulich@xxxxxxxx> wrote:

> All three per-architecture implementations were identical, and I cannot
> see how future architectures would need any sort of customization here
> (the only per-architecture aspect here is the actual PAGE_SHIFT value).
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Acked-by: Keir Fraser <keir@xxxxxxx>

> --- a/xen/include/asm-arm/mm.h
> +++ b/xen/include/asm-arm/mm.h
> @@ -202,25 +202,6 @@ static inline paddr_t gvirt_to_maddr(uin
>  #define mfn_to_virt(mfn)  (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT))
>  
>  
> -static inline int get_order_from_bytes(paddr_t size)
> -{
> -    int order;
> -    size = (size-1) >> PAGE_SHIFT;
> -    for ( order = 0; size; order++ )
> -        size >>= 1;
> -    return order;
> -}
> -
> -static inline int get_order_from_pages(unsigned long nr_pages)
> -{
> -    int order;
> -    nr_pages--;
> -    for ( order = 0; nr_pages; order++ )
> -        nr_pages >>= 1;
> -    return order;
> -}
> -
> -
>  /* Convert between Xen-heap virtual addresses and page-info structures. */
>  static inline struct page_info *virt_to_page(const void *v)
>  {
> --- a/xen/include/asm-ia64/xenpage.h
> +++ b/xen/include/asm-ia64/xenpage.h
> @@ -60,24 +60,6 @@ typedef union xen_va {
> void *p;
>  } xen_va;
>  
> -static inline int get_order_from_bytes(paddr_t size)
> -{
> -    int order;
> -    size = (size-1) >> PAGE_SHIFT;
> -    for ( order = 0; size; order++ )
> -        size >>= 1;
> -    return order;
> -}
> -
> -static inline int get_order_from_pages(unsigned long nr_pages)
> -{
> -    int order;
> -    nr_pages--;
> -    for ( order = 0; nr_pages; order++ )
> -        nr_pages >>= 1;
> -    return order;
> -}
> -
>  static inline int get_order_from_shift(unsigned long shift)
>  {
>      if (shift <= PAGE_SHIFT)
> --- a/xen/include/asm-x86/page.h
> +++ b/xen/include/asm-x86/page.h
> @@ -354,24 +354,6 @@ void setup_idle_pagetable(void);
>  
>  #ifndef __ASSEMBLY__
>  
> -static inline int get_order_from_bytes(paddr_t size)
> -{
> -    int order;
> -    size = (size-1) >> PAGE_SHIFT;
> -    for ( order = 0; size; order++ )
> -        size >>= 1;
> -    return order;
> -}
> -
> -static inline int get_order_from_pages(unsigned long nr_pages)
> -{
> -    int order;
> -    nr_pages--;
> -    for ( order = 0; nr_pages; order++ )
> -        nr_pages >>= 1;
> -    return order;
> -}
> -
>  /* Allocator functions for Xen pagetables. */
>  void *alloc_xen_pagetable(void);
>  void free_xen_pagetable(void *v);
> --- a/xen/include/xen/mm.h
> +++ b/xen/include/xen/mm.h
> @@ -318,6 +318,28 @@ page_list_splice(struct page_list_head *
>  # define page_list_splice(list, hd)        list_splice(list, hd)
>  #endif
>  
> +static inline unsigned int get_order_from_bytes(paddr_t size)
> +{
> +    unsigned int order;
> +
> +    size = (size - 1) >> PAGE_SHIFT;
> +    for ( order = 0; size; order++ )
> +        size >>= 1;
> +
> +    return order;
> +}
> +
> +static inline unsigned int get_order_from_pages(unsigned long nr_pages)
> +{
> +    unsigned int order;
> +
> +    nr_pages--;
> +    for ( order = 0; nr_pages; order++ )
> +        nr_pages >>= 1;
> +
> +    return order;
> +}
> +
>  void scrub_one_page(struct page_info *);
>  
>  /* Returns 1 on success, 0 on error, negative if the ring
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> http://lists.xen.org/xen-devel



_______________________________________________
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®.