History

mm: introduce page_size()

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).

Matthew Wilcox (Oracle) committed 7 years ago

Commit a50b8541 parent 1f18b2917 files · +35 −38Browse files

Showing the changes to include/linux (2 of 17 files). Show all

Unified · Split

2 files
  1. include/linux/hugetlb.h +1 −1
  2. include/linux/mm.h +6 −0
include/linux/hugetlb.h+1−1
@@ -454,7 +454,7 @@ static inline pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma, · 453 unmodified lines
454static inline struct hstate *page_hstate(struct page *page)454static inline struct hstate *page_hstate(struct page *page)
455{455{
456 VM_BUG_ON_PAGE(!PageHuge(page), page);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
460static inline unsigned hstate_index_to_shift(unsigned index)460static inline unsigned hstate_index_to_shift(unsigned index)
include/linux/mm.h+6−0
@@ -805,6 +805,12 @@ static inline void set_compound_order(struct page *page, unsigned int order) · 804 unmodified lines
805 page[1].compound_order = order;805 page[1].compound_order = order;
806}806}
807 807
808/* Returns the number of bytes in this potentially compound page. */
809static inline unsigned long page_size(struct page *page)
810{
811 return PAGE_SIZE << compound_order(page);
812}
813
808void free_compound_page(struct page *page);814void free_compound_page(struct page *page);
809 815
810#ifdef CONFIG_MMU816#ifdef CONFIG_MMU

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t