ANDROID: vendor_hook: Add hooks in free_swap_slot()

Provide a vendor hook to replace the function free_swap_slot,
adding the free_swap_slot process of pages swapped to the
specified swap location(i.e., the reserved expended memory)

Bug: 234214858
Signed-off-by: Bing Han <bing.han@transsion.com>
Change-Id: Idd6d0007e64d56d556d1234a8b931fce06031809
This commit is contained in:
Bing Han
2022-06-10 18:45:31 +08:00
committed by Treehugger Robot
parent d2fea0ba9a
commit 7222a0b29b
3 changed files with 8 additions and 0 deletions

View File

@@ -416,6 +416,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_referenced_one_end);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_count_pswpin);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_count_pswpout);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_count_swpout_vm_event);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_swap_slot);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_isolated_for_reclaim);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_inactive_is_low);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_snapshot_refaults);

View File

@@ -176,6 +176,9 @@ DECLARE_HOOK(android_vh_count_pswpout,
DECLARE_HOOK(android_vh_count_swpout_vm_event,
TP_PROTO(struct swap_info_struct *sis, struct page *page, bool *skip),
TP_ARGS(sis, page, skip));
DECLARE_HOOK(android_vh_free_swap_slot,
TP_PROTO(swp_entry_t entry, struct swap_slots_cache *cache, bool *skip),
TP_ARGS(entry, cache, skip));
DECLARE_HOOK(android_vh_page_isolated_for_reclaim,
TP_PROTO(struct mm_struct *mm, struct page *page),
TP_ARGS(mm, page));

View File

@@ -274,8 +274,12 @@ static int refill_swap_slots_cache(struct swap_slots_cache *cache)
int free_swap_slot(swp_entry_t entry)
{
struct swap_slots_cache *cache;
bool skip = false;
cache = raw_cpu_ptr(&swp_slots);
trace_android_vh_free_swap_slot(entry, cache, &skip);
if (skip)
return 0;
if (likely(use_swap_slot_cache && cache->slots_ret)) {
spin_lock_irq(&cache->free_lock);
/* Swap slots cache may be deactivated before acquiring lock */