diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 6a472b0c3ecb..8e8138b8b90e 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -484,6 +484,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_read_fault); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_alloc_pages_reclaim_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_alloc_pages_reclaim_cycle_end); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_throttle_direct_reclaim_bypass); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_update_uid_stats); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_append_total_power); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_bd_link_disk_holder); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_new_ref); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_del_ref); diff --git a/drivers/misc/uid_sys_stats.c b/drivers/misc/uid_sys_stats.c index bcc14a069225..f65cb6597793 100644 --- a/drivers/misc/uid_sys_stats.c +++ b/drivers/misc/uid_sys_stats.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #define UID_HASH_BITS 10 #define UID_HASH_NUMS (1 << UID_HASH_BITS) @@ -46,6 +48,15 @@ spinlock_t uid_lock[UID_HASH_NUMS]; hlist_for_each_entry_safe(uid_entry, tmp,\ &hash_table[bkt], hash) +#define UPDATE_ANDROID_OEM_DATA(target, source, task, type) \ + trace_android_vh_update_uid_stats(target, source, task, type) + +#ifdef CONFIG_ANDROID_VENDOR_OEM_DATA +#define OEM_DATA(x) x->android_oem_data1 +#else +#define OEM_DATA(x) 0 +#endif + static struct proc_dir_entry *cpu_parent; static struct proc_dir_entry *io_parent; static struct proc_dir_entry *proc_parent; @@ -80,6 +91,8 @@ struct uid_entry { int state; struct io_stats io[UID_STATE_SIZE]; struct hlist_node hash; + + ANDROID_OEM_DATA(1); }; static void init_hash_table_and_lock(void) @@ -193,7 +206,7 @@ static struct uid_entry *find_or_register_uid(uid_t uid) } static void calc_uid_cputime(struct uid_entry *uid_entry, - u64 *total_utime, u64 *total_stime) + u64 *total_utime, u64 *total_stime, u64 *android_oem_data) { struct user_namespace *user_ns = current_user_ns(); struct task_struct *p, *t; @@ -210,6 +223,7 @@ static void calc_uid_cputime(struct uid_entry *uid_entry, for_each_thread(p, t) { /* avoid double accounting of dying threads */ if (!(t->flags & PF_EXITING)) { + UPDATE_ANDROID_OEM_DATA(android_oem_data, NULL, t, 3); task_cputime_adjusted(t, &utime, &stime); *total_utime += utime; *total_stime += stime; @@ -229,10 +243,14 @@ static int uid_cputime_show(struct seq_file *m, void *v) for_each_uid_entry(uid_entry, bkt) { u64 total_utime = uid_entry->utime; u64 total_stime = uid_entry->stime; + u64 android_oem_data = OEM_DATA(uid_entry); - calc_uid_cputime(uid_entry, &total_utime, &total_stime); + calc_uid_cputime(uid_entry, &total_utime, + &total_stime, &android_oem_data); seq_printf(m, "%d: %llu %llu\n", uid_entry->uid, ktime_to_us(total_utime), ktime_to_us(total_stime)); + trace_android_vh_append_total_power(m, uid_entry->uid, + total_utime, total_stime, android_oem_data); } unlock_uid_by_bkt(bkt); } @@ -465,6 +483,8 @@ struct update_stats_work { u64 utime; u64 stime; struct llist_node node; + + ANDROID_OEM_DATA(1); }; static LLIST_HEAD(work_usw); @@ -485,6 +505,8 @@ static void update_stats_workfn(struct work_struct *work) uid_entry->utime += usw->utime; uid_entry->stime += usw->stime; + UPDATE_ANDROID_OEM_DATA(&OEM_DATA(uid_entry), + &OEM_DATA(usw), NULL, 0); __add_uid_io_stats(uid_entry, &usw->ioac, UID_STATE_DEAD_TASKS); next: @@ -519,6 +541,10 @@ static int process_notifier(struct notifier_block *self, */ usw->ioac = task->ioac; task_cputime_adjusted(task, &usw->utime, &usw->stime); +#ifdef CONFIG_ANDROID_VENDOR_OEM_DATA + usw->android_oem_data1 = 0; +#endif + UPDATE_ANDROID_OEM_DATA(NULL, &OEM_DATA(usw), task, 1); llist_add(&usw->node, &work_usw); schedule_work(&update_stats_work); } @@ -534,6 +560,7 @@ static int process_notifier(struct notifier_block *self, task_cputime_adjusted(task, &utime, &stime); uid_entry->utime += utime; uid_entry->stime += stime; + UPDATE_ANDROID_OEM_DATA(&OEM_DATA(uid_entry), NULL, task, 2); add_uid_io_stats(uid_entry, task, UID_STATE_DEAD_TASKS); diff --git a/include/trace/hooks/power.h b/include/trace/hooks/power.h index e845d0ef6025..5721b3ddf611 100644 --- a/include/trace/hooks/power.h +++ b/include/trace/hooks/power.h @@ -33,6 +33,18 @@ DECLARE_HOOK(android_vh_freq_qos_remove_request, TP_PROTO(struct freq_qos_request *req), TP_ARGS(req)); +struct task_struct; +struct seq_file; +DECLARE_HOOK(android_vh_update_uid_stats, + TP_PROTO(u64 *combine_data, u64 *usw_data, + struct task_struct *task, int type), + TP_ARGS(combine_data, usw_data, task, type)); + +DECLARE_HOOK(android_vh_append_total_power, + TP_PROTO(struct seq_file *m, uid_t uid, u64 total_utime, + u64 total_stime, u64 total_power), + TP_ARGS(m, uid, total_utime, total_stime, total_power)); + #endif /* _TRACE_HOOK_POWER_H */ /* This part must be outside protection */ #include