Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a50b854e authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Linus Torvalds
Browse files

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

Link: http://lkml.kernel.org/r/20190721104612.19120-2-willy@infradead.org


Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1f18b296
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -204,8 +204,7 @@ void __flush_dcache_page(struct address_space *mapping, struct page *page)
	 * coherent with the kernels mapping.
	 */
	if (!PageHighMem(page)) {
		size_t page_size = PAGE_SIZE << compound_order(page);
		__cpuc_flush_dcache_area(page_address(page), page_size);
		__cpuc_flush_dcache_area(page_address(page), page_size(page));
	} else {
		unsigned long i;
		if (cache_is_vipt_nonaliasing()) {
+1 −2
Original line number Diff line number Diff line
@@ -56,8 +56,7 @@ void __sync_icache_dcache(pte_t pte)
	struct page *page = pte_page(pte);

	if (!test_and_set_bit(PG_dcache_clean, &page->flags))
		sync_icache_aliases(page_address(page),
				    PAGE_SIZE << compound_order(page));
		sync_icache_aliases(page_address(page), page_size(page));
}
EXPORT_SYMBOL_GPL(__sync_icache_dcache);

+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ __ia64_sync_icache_dcache (pte_t pte)
	if (test_bit(PG_arch_1, &page->flags))
		return;				/* i-cache is already coherent with d-cache */

	flush_icache_range(addr, addr + (PAGE_SIZE << compound_order(page)));
	flush_icache_range(addr, addr + page_size(page));
	set_bit(PG_arch_1, &page->flags);	/* mark page as clean */
}

+2 −3
Original line number Diff line number Diff line
@@ -1078,7 +1078,7 @@ int chtls_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
			bool merge;

			if (page)
				pg_size <<= compound_order(page);
				pg_size = page_size(page);
			if (off < pg_size &&
			    skb_can_coalesce(skb, i, page, off)) {
				merge = 1;
@@ -1105,8 +1105,7 @@ int chtls_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
							   __GFP_NORETRY,
							   order);
					if (page)
						pg_size <<=
							compound_order(page);
						pg_size <<= order;
				}
				if (!page) {
					page = alloc_page(gfp);
+2 −2
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
		if (!page)
			goto free_pages;
		list_add_tail(&page->lru, &pages);
		size_remaining -= PAGE_SIZE << compound_order(page);
		size_remaining -= page_size(page);
		max_order = compound_order(page);
		i++;
	}
@@ -133,7 +133,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap,

	sg = table->sgl;
	list_for_each_entry_safe(page, tmp_page, &pages, lru) {
		sg_set_page(sg, page, PAGE_SIZE << compound_order(page), 0);
		sg_set_page(sg, page, page_size(page), 0);
		sg = sg_next(sg);
		list_del(&page->lru);
	}
Loading