mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
mm/page_alloc: restrict max order of merging on isolated pageblock
Current pageblock isolation logic could isolate each pageblock individually. This causes freepage accounting problem if freepage with pageblock order on isolate pageblock is merged with other freepage on normal pageblock. We can prevent merging by restricting max order of merging to pageblock order if freepage is on isolate pageblock. A side-effect of this change is that there could be non-merged buddy freepage even if finishing pageblock isolation, because undoing pageblock isolation is just to move freepage from isolate buddy list to normal buddy list rather than to consider merging. So, the patch also makes undoing pageblock isolation consider freepage merge. When un-isolation, freepage with more than pageblock order and it's buddy are checked. If they are on normal pageblock, instead of just moving, we isolate the freepage and free it in order to get merged. Signed-off-by: Joonsoo Kim <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Yasuaki Ishimatsu <[email protected]> Cc: Zhang Yanfei <[email protected]> Cc: Tang Chen <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Bartlomiej Zolnierkiewicz <[email protected]> Cc: Wen Congyang <[email protected]> Cc: Marek Szyprowski <[email protected]> Cc: Michal Nazarewicz <[email protected]> Cc: Laura Abbott <[email protected]> Cc: Heesub Shin <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: Ritesh Harjani <[email protected]> Cc: Gioh Kim <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
8f82b55dd5
commit
3c605096d3
3 changed files with 78 additions and 29 deletions
|
|
@ -108,6 +108,31 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
|
|||
/*
|
||||
* in mm/page_alloc.c
|
||||
*/
|
||||
|
||||
/*
|
||||
* Locate the struct page for both the matching buddy in our
|
||||
* pair (buddy1) and the combined O(n+1) page they form (page).
|
||||
*
|
||||
* 1) Any buddy B1 will have an order O twin B2 which satisfies
|
||||
* the following equation:
|
||||
* B2 = B1 ^ (1 << O)
|
||||
* For example, if the starting buddy (buddy2) is #8 its order
|
||||
* 1 buddy is #10:
|
||||
* B2 = 8 ^ (1 << 1) = 8 ^ 2 = 10
|
||||
*
|
||||
* 2) Any buddy B will have an order O+1 parent P which
|
||||
* satisfies the following equation:
|
||||
* P = B & ~(1 << O)
|
||||
*
|
||||
* Assumption: *_mem_map is contiguous at least up to MAX_ORDER
|
||||
*/
|
||||
static inline unsigned long
|
||||
__find_buddy_index(unsigned long page_idx, unsigned int order)
|
||||
{
|
||||
return page_idx ^ (1 << order);
|
||||
}
|
||||
|
||||
extern int __isolate_free_page(struct page *page, unsigned int order);
|
||||
extern void __free_pages_bootmem(struct page *page, unsigned int order);
|
||||
extern void prep_compound_page(struct page *page, unsigned long order);
|
||||
#ifdef CONFIG_MEMORY_FAILURE
|
||||
|
|
|
|||
Loading…
Reference in a new issue