ANDROID: vendor_hooks: Add vendor hooks in __swap_writepage
Add hook in __swap_writepage for reclaim synchronous or asynchronous in different scenarios. Bug: 363882594 Change-Id: I06604454fa3019850a499912f6def97525960c0f Signed-off-by: Jiewen Wang <jiewen.wang@vivo.com>
This commit is contained in:
committed by
Treehugger Robot
parent
7669d436d7
commit
8f5f6798e1
@@ -550,3 +550,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_wp_page);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_swap_page);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_anonymous_page);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_uprobes_replace_page);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_swap_writepage);
|
||||
|
||||
@@ -513,6 +513,9 @@ DECLARE_HOOK(android_vh_uprobes_replace_page,
|
||||
DECLARE_HOOK(android_vh_shmem_swapin_folio,
|
||||
TP_PROTO(struct folio *folio),
|
||||
TP_ARGS(folio));
|
||||
DECLARE_HOOK(android_vh_swap_writepage,
|
||||
TP_PROTO(unsigned long *sis_flags, struct page *page),
|
||||
TP_ARGS(sis_flags, page));
|
||||
#endif /* _TRACE_HOOK_MM_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
||||
10
mm/page_io.c
10
mm/page_io.c
@@ -27,6 +27,9 @@
|
||||
#include <linux/zswap.h>
|
||||
#include "swap.h"
|
||||
|
||||
#undef CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/mm.h>
|
||||
|
||||
static void __end_swap_bio_write(struct bio *bio)
|
||||
{
|
||||
struct folio *folio = bio_first_folio_all(bio);
|
||||
@@ -452,6 +455,7 @@ static void swap_writepage_bdev_async(struct folio *folio,
|
||||
void __swap_writepage(struct folio *folio, struct writeback_control *wbc)
|
||||
{
|
||||
struct swap_info_struct *sis = swp_swap_info(folio->swap);
|
||||
unsigned long sis_flags = 0;
|
||||
|
||||
VM_BUG_ON_FOLIO(!folio_test_swapcache(folio), folio);
|
||||
/*
|
||||
@@ -459,14 +463,16 @@ void __swap_writepage(struct folio *folio, struct writeback_control *wbc)
|
||||
* but that will never affect SWP_FS_OPS, so the data_race
|
||||
* is safe.
|
||||
*/
|
||||
if (data_race(sis->flags & SWP_FS_OPS))
|
||||
sis_flags = data_race(sis->flags);
|
||||
trace_android_vh_swap_writepage(&sis_flags, &folio->page);
|
||||
if (sis_flags & SWP_FS_OPS)
|
||||
swap_writepage_fs(folio, wbc);
|
||||
/*
|
||||
* ->flags can be updated non-atomicially (scan_swap_map_slots),
|
||||
* but that will never affect __SWP_WRITE_SYNCHRONOUS_IO, so the data_race
|
||||
* is safe.
|
||||
*/
|
||||
else if (data_race(sis->flags & __SWP_WRITE_SYNCHRONOUS_IO))
|
||||
else if (sis_flags & __SWP_WRITE_SYNCHRONOUS_IO)
|
||||
swap_writepage_bdev_sync(folio, wbc, sis);
|
||||
else
|
||||
swap_writepage_bdev_async(folio, wbc, sis);
|
||||
|
||||
Reference in New Issue
Block a user