|
@@ -443,7 +443,6 @@ struct pacct_struct {
|
|
* @utime: time spent in user mode, in &cputime_t units
|
|
* @utime: time spent in user mode, in &cputime_t units
|
|
* @stime: time spent in kernel mode, in &cputime_t units
|
|
* @stime: time spent in kernel mode, in &cputime_t units
|
|
* @sum_exec_runtime: total time spent on the CPU, in nanoseconds
|
|
* @sum_exec_runtime: total time spent on the CPU, in nanoseconds
|
|
- * @lock: lock for fields in this struct
|
|
|
|
*
|
|
*
|
|
* This structure groups together three kinds of CPU time that are
|
|
* This structure groups together three kinds of CPU time that are
|
|
* tracked for threads and thread groups. Most things considering
|
|
* tracked for threads and thread groups. Most things considering
|
|
@@ -454,23 +453,33 @@ struct task_cputime {
|
|
cputime_t utime;
|
|
cputime_t utime;
|
|
cputime_t stime;
|
|
cputime_t stime;
|
|
unsigned long long sum_exec_runtime;
|
|
unsigned long long sum_exec_runtime;
|
|
- spinlock_t lock;
|
|
|
|
};
|
|
};
|
|
/* Alternate field names when used to cache expirations. */
|
|
/* Alternate field names when used to cache expirations. */
|
|
#define prof_exp stime
|
|
#define prof_exp stime
|
|
#define virt_exp utime
|
|
#define virt_exp utime
|
|
#define sched_exp sum_exec_runtime
|
|
#define sched_exp sum_exec_runtime
|
|
|
|
|
|
|
|
+#define INIT_CPUTIME \
|
|
|
|
+ (struct task_cputime) { \
|
|
|
|
+ .utime = cputime_zero, \
|
|
|
|
+ .stime = cputime_zero, \
|
|
|
|
+ .sum_exec_runtime = 0, \
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * struct thread_group_cputime - thread group interval timer counts
|
|
|
|
- * @totals: thread group interval timers; substructure for
|
|
|
|
- * uniprocessor kernel, per-cpu for SMP kernel.
|
|
|
|
|
|
+ * struct thread_group_cputimer - thread group interval timer counts
|
|
|
|
+ * @cputime: thread group interval timers.
|
|
|
|
+ * @running: non-zero when there are timers running and
|
|
|
|
+ * @cputime receives updates.
|
|
|
|
+ * @lock: lock for fields in this struct.
|
|
*
|
|
*
|
|
* This structure contains the version of task_cputime, above, that is
|
|
* This structure contains the version of task_cputime, above, that is
|
|
- * used for thread group CPU clock calculations.
|
|
|
|
|
|
+ * used for thread group CPU timer calculations.
|
|
*/
|
|
*/
|
|
-struct thread_group_cputime {
|
|
|
|
- struct task_cputime totals;
|
|
|
|
|
|
+struct thread_group_cputimer {
|
|
|
|
+ struct task_cputime cputime;
|
|
|
|
+ int running;
|
|
|
|
+ spinlock_t lock;
|
|
};
|
|
};
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -519,10 +528,10 @@ struct signal_struct {
|
|
cputime_t it_prof_incr, it_virt_incr;
|
|
cputime_t it_prof_incr, it_virt_incr;
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Thread group totals for process CPU clocks.
|
|
|
|
- * See thread_group_cputime(), et al, for details.
|
|
|
|
|
|
+ * Thread group totals for process CPU timers.
|
|
|
|
+ * See thread_group_cputimer(), et al, for details.
|
|
*/
|
|
*/
|
|
- struct thread_group_cputime cputime;
|
|
|
|
|
|
+ struct thread_group_cputimer cputimer;
|
|
|
|
|
|
/* Earliest-expiration cache. */
|
|
/* Earliest-expiration cache. */
|
|
struct task_cputime cputime_expires;
|
|
struct task_cputime cputime_expires;
|
|
@@ -559,7 +568,7 @@ struct signal_struct {
|
|
* Live threads maintain their own counters and add to these
|
|
* Live threads maintain their own counters and add to these
|
|
* in __exit_signal, except for the group leader.
|
|
* in __exit_signal, except for the group leader.
|
|
*/
|
|
*/
|
|
- cputime_t cutime, cstime;
|
|
|
|
|
|
+ cputime_t utime, stime, cutime, cstime;
|
|
cputime_t gtime;
|
|
cputime_t gtime;
|
|
cputime_t cgtime;
|
|
cputime_t cgtime;
|
|
unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
|
|
unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
|
|
@@ -567,6 +576,14 @@ struct signal_struct {
|
|
unsigned long inblock, oublock, cinblock, coublock;
|
|
unsigned long inblock, oublock, cinblock, coublock;
|
|
struct task_io_accounting ioac;
|
|
struct task_io_accounting ioac;
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Cumulative ns of schedule CPU time fo dead threads in the
|
|
|
|
+ * group, not including a zombie group leader, (This only differs
|
|
|
|
+ * from jiffies_to_ns(utime + stime) if sched_clock uses something
|
|
|
|
+ * other than jiffies.)
|
|
|
|
+ */
|
|
|
|
+ unsigned long long sum_sched_runtime;
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* We don't bother to synchronize most readers of this at all,
|
|
* We don't bother to synchronize most readers of this at all,
|
|
* because there is no reader checking a limit that actually needs
|
|
* because there is no reader checking a limit that actually needs
|
|
@@ -2183,27 +2200,24 @@ static inline int spin_needbreak(spinlock_t *lock)
|
|
/*
|
|
/*
|
|
* Thread group CPU time accounting.
|
|
* Thread group CPU time accounting.
|
|
*/
|
|
*/
|
|
|
|
+void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
|
|
|
|
|
|
static inline
|
|
static inline
|
|
-void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
|
|
|
|
|
|
+void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
|
|
{
|
|
{
|
|
- struct task_cputime *totals = &tsk->signal->cputime.totals;
|
|
|
|
|
|
+ struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
|
|
|
|
- spin_lock_irqsave(&totals->lock, flags);
|
|
|
|
- *times = *totals;
|
|
|
|
- spin_unlock_irqrestore(&totals->lock, flags);
|
|
|
|
|
|
+ spin_lock_irqsave(&cputimer->lock, flags);
|
|
|
|
+ *times = cputimer->cputime;
|
|
|
|
+ spin_unlock_irqrestore(&cputimer->lock, flags);
|
|
}
|
|
}
|
|
|
|
|
|
static inline void thread_group_cputime_init(struct signal_struct *sig)
|
|
static inline void thread_group_cputime_init(struct signal_struct *sig)
|
|
{
|
|
{
|
|
- sig->cputime.totals = (struct task_cputime){
|
|
|
|
- .utime = cputime_zero,
|
|
|
|
- .stime = cputime_zero,
|
|
|
|
- .sum_exec_runtime = 0,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- spin_lock_init(&sig->cputime.totals.lock);
|
|
|
|
|
|
+ sig->cputimer.cputime = INIT_CPUTIME;
|
|
|
|
+ spin_lock_init(&sig->cputimer.lock);
|
|
|
|
+ sig->cputimer.running = 0;
|
|
}
|
|
}
|
|
|
|
|
|
static inline void thread_group_cputime_free(struct signal_struct *sig)
|
|
static inline void thread_group_cputime_free(struct signal_struct *sig)
|