aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorAaron Lu <aaron.lu@intel.com>2018-12-28 03:35:22 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-28 15:11:48 -0500
commit742aa7fb52c56fb3b307e704f93e67b698959cc2 (patch)
tree4a5fe6c5984f2cb38b6543f60a1d6cd00d8a53fc /mm/page_alloc.c
parent65895b67ad27df0f62bfaf82dd5622f95ea29196 (diff)
mm/page_alloc.c: use a single function to free page
There are multiple places of freeing a page, they all do the same things so a common function can be used to reduce code duplicate. It also avoids bug fixed in one function but left in another. Link: http://lkml.kernel.org/r/20181119134834.17765-3-aaron.lu@intel.com Signed-off-by: Aaron Lu <aaron.lu@intel.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Jesper Dangaard Brouer <brouer@redhat.com> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Pankaj gupta <pagupta@redhat.com> Cc: Pawel Staszewski <pstaszewski@itcare.pl> Cc: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f0617cf88706..298b449a03c7 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4427,16 +4427,19 @@ unsigned long get_zeroed_page(gfp_t gfp_mask)
4427} 4427}
4428EXPORT_SYMBOL(get_zeroed_page); 4428EXPORT_SYMBOL(get_zeroed_page);
4429 4429
4430void __free_pages(struct page *page, unsigned int order) 4430static inline void free_the_page(struct page *page, unsigned int order)
4431{ 4431{
4432 if (put_page_testzero(page)) { 4432 if (order == 0) /* Via pcp? */
4433 if (order == 0) 4433 free_unref_page(page);
4434 free_unref_page(page); 4434 else
4435 else 4435 __free_pages_ok(page, order);
4436 __free_pages_ok(page, order);
4437 }
4438} 4436}
4439 4437
4438void __free_pages(struct page *page, unsigned int order)
4439{
4440 if (put_page_testzero(page))
4441 free_the_page(page, order);
4442}
4440EXPORT_SYMBOL(__free_pages); 4443EXPORT_SYMBOL(__free_pages);
4441 4444
4442void free_pages(unsigned long addr, unsigned int order) 4445void free_pages(unsigned long addr, unsigned int order)
@@ -4485,14 +4488,8 @@ void __page_frag_cache_drain(struct page *page, unsigned int count)
4485{ 4488{
4486 VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); 4489 VM_BUG_ON_PAGE(page_ref_count(page) == 0, page);
4487 4490
4488 if (page_ref_sub_and_test(page, count)) { 4491 if (page_ref_sub_and_test(page, count))
4489 unsigned int order = compound_order(page); 4492 free_the_page(page, compound_order(page));
4490
4491 if (order == 0)
4492 free_unref_page(page);
4493 else
4494 __free_pages_ok(page, order);
4495 }
4496} 4493}
4497EXPORT_SYMBOL(__page_frag_cache_drain); 4494EXPORT_SYMBOL(__page_frag_cache_drain);
4498 4495
@@ -4557,14 +4554,8 @@ void page_frag_free(void *addr)
4557{ 4554{
4558 struct page *page = virt_to_head_page(addr); 4555 struct page *page = virt_to_head_page(addr);
4559 4556
4560 if (unlikely(put_page_testzero(page))) { 4557 if (unlikely(put_page_testzero(page)))
4561 unsigned int order = compound_order(page); 4558 free_the_page(page, compound_order(page));
4562
4563 if (order == 0) /* Via pcp? */
4564 free_unref_page(page);
4565 else
4566 __free_pages_ok(page, order);
4567 }
4568} 4559}
4569EXPORT_SYMBOL(page_frag_free); 4560EXPORT_SYMBOL(page_frag_free);
4570 4561