提交 9acacc2a 编写于 作者: Z Zhao Lei 提交者: Ingo Molnar

sched/cpuacct: Merge cpuacct_usage_index and cpuacct_stat_index enums

These two types have similar function, no need to separate them.
Signed-off-by: NZhao Lei <zhaolei@cn.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/436748885270d64363c7dc67167507d486c2057a.1466415271.git.zhaolei@cn.fujitsu.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 55e16d30
...@@ -25,15 +25,13 @@ enum cpuacct_stat_index { ...@@ -25,15 +25,13 @@ enum cpuacct_stat_index {
CPUACCT_STAT_NSTATS, CPUACCT_STAT_NSTATS,
}; };
enum cpuacct_usage_index { static const char * const cpuacct_stat_desc[] = {
CPUACCT_USAGE_USER, /* ... user mode */ [CPUACCT_STAT_USER] = "user",
CPUACCT_USAGE_SYSTEM, /* ... kernel mode */ [CPUACCT_STAT_SYSTEM] = "system",
CPUACCT_USAGE_NRUSAGE,
}; };
struct cpuacct_usage { struct cpuacct_usage {
u64 usages[CPUACCT_USAGE_NRUSAGE]; u64 usages[CPUACCT_STAT_NSTATS];
}; };
/* track cpu usage of a group of tasks and its child groups */ /* track cpu usage of a group of tasks and its child groups */
...@@ -108,16 +106,16 @@ static void cpuacct_css_free(struct cgroup_subsys_state *css) ...@@ -108,16 +106,16 @@ static void cpuacct_css_free(struct cgroup_subsys_state *css)
} }
static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu, static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu,
enum cpuacct_usage_index index) enum cpuacct_stat_index index)
{ {
struct cpuacct_usage *cpuusage = per_cpu_ptr(ca->cpuusage, cpu); struct cpuacct_usage *cpuusage = per_cpu_ptr(ca->cpuusage, cpu);
u64 data; u64 data;
/* /*
* We allow index == CPUACCT_USAGE_NRUSAGE here to read * We allow index == CPUACCT_STAT_NSTATS here to read
* the sum of suages. * the sum of suages.
*/ */
BUG_ON(index > CPUACCT_USAGE_NRUSAGE); BUG_ON(index > CPUACCT_STAT_NSTATS);
#ifndef CONFIG_64BIT #ifndef CONFIG_64BIT
/* /*
...@@ -126,11 +124,11 @@ static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu, ...@@ -126,11 +124,11 @@ static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu,
raw_spin_lock_irq(&cpu_rq(cpu)->lock); raw_spin_lock_irq(&cpu_rq(cpu)->lock);
#endif #endif
if (index == CPUACCT_USAGE_NRUSAGE) { if (index == CPUACCT_STAT_NSTATS) {
int i = 0; int i = 0;
data = 0; data = 0;
for (i = 0; i < CPUACCT_USAGE_NRUSAGE; i++) for (i = 0; i < CPUACCT_STAT_NSTATS; i++)
data += cpuusage->usages[i]; data += cpuusage->usages[i];
} else { } else {
data = cpuusage->usages[index]; data = cpuusage->usages[index];
...@@ -155,7 +153,7 @@ static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val) ...@@ -155,7 +153,7 @@ static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val)
raw_spin_lock_irq(&cpu_rq(cpu)->lock); raw_spin_lock_irq(&cpu_rq(cpu)->lock);
#endif #endif
for (i = 0; i < CPUACCT_USAGE_NRUSAGE; i++) for (i = 0; i < CPUACCT_STAT_NSTATS; i++)
cpuusage->usages[i] = val; cpuusage->usages[i] = val;
#ifndef CONFIG_64BIT #ifndef CONFIG_64BIT
...@@ -165,7 +163,7 @@ static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val) ...@@ -165,7 +163,7 @@ static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val)
/* return total cpu usage (in nanoseconds) of a group */ /* return total cpu usage (in nanoseconds) of a group */
static u64 __cpuusage_read(struct cgroup_subsys_state *css, static u64 __cpuusage_read(struct cgroup_subsys_state *css,
enum cpuacct_usage_index index) enum cpuacct_stat_index index)
{ {
struct cpuacct *ca = css_ca(css); struct cpuacct *ca = css_ca(css);
u64 totalcpuusage = 0; u64 totalcpuusage = 0;
...@@ -180,18 +178,18 @@ static u64 __cpuusage_read(struct cgroup_subsys_state *css, ...@@ -180,18 +178,18 @@ static u64 __cpuusage_read(struct cgroup_subsys_state *css,
static u64 cpuusage_user_read(struct cgroup_subsys_state *css, static u64 cpuusage_user_read(struct cgroup_subsys_state *css,
struct cftype *cft) struct cftype *cft)
{ {
return __cpuusage_read(css, CPUACCT_USAGE_USER); return __cpuusage_read(css, CPUACCT_STAT_USER);
} }
static u64 cpuusage_sys_read(struct cgroup_subsys_state *css, static u64 cpuusage_sys_read(struct cgroup_subsys_state *css,
struct cftype *cft) struct cftype *cft)
{ {
return __cpuusage_read(css, CPUACCT_USAGE_SYSTEM); return __cpuusage_read(css, CPUACCT_STAT_SYSTEM);
} }
static u64 cpuusage_read(struct cgroup_subsys_state *css, struct cftype *cft) static u64 cpuusage_read(struct cgroup_subsys_state *css, struct cftype *cft)
{ {
return __cpuusage_read(css, CPUACCT_USAGE_NRUSAGE); return __cpuusage_read(css, CPUACCT_STAT_NSTATS);
} }
static int cpuusage_write(struct cgroup_subsys_state *css, struct cftype *cft, static int cpuusage_write(struct cgroup_subsys_state *css, struct cftype *cft,
...@@ -213,7 +211,7 @@ static int cpuusage_write(struct cgroup_subsys_state *css, struct cftype *cft, ...@@ -213,7 +211,7 @@ static int cpuusage_write(struct cgroup_subsys_state *css, struct cftype *cft,
} }
static int __cpuacct_percpu_seq_show(struct seq_file *m, static int __cpuacct_percpu_seq_show(struct seq_file *m,
enum cpuacct_usage_index index) enum cpuacct_stat_index index)
{ {
struct cpuacct *ca = css_ca(seq_css(m)); struct cpuacct *ca = css_ca(seq_css(m));
u64 percpu; u64 percpu;
...@@ -229,24 +227,19 @@ static int __cpuacct_percpu_seq_show(struct seq_file *m, ...@@ -229,24 +227,19 @@ static int __cpuacct_percpu_seq_show(struct seq_file *m,
static int cpuacct_percpu_user_seq_show(struct seq_file *m, void *V) static int cpuacct_percpu_user_seq_show(struct seq_file *m, void *V)
{ {
return __cpuacct_percpu_seq_show(m, CPUACCT_USAGE_USER); return __cpuacct_percpu_seq_show(m, CPUACCT_STAT_USER);
} }
static int cpuacct_percpu_sys_seq_show(struct seq_file *m, void *V) static int cpuacct_percpu_sys_seq_show(struct seq_file *m, void *V)
{ {
return __cpuacct_percpu_seq_show(m, CPUACCT_USAGE_SYSTEM); return __cpuacct_percpu_seq_show(m, CPUACCT_STAT_SYSTEM);
} }
static int cpuacct_percpu_seq_show(struct seq_file *m, void *V) static int cpuacct_percpu_seq_show(struct seq_file *m, void *V)
{ {
return __cpuacct_percpu_seq_show(m, CPUACCT_USAGE_NRUSAGE); return __cpuacct_percpu_seq_show(m, CPUACCT_STAT_NSTATS);
} }
static const char * const cpuacct_stat_desc[] = {
[CPUACCT_STAT_USER] = "user",
[CPUACCT_STAT_SYSTEM] = "system",
};
static int cpuacct_stats_show(struct seq_file *sf, void *v) static int cpuacct_stats_show(struct seq_file *sf, void *v)
{ {
struct cpuacct *ca = css_ca(seq_css(sf)); struct cpuacct *ca = css_ca(seq_css(sf));
...@@ -316,11 +309,11 @@ static struct cftype files[] = { ...@@ -316,11 +309,11 @@ static struct cftype files[] = {
void cpuacct_charge(struct task_struct *tsk, u64 cputime) void cpuacct_charge(struct task_struct *tsk, u64 cputime)
{ {
struct cpuacct *ca; struct cpuacct *ca;
int index = CPUACCT_USAGE_SYSTEM; int index = CPUACCT_STAT_SYSTEM;
struct pt_regs *regs = task_pt_regs(tsk); struct pt_regs *regs = task_pt_regs(tsk);
if (regs && user_mode(regs)) if (regs && user_mode(regs))
index = CPUACCT_USAGE_USER; index = CPUACCT_STAT_USER;
rcu_read_lock(); rcu_read_lock();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册