cpuacct: Introduce cgroup_account_cputime[_field]()
Introduce cgroup_account_cputime[_field]() which wrap cpuacct_charge() and cgroup_account_field(). This doesn't introduce any functional changes and will be used to add cgroup basic resource accounting. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@redhat.com>
This commit is contained in:
parent
cfb766da54
commit
d2cc5ed694
|
@ -22,6 +22,7 @@
|
||||||
#include <linux/nsproxy.h>
|
#include <linux/nsproxy.h>
|
||||||
#include <linux/user_namespace.h>
|
#include <linux/user_namespace.h>
|
||||||
#include <linux/refcount.h>
|
#include <linux/refcount.h>
|
||||||
|
#include <linux/kernel_stat.h>
|
||||||
|
|
||||||
#include <linux/cgroup-defs.h>
|
#include <linux/cgroup-defs.h>
|
||||||
|
|
||||||
|
@ -688,6 +689,43 @@ static inline void cgroup_path_from_kernfs_id(const union kernfs_node_id *id,
|
||||||
char *buf, size_t buflen) {}
|
char *buf, size_t buflen) {}
|
||||||
#endif /* !CONFIG_CGROUPS */
|
#endif /* !CONFIG_CGROUPS */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Basic resource stats.
|
||||||
|
*/
|
||||||
|
#ifdef CONFIG_CGROUPS
|
||||||
|
|
||||||
|
#ifdef CONFIG_CGROUP_CPUACCT
|
||||||
|
void cpuacct_charge(struct task_struct *tsk, u64 cputime);
|
||||||
|
void cpuacct_account_field(struct task_struct *tsk, int index, u64 val);
|
||||||
|
#else
|
||||||
|
static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) {}
|
||||||
|
static inline void cpuacct_account_field(struct task_struct *tsk, int index,
|
||||||
|
u64 val) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline void cgroup_account_cputime(struct task_struct *task,
|
||||||
|
u64 delta_exec)
|
||||||
|
{
|
||||||
|
cpuacct_charge(task, delta_exec);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void cgroup_account_cputime_field(struct task_struct *task,
|
||||||
|
enum cpu_usage_stat index,
|
||||||
|
u64 delta_exec)
|
||||||
|
{
|
||||||
|
cpuacct_account_field(task, index, delta_exec);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* CONFIG_CGROUPS */
|
||||||
|
|
||||||
|
static inline void cgroup_account_cputime(struct task_struct *task,
|
||||||
|
u64 delta_exec) {}
|
||||||
|
static inline void cgroup_account_cputime_field(struct task_struct *task,
|
||||||
|
enum cpu_usage_stat index,
|
||||||
|
u64 delta_exec) {}
|
||||||
|
|
||||||
|
#endif /* CONFIG_CGROUPS */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sock->sk_cgrp_data handling. For more info, see sock_cgroup_data
|
* sock->sk_cgrp_data handling. For more info, see sock_cgroup_data
|
||||||
* definition in cgroup-defs.h.
|
* definition in cgroup-defs.h.
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
#ifdef CONFIG_CGROUP_CPUACCT
|
|
||||||
|
|
||||||
extern void cpuacct_charge(struct task_struct *tsk, u64 cputime);
|
|
||||||
extern void cpuacct_account_field(struct task_struct *tsk, int index, u64 val);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
cpuacct_account_field(struct task_struct *tsk, int index, u64 val)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -109,7 +109,7 @@ static inline void task_group_account_field(struct task_struct *p, int index,
|
||||||
*/
|
*/
|
||||||
__this_cpu_add(kernel_cpustat.cpustat[index], tmp);
|
__this_cpu_add(kernel_cpustat.cpustat[index], tmp);
|
||||||
|
|
||||||
cpuacct_account_field(p, index, tmp);
|
cgroup_account_cputime_field(p, index, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1143,7 +1143,7 @@ static void update_curr_dl(struct rq *rq)
|
||||||
account_group_exec_runtime(curr, delta_exec);
|
account_group_exec_runtime(curr, delta_exec);
|
||||||
|
|
||||||
curr->se.exec_start = rq_clock_task(rq);
|
curr->se.exec_start = rq_clock_task(rq);
|
||||||
cpuacct_charge(curr, delta_exec);
|
cgroup_account_cputime(curr, delta_exec);
|
||||||
|
|
||||||
sched_rt_avg_update(rq, delta_exec);
|
sched_rt_avg_update(rq, delta_exec);
|
||||||
|
|
||||||
|
|
|
@ -851,7 +851,7 @@ static void update_curr(struct cfs_rq *cfs_rq)
|
||||||
struct task_struct *curtask = task_of(curr);
|
struct task_struct *curtask = task_of(curr);
|
||||||
|
|
||||||
trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
|
trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
|
||||||
cpuacct_charge(curtask, delta_exec);
|
cgroup_account_cputime(curtask, delta_exec);
|
||||||
account_group_exec_runtime(curtask, delta_exec);
|
account_group_exec_runtime(curtask, delta_exec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -979,7 +979,7 @@ static void update_curr_rt(struct rq *rq)
|
||||||
account_group_exec_runtime(curr, delta_exec);
|
account_group_exec_runtime(curr, delta_exec);
|
||||||
|
|
||||||
curr->se.exec_start = rq_clock_task(rq);
|
curr->se.exec_start = rq_clock_task(rq);
|
||||||
cpuacct_charge(curr, delta_exec);
|
cgroup_account_cputime(curr, delta_exec);
|
||||||
|
|
||||||
sched_rt_avg_update(rq, delta_exec);
|
sched_rt_avg_update(rq, delta_exec);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <linux/irq_work.h>
|
#include <linux/irq_work.h>
|
||||||
#include <linux/tick.h>
|
#include <linux/tick.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/cgroup.h>
|
||||||
|
|
||||||
#ifdef CONFIG_PARAVIRT
|
#ifdef CONFIG_PARAVIRT
|
||||||
#include <asm/paravirt.h>
|
#include <asm/paravirt.h>
|
||||||
|
@ -36,7 +37,6 @@
|
||||||
|
|
||||||
#include "cpupri.h"
|
#include "cpupri.h"
|
||||||
#include "cpudeadline.h"
|
#include "cpudeadline.h"
|
||||||
#include "cpuacct.h"
|
|
||||||
|
|
||||||
#ifdef CONFIG_SCHED_DEBUG
|
#ifdef CONFIG_SCHED_DEBUG
|
||||||
# define SCHED_WARN_ON(x) WARN_ONCE(x, #x)
|
# define SCHED_WARN_ON(x) WARN_ONCE(x, #x)
|
||||||
|
|
|
@ -71,7 +71,7 @@ static void put_prev_task_stop(struct rq *rq, struct task_struct *prev)
|
||||||
account_group_exec_runtime(curr, delta_exec);
|
account_group_exec_runtime(curr, delta_exec);
|
||||||
|
|
||||||
curr->se.exec_start = rq_clock_task(rq);
|
curr->se.exec_start = rq_clock_task(rq);
|
||||||
cpuacct_charge(curr, delta_exec);
|
cgroup_account_cputime(curr, delta_exec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void task_tick_stop(struct rq *rq, struct task_struct *curr, int queued)
|
static void task_tick_stop(struct rq *rq, struct task_struct *curr, int queued)
|
||||||
|
|
Loading…
Reference in New Issue