mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
mm/page_alloc: simplify page_is_buddy() for better code readability
Simplify page_is_buddy() to reduce the redundant code for better code readability. Signed-off-by: chenqiwu <chenqiwu@xiaomi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Alexander Duyck <alexander.h.duyck@linux.intel.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com> Link: http://lkml.kernel.org/r/1583853751-5525-1-git-send-email-qiwuchen55@gmail.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
@@ -792,32 +792,25 @@ static inline void set_page_order(struct page *page, unsigned int order)
|
|||||||
*
|
*
|
||||||
* For recording page's order, we use page_private(page).
|
* For recording page's order, we use page_private(page).
|
||||||
*/
|
*/
|
||||||
static inline int page_is_buddy(struct page *page, struct page *buddy,
|
static inline bool page_is_buddy(struct page *page, struct page *buddy,
|
||||||
unsigned int order)
|
unsigned int order)
|
||||||
{
|
{
|
||||||
if (page_is_guard(buddy) && page_order(buddy) == order) {
|
if (!page_is_guard(buddy) && !PageBuddy(buddy))
|
||||||
if (page_zone_id(page) != page_zone_id(buddy))
|
return false;
|
||||||
return 0;
|
|
||||||
|
|
||||||
VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy);
|
if (page_order(buddy) != order)
|
||||||
|
return false;
|
||||||
|
|
||||||
return 1;
|
/*
|
||||||
}
|
* zone check is done late to avoid uselessly calculating
|
||||||
|
* zone/node ids for pages that could never merge.
|
||||||
|
*/
|
||||||
|
if (page_zone_id(page) != page_zone_id(buddy))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (PageBuddy(buddy) && page_order(buddy) == order) {
|
VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy);
|
||||||
/*
|
|
||||||
* zone check is done late to avoid uselessly
|
|
||||||
* calculating zone/node ids for pages that could
|
|
||||||
* never merge.
|
|
||||||
*/
|
|
||||||
if (page_zone_id(page) != page_zone_id(buddy))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
VM_BUG_ON_PAGE(page_count(buddy) != 0, buddy);
|
return true;
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_COMPACTION
|
#ifdef CONFIG_COMPACTION
|
||||||
|
Reference in New Issue
Block a user