ANDROID: memcg: add vendor hook to use vm_swappiness

Add vendor hook to use system-wide vm_swappiness.
Refered to https://android-review.googlesource.com/c/kernel/common/+/2694466
to avoid build error issue with including include/trace/hooks/vmscan.h.

Bug: 351175506
Change-Id: Iba3b71ade27c7d23787d26b3753e49a21358f0e8
Signed-off-by: Sooyong Suk <s.suk@samsung.corp-partner.google.com>
This commit is contained in:
Sooyong Suk 2024-07-11 16:20:52 +09:00 committed by Treehugger Robot
parent cebdeae238
commit 89d387d916
4 changed files with 23 additions and 0 deletions

View File

@ -442,3 +442,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_debug_show_areas);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_contig_range_not_isolated);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_warn_alloc_tune_ratelimit);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_warn_alloc_show_mem_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_use_vm_swappiness);

View File

@ -637,8 +637,16 @@ static inline void swap_free(swp_entry_t entry)
}
#ifdef CONFIG_MEMCG
extern void _trace_android_vh_use_vm_swappiness(bool *use_vm_swappiness);
static inline int mem_cgroup_swappiness(struct mem_cgroup *memcg)
{
bool use_vm_swappiness = false;
_trace_android_vh_use_vm_swappiness(&use_vm_swappiness);
if (use_vm_swappiness)
return READ_ONCE(vm_swappiness);
/* Cgroup2 doesn't have per-cgroup swappiness */
if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
return READ_ONCE(vm_swappiness);

View File

@ -61,6 +61,9 @@ DECLARE_HOOK(android_vh_file_is_tiny_bypass,
DECLARE_HOOK(android_vh_rebalance_anon_lru_bypass,
TP_PROTO(bool *bypass),
TP_ARGS(bypass));
DECLARE_HOOK(android_vh_use_vm_swappiness,
TP_PROTO(bool *use_vm_swappiness),
TP_ARGS(use_vm_swappiness));
#endif /* _TRACE_HOOK_VMSCAN_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View File

@ -74,6 +74,7 @@
#include <trace/events/vmscan.h>
#include <trace/hooks/mm.h>
#include <trace/hooks/vmscan.h>
struct cgroup_subsys memory_cgrp_subsys __read_mostly;
EXPORT_SYMBOL(memory_cgrp_subsys);
@ -251,6 +252,16 @@ struct mem_cgroup *vmpressure_to_memcg(struct vmpressure *vmpr)
return container_of(vmpr, struct mem_cgroup, vmpressure);
}
/*
* trace_android_vh_use_vm_swappiness is called in include/linux/swap.h by
* including include/trace/hooks/vmscan.h, which will result to build-err.
* So we create func: _trace_android_vh_use_vm_swappiness.
*/
void _trace_android_vh_use_vm_swappiness(bool *use_vm_swappiness)
{
trace_android_vh_use_vm_swappiness(use_vm_swappiness);
}
#ifdef CONFIG_MEMCG_KMEM
static DEFINE_SPINLOCK(objcg_lock);