ANDROID: vendor_hooks: Add a hook for task tagging

Add a hook to tag task by its comm.
Easy way to identity a task by its tag.

Bug: 189352151
Signed-off-by: ted.lin <ted.lin@oneplus.com>
Change-Id: I32f2f7cec6643f4bd48312b9cffa770c902cebf3
This commit is contained in:
ted.lin
2021-05-26 22:00:14 +08:00
committed by Todd Kjos
parent 4968ab31d1
commit cadbca1c5e
3 changed files with 7 additions and 0 deletions

View File

@@ -297,3 +297,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_gpio_cd_irqt);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_vmalloc_stack); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_vmalloc_stack);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_stack_hash); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_stack_hash);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_track_hash); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_track_hash);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_task_comm);

View File

@@ -73,6 +73,7 @@
#include "internal.h" #include "internal.h"
#include <trace/events/sched.h> #include <trace/events/sched.h>
#include <trace/hooks/sched.h>
static int bprm_creds_from_file(struct linux_binprm *bprm); static int bprm_creds_from_file(struct linux_binprm *bprm);
@@ -1227,6 +1228,7 @@ void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec)
strlcpy(tsk->comm, buf, sizeof(tsk->comm)); strlcpy(tsk->comm, buf, sizeof(tsk->comm));
task_unlock(tsk); task_unlock(tsk);
perf_event_comm(tsk, exec); perf_event_comm(tsk, exec);
trace_android_vh_set_task_comm(tsk);
} }
/* /*

View File

@@ -362,6 +362,10 @@ DECLARE_HOOK(android_vh_dup_task_struct,
TP_PROTO(struct task_struct *tsk, struct task_struct *orig), TP_PROTO(struct task_struct *tsk, struct task_struct *orig),
TP_ARGS(tsk, orig)); TP_ARGS(tsk, orig));
DECLARE_HOOK(android_vh_set_task_comm,
TP_PROTO(struct task_struct *p),
TP_ARGS(p));
/* macro versions of hooks are no longer required */ /* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_SCHED_H */ #endif /* _TRACE_HOOK_SCHED_H */