ANDROID: mm: Create vendor hooks to control ZONE_MOVABLE allocations

Create a vendor hook inside of gfp_zone() to modify which allocations
get to enter ZONE_MOVABLE, by zeroing out __GFP_HIGHMEM inside of the
trace hook based on certain conditions.

Separately, create separate trace hooks in the swap-in and readahead
paths to affect the behavior of the tracehook in gfp_zone().

Bug: 158645321
Change-Id: I4a4f0b724267ee120a1e5661f6da5d43d7ef6fc6
Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org>
This commit is contained in:
Chris Goldsworthy
2020-11-09 22:26:47 -08:00
parent 3d7ab504ec
commit 62e32cf8f3
7 changed files with 76 additions and 16 deletions

View File

@@ -9,6 +9,7 @@
#include <linux/stddef.h>
#include <linux/mm.h>
#include <linux/mmzone.h>
#include <trace/hooks/mm.h>
struct pglist_data *first_online_pgdat(void)
{
@@ -113,3 +114,19 @@ int page_cpupid_xchg_last(struct page *page, int cpupid)
return last_cpupid;
}
#endif
enum zone_type gfp_zone(gfp_t flags)
{
enum zone_type z;
gfp_t local_flags = flags;
int bit;
trace_android_rvh_set_gfp_zone_flags(&local_flags);
bit = (__force int) ((local_flags) & GFP_ZONEMASK);
z = (GFP_ZONE_TABLE >> (bit * GFP_ZONES_SHIFT)) &
((1 << GFP_ZONES_SHIFT) - 1);
VM_BUG_ON((GFP_ZONE_BAD >> bit) & 1);
return z;
}