diff options
author | Matthew Wilcox <mawilcox@microsoft.com> | 2018-06-07 20:08:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-07 20:34:37 -0400 |
commit | 6e292b9be7f4358985ce33ae1f59ab30a8c09e08 (patch) | |
tree | 857ddd791e19272b368e673bb192577a6c5d3e9c /mm/page_alloc.c | |
parent | 620b4e903179d58342503fa09d9c680d93bf7db8 (diff) |
mm: split page_type out from _mapcount
We're already using a union of many fields here, so stop abusing the
_mapcount and make page_type its own field. That implies renaming some of
the machinery that creates PageBuddy, PageBalloon and PageKmemcg; bring
back the PG_buddy, PG_balloon and PG_kmemcg names.
As suggested by Kirill, make page_type a bitmask. Because it starts out
life as -1 (thanks to sharing the storage with _mapcount), setting a page
flag means clearing the appropriate bit. This gives us space for probably
twenty or so extra bits (depending how paranoid we want to be about
_mapcount underflow).
Link: http://lkml.kernel.org/r/20180518194519.3820-3-willy@infradead.org
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Christoph Lameter <cl@linux.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.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.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 96d48d24e1ef..5afdf495c374 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -705,16 +705,14 @@ static inline void rmv_page_order(struct page *page) | |||
705 | 705 | ||
706 | /* | 706 | /* |
707 | * This function checks whether a page is free && is the buddy | 707 | * This function checks whether a page is free && is the buddy |
708 | * we can do coalesce a page and its buddy if | 708 | * we can coalesce a page and its buddy if |
709 | * (a) the buddy is not in a hole (check before calling!) && | 709 | * (a) the buddy is not in a hole (check before calling!) && |
710 | * (b) the buddy is in the buddy system && | 710 | * (b) the buddy is in the buddy system && |
711 | * (c) a page and its buddy have the same order && | 711 | * (c) a page and its buddy have the same order && |
712 | * (d) a page and its buddy are in the same zone. | 712 | * (d) a page and its buddy are in the same zone. |
713 | * | 713 | * |
714 | * For recording whether a page is in the buddy system, we set ->_mapcount | 714 | * For recording whether a page is in the buddy system, we set PageBuddy. |
715 | * PAGE_BUDDY_MAPCOUNT_VALUE. | 715 | * Setting, clearing, and testing PageBuddy is serialized by zone->lock. |
716 | * Setting, clearing, and testing _mapcount PAGE_BUDDY_MAPCOUNT_VALUE is | ||
717 | * serialized by zone->lock. | ||
718 | * | 716 | * |
719 | * For recording page's order, we use page_private(page). | 717 | * For recording page's order, we use page_private(page). |
720 | */ | 718 | */ |
@@ -759,9 +757,8 @@ static inline int page_is_buddy(struct page *page, struct page *buddy, | |||
759 | * as necessary, plus some accounting needed to play nicely with other | 757 | * as necessary, plus some accounting needed to play nicely with other |
760 | * parts of the VM system. | 758 | * parts of the VM system. |
761 | * At each level, we keep a list of pages, which are heads of continuous | 759 | * At each level, we keep a list of pages, which are heads of continuous |
762 | * free pages of length of (1 << order) and marked with _mapcount | 760 | * free pages of length of (1 << order) and marked with PageBuddy. |
763 | * PAGE_BUDDY_MAPCOUNT_VALUE. Page's order is recorded in page_private(page) | 761 | * Page's order is recorded in page_private(page) field. |
764 | * field. | ||
765 | * So when we are allocating or freeing one, we can derive the state of the | 762 | * So when we are allocating or freeing one, we can derive the state of the |
766 | * other. That is, if we allocate a small block, and both were | 763 | * other. That is, if we allocate a small block, and both were |
767 | * free, the remainder of the region must be split into blocks. | 764 | * free, the remainder of the region must be split into blocks. |