Patch series "Make working with compound pages easier", v2. These three patches add three helpers and convert the appropriate places to use them. This patch (of 3): It's unnecessarily hard to find out the size of a potentially huge page. Replace 'PAGE_SIZE << compound_order(page)' with page_size(page).
Showing the changes to include/linux (2 of 17 files). Show all
Unified · Split
| @@ -454,7 +454,7 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma, · 453 unmodified lines | ||
| 454 | 454 | static inline struct hstate *page_hstate(struct page *page) |
| 455 | 455 | { |
| 456 | 456 | VM_BUG_ON_PAGE(!PageHuge(page), page); |
| 457 | − return size_to_hstate(PAGE_SIZE << compound_order(page)); | |
| 457 | + return size_to_hstate(page_size(page)); | |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | static inline unsigned hstate_index_to_shift(unsigned index) |
| @@ -805,6 +805,12 @@ static inline void set_compound_order(struct page *page, unsigned int order) · 804 unmodified lines | ||
| 805 | 805 | page[1].compound_order = order; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | +/* Returns the number of bytes in this potentially compound page. */ | |
| 809 | +static inline unsigned long page_size(struct page *page) | |
| 810 | +{ | |
| 811 | + return PAGE_SIZE << compound_order(page); | |
| 812 | +} | |
| 813 | + | |
| 808 | 814 | void free_compound_page(struct page *page); |
| 809 | 815 | |
| 810 | 816 | #ifdef CONFIG_MMU |