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:
parent
3d7ab504ec
commit
62e32cf8f3
@ -25,6 +25,7 @@
|
||||
#include <trace/hooks/gic_v3.h>
|
||||
#include <trace/hooks/epoch.h>
|
||||
#include <trace/hooks/cpufreq.h>
|
||||
#include <trace/hooks/mm.h>
|
||||
|
||||
/*
|
||||
* Export tracepoints that act as a bare tracehook (ie: have no trace event
|
||||
@ -86,3 +87,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_iowait);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_sugov_update);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_setaffinity);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_cpus_allowed);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_skip_swapcache_flags);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_gfp_zone_flags);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_readahead_gfp_mask);
|
||||
|
@ -462,16 +462,7 @@ static inline bool gfpflags_normal_context(const gfp_t gfp_flags)
|
||||
| 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM) \
|
||||
)
|
||||
|
||||
static inline enum zone_type gfp_zone(gfp_t flags)
|
||||
{
|
||||
enum zone_type z;
|
||||
int bit = (__force int) (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;
|
||||
}
|
||||
enum zone_type gfp_zone(gfp_t flags);
|
||||
|
||||
/*
|
||||
* There is only one page-allocator function, and two main namespaces to
|
||||
|
@ -296,10 +296,7 @@ static inline struct page *page_cache_alloc(struct address_space *x)
|
||||
return __page_cache_alloc(mapping_gfp_mask(x));
|
||||
}
|
||||
|
||||
static inline gfp_t readahead_gfp_mask(struct address_space *x)
|
||||
{
|
||||
return mapping_gfp_mask(x) | __GFP_NORETRY | __GFP_NOWARN;
|
||||
}
|
||||
gfp_t readahead_gfp_mask(struct address_space *x);
|
||||
|
||||
typedef int filler_t(void *, struct page *);
|
||||
|
||||
|
38
include/trace/hooks/mm.h
Normal file
38
include/trace/hooks/mm.h
Normal file
@ -0,0 +1,38 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM mm
|
||||
|
||||
#define TRACE_INCLUDE_PATH trace/hooks
|
||||
|
||||
#if !defined(_TRACE_HOOK_MM_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define _TRACE_HOOK_MM_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <linux/tracepoint.h>
|
||||
#include <trace/hooks/vendor_hooks.h>
|
||||
|
||||
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
|
||||
|
||||
DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags,
|
||||
TP_PROTO(gfp_t *flags),
|
||||
TP_ARGS(flags), 1);
|
||||
DECLARE_RESTRICTED_HOOK(android_rvh_set_gfp_zone_flags,
|
||||
TP_PROTO(gfp_t *flags),
|
||||
TP_ARGS(flags), 1);
|
||||
DECLARE_RESTRICTED_HOOK(android_rvh_set_readahead_gfp_mask,
|
||||
TP_PROTO(gfp_t *flags),
|
||||
TP_ARGS(flags), 1);
|
||||
|
||||
#else
|
||||
|
||||
#define trace_android_rvh_set_skip_swapcache_flags(gfp_flags)
|
||||
#define trace_android_rvh_set_gfp_zone_flags(gfp_flags)
|
||||
#define trace_android_rvh_set_readahead_gfp_mask(gfp_flags)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _TRACE_HOOK_MM_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
@ -73,6 +73,7 @@
|
||||
#include <linux/perf_event.h>
|
||||
#include <linux/ptrace.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <trace/hooks/mm.h>
|
||||
|
||||
#include <trace/events/kmem.h>
|
||||
|
||||
@ -3293,8 +3294,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
|
||||
if (data_race(si->flags & SWP_SYNCHRONOUS_IO) &&
|
||||
__swap_count(entry) == 1) {
|
||||
/* skip swapcache */
|
||||
page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma,
|
||||
vmf->address);
|
||||
gfp_t flags = GFP_HIGHUSER_MOVABLE;
|
||||
|
||||
trace_android_rvh_set_skip_swapcache_flags(&flags);
|
||||
page = alloc_page_vma(flags, vma, vmf->address);
|
||||
if (page) {
|
||||
int err;
|
||||
|
||||
|
17
mm/mmzone.c
17
mm/mmzone.c
@ -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;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <linux/blk-cgroup.h>
|
||||
#include <linux/fadvise.h>
|
||||
#include <linux/sched/mm.h>
|
||||
#include <trace/hooks/mm.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@ -114,6 +115,15 @@ int read_cache_pages(struct address_space *mapping, struct list_head *pages,
|
||||
|
||||
EXPORT_SYMBOL(read_cache_pages);
|
||||
|
||||
gfp_t readahead_gfp_mask(struct address_space *x)
|
||||
{
|
||||
gfp_t mask = mapping_gfp_mask(x) | __GFP_NORETRY | __GFP_NOWARN;
|
||||
|
||||
trace_android_rvh_set_readahead_gfp_mask(&mask);
|
||||
return mask;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(readahead_gfp_mask);
|
||||
|
||||
static void read_pages(struct readahead_control *rac, struct list_head *pages,
|
||||
bool skip_page)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user