mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-10-31 18:09:19 +00:00
sched: cpufreq: Adds a field cpu_power in the task_struct
cpu_power has been added to keep track of amount of power each task is consuming. cpu_power is updated whenever stime and utime are updated for a task. power is computed by taking into account the frequency at which the current core was running and the current for cpu actively running at hat frequency. Bug: 21498425 Change-Id: Ic535941e7b339aab5cae9081a34049daeb44b248 Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com> Git-commit: 94877641f6b6ea17aa335729f548eb5647db3e3e Git-repo: https://android.googlesource.com/kernel/msm/ Signed-off-by: Nirmal Abraham <nabrah@codeaurora.org> [clingutla@codeaurora.org:This fixes the undefined reference to acct_update_power() when building for ARCH=um in include/linux/cpufreq.h] Signed-off-by: Lingutla Chandrasekhar <clingutla@codeaurora.org> Signed-off-by: Avaneesh Kumar Dwivedi <akdwived@codeaurora.org>
This commit is contained in:
parent
ae586dc9cb
commit
9d329d4cf1
5 changed files with 39 additions and 0 deletions
|
@ -16,6 +16,7 @@
|
|||
#include <linux/sort.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/sched.h>
|
||||
#include <asm/cputime.h>
|
||||
|
||||
static spinlock_t cpufreq_stats_lock;
|
||||
|
@ -126,6 +127,25 @@ static int get_index_all_cpufreq_stat(struct all_cpufreq_stats *all_stat,
|
|||
return -1;
|
||||
}
|
||||
|
||||
void acct_update_power(struct task_struct *task, cputime_t cputime)
|
||||
{
|
||||
struct cpufreq_power_stats *powerstats;
|
||||
struct cpufreq_stats *stats;
|
||||
unsigned int cpu_num, curr;
|
||||
|
||||
if (!task)
|
||||
return;
|
||||
cpu_num = task_cpu(task);
|
||||
powerstats = per_cpu(cpufreq_power_stats, cpu_num);
|
||||
stats = per_cpu(cpufreq_stats_table, cpu_num);
|
||||
if (!powerstats || !stats)
|
||||
return;
|
||||
|
||||
curr = powerstats->curr[stats->last_index];
|
||||
task->cpu_power += curr * cputime_to_usecs(cputime);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(acct_update_power);
|
||||
|
||||
static ssize_t show_current_in_state(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <linux/kobject.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <asm/cputime.h>
|
||||
|
||||
/*********************************************************************
|
||||
* CPUFREQ INTERFACE *
|
||||
|
@ -483,4 +484,13 @@ static inline int cpufreq_generic_exit(struct cpufreq_policy *policy)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* CPUFREQ STATS *
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef CONFIG_CPU_FREQ_STAT
|
||||
void acct_update_power(struct task_struct *p, cputime_t cputime);
|
||||
#else
|
||||
static inline void acct_update_power(struct task_struct *p, cputime_t cputime) {}
|
||||
#endif
|
||||
#endif /* _LINUX_CPUFREQ_H */
|
||||
|
|
|
@ -1343,6 +1343,7 @@ struct task_struct {
|
|||
|
||||
cputime_t utime, stime, utimescaled, stimescaled;
|
||||
cputime_t gtime;
|
||||
unsigned long long cpu_power;
|
||||
#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
|
||||
struct cputime prev_cputime;
|
||||
#endif
|
||||
|
|
|
@ -1300,6 +1300,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
|
|||
|
||||
p->utime = p->stime = p->gtime = 0;
|
||||
p->utimescaled = p->stimescaled = 0;
|
||||
p->cpu_power = 0;
|
||||
#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
|
||||
p->prev_cputime.utime = p->prev_cputime.stime = 0;
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <linux/cpufreq.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/tsacct_kern.h>
|
||||
|
@ -158,6 +159,9 @@ void account_user_time(struct task_struct *p, cputime_t cputime,
|
|||
|
||||
/* Account for user time used */
|
||||
acct_account_cputime(p);
|
||||
|
||||
/* Account power usage for user time */
|
||||
acct_update_power(p, cputime);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -208,6 +212,9 @@ void __account_system_time(struct task_struct *p, cputime_t cputime,
|
|||
|
||||
/* Account for system time used */
|
||||
acct_account_cputime(p);
|
||||
|
||||
/* Account power usage for system time */
|
||||
acct_update_power(p, cputime);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue