[IMPROVE] energy: add apps parameters in debugfs
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>
Mon, 30 Sep 2013 12:03:50 +0000 (16:03 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Mon, 30 Sep 2013 12:03:50 +0000 (16:03 +0400)
Change-Id: I535360b0d62d2a4b67d15f720c826b5f875b08bd
Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
energy/energy.c
us_manager/sspt/sspt_proc.c

index d0b711a..b5aed42 100644 (file)
@@ -389,22 +389,51 @@ static struct kretprobe sys_write_krp = {
 
 
 
-static u64 current_time_apps(void)
-{
-       /* TODO: implement */
-       return 0;
-}
+enum parameter_type {
+       PT_CPU,
+       PT_READ,
+       PT_WRITE
+};
 
-static u64 current_read_apps(void)
-{
-       /* TODO: implement */
-       return 0;
+struct cmd_pt {
+       enum parameter_type pt;
+       u64 val;
+};
+
+static void callback_for_proc(struct sspt_proc *proc, void *data)
+{
+       void *f_data = sspt_get_feature_data(proc->feature, feature_id);
+       struct energy_data *ed = (struct energy_data *)f_data;
+
+       if (ed) {
+               struct cmd_pt *cmdp = (struct cmd_pt *)data;
+
+               switch (cmdp->pt) {
+               case PT_CPU:
+                       cmdp->val += cpus_time_get_running_all(&ed->ct);
+                       break;
+               case PT_READ:
+                       cmdp->val += atomic64_read(&ed->bytes_read);
+                       break;
+               case PT_WRITE:
+                       cmdp->val += atomic64_read(&ed->bytes_written);
+                       break;
+               default:
+                       break;
+               }
+       }
 }
 
-static u64 current_write_apps(void)
+static u64 current_parameter_apps(enum parameter_type pt)
 {
-       /* TODO: implement */
-       return 0;
+       struct cmd_pt cmdp;
+
+       cmdp.pt = pt;
+       cmdp.val = 0;
+
+       on_each_proc(callback_for_proc, (void *)&cmdp);
+
+       return cmdp.val;
 }
 
 u64 get_parameter_energy(enum parameter_energy pe)
@@ -419,7 +448,7 @@ u64 get_parameter_energy(enum parameter_energy pe)
                val = cpus_time_get_running_all(&ed_system.ct);
                break;
        case PE_TIME_APPS:
-               val = current_time_apps();
+               val = current_parameter_apps(PT_CPU);
                break;
        case PE_READ_SYSTEM:
                val = atomic64_read(&ed_system.bytes_read);
@@ -428,10 +457,10 @@ u64 get_parameter_energy(enum parameter_energy pe)
                val = atomic64_read(&ed_system.bytes_written);
                break;
        case PE_READ_APPS:
-               val = current_read_apps();
+               val = current_parameter_apps(PT_READ);
                break;
        case PE_WRITE_APPS:
-               val = current_write_apps();
+               val = current_parameter_apps(PT_WRITE);
                break;
        default:
                break;
index fe08406..be4bd01 100644 (file)
@@ -125,6 +125,7 @@ void on_each_proc(void (*func)(struct sspt_proc *, void *), void *data)
        }
        spin_unlock(&proc_lock);
 }
+EXPORT_SYMBOL_GPL(on_each_proc);
 
 struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task,
                                               void *priv)