Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit b910ce6

Browse files
yipeng xiangTreehugger Robot
authored andcommitted
ANDROID: vendor_hooks: add hooks for f2fs issue checkpoint
Add hooks to solve the priority inversion. while the key thread needs to update fs data, it should wake and wait for f2fs checkpoint thread to complete the work. So one scheme is needed to ensure the priority of checkpoint thread especially in CPU high load scenarios. Bug: 375088532 Change-Id: Iaa181cd1c8368310d9dd4c78adda6c7add5858b3 Signed-off-by: yipeng xiang <[email protected]>
1 parent 08deb99 commit b910ce6

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

drivers/android/vendor_hooks.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_swapmem_gather_init);
442442
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_swapmem_gather_finish);
443443
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_f2fs_file_open);
444444
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_f2fs_down_read);
445+
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_f2fs_improve_priority);
446+
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_f2fs_restore_priority);
445447
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_uplink_send_msg);
446448
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_inet_create);
447449
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sock_create);

fs/f2fs/checkpoint.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,10 +1903,18 @@ int f2fs_issue_checkpoint(struct f2fs_sb_info *sbi)
19031903
if (waitqueue_active(&cprc->ckpt_wait_queue))
19041904
wake_up(&cprc->ckpt_wait_queue);
19051905

1906-
if (cprc->f2fs_issue_ckpt)
1906+
if (cprc->f2fs_issue_ckpt) {
1907+
bool prio_changed = false;
1908+
int saved_prio;
1909+
1910+
trace_android_vh_f2fs_improve_priority(cprc->f2fs_issue_ckpt, &saved_prio,
1911+
&prio_changed);
19071912
wait_for_completion(&req.wait);
1908-
else
1913+
if (prio_changed)
1914+
trace_android_vh_f2fs_restore_priority(cprc->f2fs_issue_ckpt, saved_prio);
1915+
} else {
19091916
flush_remained_ckpt_reqs(sbi, &req);
1917+
}
19101918

19111919
return req.ret;
19121920
}

include/trace/hooks/fs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ DECLARE_RESTRICTED_HOOK(android_rvh_f2fs_down_read,
2020
TP_PROTO(wait_queue_head_t *read_waiters, struct rw_semaphore *rwsem, bool *skip),
2121
TP_ARGS(read_waiters, rwsem, skip), 1);
2222

23+
DECLARE_HOOK(android_vh_f2fs_improve_priority,
24+
TP_PROTO(struct task_struct *p, int *saved_prio, bool *skip),
25+
TP_ARGS(p, saved_prio, skip));
26+
27+
DECLARE_HOOK(android_vh_f2fs_restore_priority,
28+
TP_PROTO(struct task_struct *p, int saved_prio),
29+
TP_ARGS(p, saved_prio));
30+
2331
#endif /* _TRACE_HOOK_FS_H */
2432

2533
/* This part must be outside protection */

0 commit comments

Comments
 (0)