mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
mm/page_alloc.c: use a single function to free page
[ Upstream commit 742aa7fb52
]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
257ad5fbfe
commit
9696c7656e
1 changed files with 14 additions and 23 deletions
|
@ -4451,16 +4451,19 @@ unsigned long get_zeroed_page(gfp_t gfp_mask)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(get_zeroed_page);
|
EXPORT_SYMBOL(get_zeroed_page);
|
||||||
|
|
||||||
void __free_pages(struct page *page, unsigned int order)
|
static inline void free_the_page(struct page *page, unsigned int order)
|
||||||
{
|
{
|
||||||
if (put_page_testzero(page)) {
|
if (order == 0) /* Via pcp? */
|
||||||
if (order == 0)
|
free_unref_page(page);
|
||||||
free_unref_page(page);
|
else
|
||||||
else
|
__free_pages_ok(page, order);
|
||||||
__free_pages_ok(page, order);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __free_pages(struct page *page, unsigned int order)
|
||||||
|
{
|
||||||
|
if (put_page_testzero(page))
|
||||||
|
free_the_page(page, order);
|
||||||
|
}
|
||||||
EXPORT_SYMBOL(__free_pages);
|
EXPORT_SYMBOL(__free_pages);
|
||||||
|
|
||||||
void free_pages(unsigned long addr, unsigned int order)
|
void free_pages(unsigned long addr, unsigned int order)
|
||||||
|
@ -4509,14 +4512,8 @@ void __page_frag_cache_drain(struct page *page, unsigned int count)
|
||||||
{
|
{
|
||||||
VM_BUG_ON_PAGE(page_ref_count(page) == 0, page);
|
VM_BUG_ON_PAGE(page_ref_count(page) == 0, page);
|
||||||
|
|
||||||
if (page_ref_sub_and_test(page, count)) {
|
if (page_ref_sub_and_test(page, count))
|
||||||
unsigned int order = compound_order(page);
|
free_the_page(page, compound_order(page));
|
||||||
|
|
||||||
if (order == 0)
|
|
||||||
free_unref_page(page);
|
|
||||||
else
|
|
||||||
__free_pages_ok(page, order);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__page_frag_cache_drain);
|
EXPORT_SYMBOL(__page_frag_cache_drain);
|
||||||
|
|
||||||
|
@ -4581,14 +4578,8 @@ void page_frag_free(void *addr)
|
||||||
{
|
{
|
||||||
struct page *page = virt_to_head_page(addr);
|
struct page *page = virt_to_head_page(addr);
|
||||||
|
|
||||||
if (unlikely(put_page_testzero(page))) {
|
if (unlikely(put_page_testzero(page)))
|
||||||
unsigned int order = compound_order(page);
|
free_the_page(page, compound_order(page));
|
||||||
|
|
||||||
if (order == 0) /* Via pcp? */
|
|
||||||
free_unref_page(page);
|
|
||||||
else
|
|
||||||
__free_pages_ok(page, order);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(page_frag_free);
|
EXPORT_SYMBOL(page_frag_free);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue