diff options
author | Jan Beulich <jbeulich@suse.com> | 2012-03-07 11:50:31 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2012-03-07 11:50:31 +0100 |
commit | 5fb0f4f5d87bb72a76ca55b96a8b4ce1a0810f8c (patch) | |
tree | 875ca5be9806a5d3f82598a92a78213ebaba793e /xen/include/xen/mm.h | |
parent | e45066d3c3fff98ed502546bd3152541eab16b07 (diff) | |
download | xen-5fb0f4f5d87bb72a76ca55b96a8b4ce1a0810f8c.tar.gz xen-5fb0f4f5d87bb72a76ca55b96a8b4ce1a0810f8c.tar.bz2 xen-5fb0f4f5d87bb72a76ca55b96a8b4ce1a0810f8c.zip |
provide a single, common implementation for get_order_from_{bytes,pages}()
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@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/include/xen/mm.h')
-rw-r--r-- | xen/include/xen/mm.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 94e7d42a8e..11381a1303 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -318,6 +318,28 @@ page_list_splice(struct page_list_head *list, struct page_list_head *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 |