ANDROID: mm: Create hooks for ZONE_MOVABLE allocs
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 a trace hook in the readahead path to affect the behavior of the tracehook in gfp_zone(). In 5.15, we had set_skip_swapcache_flags trace-hook in do_swap_page() but commit ac26e9c7b809 ("ANDROID: cma: allow to use CMA in swap-in path") added __GFP_CMA explicitly, so the set_skip_swapcache_flags trace hook is no longer needed. Note: To comply with vendor hook guidlines, avoid including types.h in trace/hooks/mm.h and use unsigned int for gfp_t. Bug: 158645321 Change-Id: Idfa6b0b06b1b819d706c847e702bc94ddf7aa55a Signed-off-by: Chris Goldsworthy <cgoldswo@codeaurora.org> Signed-off-by: Sukadev Bhattiprolu <quic_sukadev@quicinc.com>
This commit is contained in:
parent
31f15608bb
commit
342be123fd
@ -3509,6 +3509,8 @@
|
|||||||
__traceiter_android_rvh_select_task_rq_rt
|
__traceiter_android_rvh_select_task_rq_rt
|
||||||
__traceiter_android_rvh_set_balance_anon_file_reclaim
|
__traceiter_android_rvh_set_balance_anon_file_reclaim
|
||||||
__traceiter_android_rvh_set_cpus_allowed_by_task
|
__traceiter_android_rvh_set_cpus_allowed_by_task
|
||||||
|
__traceiter_android_rvh_set_gfp_zone_flags
|
||||||
|
__traceiter_android_rvh_set_readahead_gfp_mask
|
||||||
__traceiter_android_rvh_setscheduler
|
__traceiter_android_rvh_setscheduler
|
||||||
__traceiter_android_rvh_set_task_cpu
|
__traceiter_android_rvh_set_task_cpu
|
||||||
__traceiter_android_rvh_set_user_nice
|
__traceiter_android_rvh_set_user_nice
|
||||||
@ -3639,6 +3641,8 @@
|
|||||||
__tracepoint_android_rvh_select_task_rq_rt
|
__tracepoint_android_rvh_select_task_rq_rt
|
||||||
__tracepoint_android_rvh_set_balance_anon_file_reclaim
|
__tracepoint_android_rvh_set_balance_anon_file_reclaim
|
||||||
__tracepoint_android_rvh_set_cpus_allowed_by_task
|
__tracepoint_android_rvh_set_cpus_allowed_by_task
|
||||||
|
__tracepoint_android_rvh_set_gfp_zone_flags
|
||||||
|
__tracepoint_android_rvh_set_readahead_gfp_mask
|
||||||
__tracepoint_android_rvh_setscheduler
|
__tracepoint_android_rvh_setscheduler
|
||||||
__tracepoint_android_rvh_set_task_cpu
|
__tracepoint_android_rvh_set_task_cpu
|
||||||
__tracepoint_android_rvh_set_user_nice
|
__tracepoint_android_rvh_set_user_nice
|
||||||
|
@ -187,3 +187,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_store_partner_src_caps);
|
|||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_get_timer);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_get_timer);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_modify_src_caps);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_modify_src_caps);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_log);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_log);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_gfp_zone_flags);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_readahead_gfp_mask);
|
||||||
|
@ -123,7 +123,7 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
|
|||||||
| 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM) \
|
| 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM) \
|
||||||
)
|
)
|
||||||
|
|
||||||
static inline enum zone_type gfp_zone(gfp_t flags)
|
static inline enum zone_type __gfp_zone(gfp_t flags)
|
||||||
{
|
{
|
||||||
enum zone_type z;
|
enum zone_type z;
|
||||||
int bit = (__force int) (flags & GFP_ZONEMASK);
|
int bit = (__force int) (flags & GFP_ZONEMASK);
|
||||||
@ -134,6 +134,8 @@ static inline enum zone_type gfp_zone(gfp_t flags)
|
|||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum zone_type gfp_zone(gfp_t flags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There is only one page-allocator function, and two main namespaces to
|
* There is only one page-allocator function, and two main namespaces to
|
||||||
* it. The alloc_page*() variants return 'struct page *' and as such
|
* it. The alloc_page*() variants return 'struct page *' and as such
|
||||||
|
@ -485,11 +485,13 @@ static inline struct page *page_cache_alloc(struct address_space *x)
|
|||||||
return __page_cache_alloc(mapping_gfp_mask(x));
|
return __page_cache_alloc(mapping_gfp_mask(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline gfp_t readahead_gfp_mask(struct address_space *x)
|
static inline gfp_t __readahead_gfp_mask(struct address_space *x)
|
||||||
{
|
{
|
||||||
return mapping_gfp_mask(x) | __GFP_NORETRY | __GFP_NOWARN;
|
return mapping_gfp_mask(x) | __GFP_NORETRY | __GFP_NOWARN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfp_t readahead_gfp_mask(struct address_space *x);
|
||||||
|
|
||||||
typedef int filler_t(struct file *, struct folio *);
|
typedef int filler_t(struct file *, struct folio *);
|
||||||
|
|
||||||
pgoff_t page_cache_next_miss(struct address_space *mapping,
|
pgoff_t page_cache_next_miss(struct address_space *mapping,
|
||||||
|
@ -16,19 +16,14 @@ DECLARE_RESTRICTED_HOOK(android_rvh_shmem_get_folio,
|
|||||||
TP_PROTO(struct shmem_inode_info *info, struct folio **folio),
|
TP_PROTO(struct shmem_inode_info *info, struct folio **folio),
|
||||||
TP_ARGS(info, folio), 2);
|
TP_ARGS(info, folio), 2);
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
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,
|
DECLARE_RESTRICTED_HOOK(android_rvh_set_gfp_zone_flags,
|
||||||
TP_PROTO(gfp_t *flags),
|
TP_PROTO(unsigned int *flags), /* gfp_t *flags */
|
||||||
TP_ARGS(flags), 1);
|
TP_ARGS(flags), 1);
|
||||||
DECLARE_RESTRICTED_HOOK(android_rvh_set_readahead_gfp_mask,
|
|
||||||
TP_PROTO(gfp_t *flags),
|
DECLARE_RESTRICTED_HOOK(android_rvh_set_readahead_gfp_mask,
|
||||||
|
TP_PROTO(unsigned int *flags), /* gfp_t *flags */
|
||||||
TP_ARGS(flags), 1);
|
TP_ARGS(flags), 1);
|
||||||
|
|
||||||
*/
|
|
||||||
#endif /* _TRACE_HOOK_MM_H */
|
#endif /* _TRACE_HOOK_MM_H */
|
||||||
|
|
||||||
/* This part must be outside protection */
|
/* This part must be outside protection */
|
||||||
|
@ -3802,8 +3802,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
|
|||||||
if (data_race(si->flags & SWP_SYNCHRONOUS_IO) &&
|
if (data_race(si->flags & SWP_SYNCHRONOUS_IO) &&
|
||||||
__swap_count(entry) == 1) {
|
__swap_count(entry) == 1) {
|
||||||
/* skip swapcache */
|
/* skip swapcache */
|
||||||
folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0,
|
folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE|__GFP_CMA,
|
||||||
vma, vmf->address, false);
|
0, vma, vmf->address, false);
|
||||||
page = &folio->page;
|
page = &folio->page;
|
||||||
if (folio) {
|
if (folio) {
|
||||||
__folio_set_locked(folio);
|
__folio_set_locked(folio);
|
||||||
@ -3829,7 +3829,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
|
|||||||
folio->private = NULL;
|
folio->private = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE,
|
page = swapin_readahead(entry,
|
||||||
|
GFP_HIGHUSER_MOVABLE|__GFP_CMA,
|
||||||
vmf);
|
vmf);
|
||||||
if (page)
|
if (page)
|
||||||
folio = page_folio(page);
|
folio = page_folio(page);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <linux/stddef.h>
|
#include <linux/stddef.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/mmzone.h>
|
#include <linux/mmzone.h>
|
||||||
|
#include <trace/hooks/mm.h>
|
||||||
|
|
||||||
struct pglist_data *first_online_pgdat(void)
|
struct pglist_data *first_online_pgdat(void)
|
||||||
{
|
{
|
||||||
@ -110,3 +111,10 @@ int page_cpupid_xchg_last(struct page *page, int cpupid)
|
|||||||
return last_cpupid;
|
return last_cpupid;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum zone_type gfp_zone(gfp_t flags)
|
||||||
|
{
|
||||||
|
trace_android_rvh_set_gfp_zone_flags(&flags);
|
||||||
|
|
||||||
|
return __gfp_zone(flags);
|
||||||
|
}
|
||||||
|
@ -129,6 +129,7 @@
|
|||||||
#include <linux/blk-cgroup.h>
|
#include <linux/blk-cgroup.h>
|
||||||
#include <linux/fadvise.h>
|
#include <linux/fadvise.h>
|
||||||
#include <linux/sched/mm.h>
|
#include <linux/sched/mm.h>
|
||||||
|
#include <trace/hooks/mm.h>
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
@ -144,6 +145,15 @@ file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(file_ra_state_init);
|
EXPORT_SYMBOL_GPL(file_ra_state_init);
|
||||||
|
|
||||||
|
gfp_t readahead_gfp_mask(struct address_space *x)
|
||||||
|
{
|
||||||
|
gfp_t mask = __readahead_gfp_mask(x);
|
||||||
|
|
||||||
|
trace_android_rvh_set_readahead_gfp_mask(&mask);
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(readahead_gfp_mask);
|
||||||
|
|
||||||
static void read_pages(struct readahead_control *rac)
|
static void read_pages(struct readahead_control *rac)
|
||||||
{
|
{
|
||||||
const struct address_space_operations *aops = rac->mapping->a_ops;
|
const struct address_space_operations *aops = rac->mapping->a_ops;
|
||||||
|
Loading…
Reference in New Issue
Block a user