diff options
author | Johannes Weiner <[email protected]> | 2023-09-11 14:11:08 -0400 |
---|---|---|
committer | Andrew Morton <[email protected]> | 2023-09-19 13:21:32 -0700 |
commit | 7b086755fb8cdbb6b3e45a1bbddc00e7f9b1dc03 (patch) | |
tree | fdada2bdf6ed4b8f49ade8416b780c22aad3a451 /include/linux | |
parent | e72590fa56b73b99885b17c74017b6cd4355bf66 (diff) |
mm: page_alloc: fix CMA and HIGHATOMIC landing on the wrong buddy list
Commit 4b23a68f9536 ("mm/page_alloc: protect PCP lists with a spinlock")
bypasses the pcplist on lock contention and returns the page directly to
the buddy list of the page's migratetype.
For pages that don't have their own pcplist, such as CMA and HIGHATOMIC,
the migratetype is temporarily updated such that the page can hitch a ride
on the MOVABLE pcplist. Their true type is later reassessed when flushing
in free_pcppages_bulk(). However, when lock contention is detected after
the type was already overridden, the bypass will then put the page on the
wrong buddy list.
Once on the MOVABLE buddy list, the page becomes eligible for fallbacks
and even stealing. In the case of HIGHATOMIC, otherwise ineligible
allocations can dip into the highatomic reserves. In the case of CMA, the
page can be lost from the CMA region permanently.
Use a separate pcpmigratetype variable for the pcplist override. Use the
original migratetype when going directly to the buddy. This fixes the bug
and should make the intentions more obvious in the code.
Originally sent here to address the HIGHATOMIC case:
https://lore.kernel.org/lkml/[email protected]/
Changelog updated in response to the CMA-specific bug report.
[[email protected]: updated changelog]
Link: https://lkml.kernel.org/r/[email protected]
Fixes: 4b23a68f9536 ("mm/page_alloc: protect PCP lists with a spinlock")
Signed-off-by: Johannes Weiner <[email protected]>
Reported-by: Joe Liu <[email protected]>
Reviewed-by: Vlastimil Babka <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions