ANDROID: uid_sys_stats: add ANDROID_OEM_DATA in struct uid_entry and update_stats_work
Add ANDROID_OEM_DATA to the struct uid_entry and update_stats_work, and add some vendor hooks to support recording OEM customized data at the uid level. Based on this, calculate and display customized data in the show_uid_stat process. Bug: 411259125 Change-Id: I1b0b993e2a4e2b6532b4209dddb2a3eeb7609c37 Signed-off-by: Bo Lan <lanbo@honor.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/spinlock_types.h>
|
||||
#include <linux/pm_qos.h>
|
||||
#include <trace/hooks/power.h>
|
||||
|
||||
#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);
|
||||
|
||||
|
||||
@@ -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 <trace/define_trace.h>
|
||||
|
||||
Reference in New Issue
Block a user