diff options
Diffstat (limited to 'kernel/tsacct.c')
-rw-r--r-- | kernel/tsacct.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/kernel/tsacct.c b/kernel/tsacct.c index 625df0b44690..a1dd9a1b1327 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c | |||
@@ -32,6 +32,7 @@ void bacct_add_tsk(struct user_namespace *user_ns, | |||
32 | { | 32 | { |
33 | const struct cred *tcred; | 33 | const struct cred *tcred; |
34 | struct timespec uptime, ts; | 34 | struct timespec uptime, ts; |
35 | cputime_t utime, stime, utimescaled, stimescaled; | ||
35 | u64 ac_etime; | 36 | u64 ac_etime; |
36 | 37 | ||
37 | BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN); | 38 | BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN); |
@@ -65,10 +66,15 @@ void bacct_add_tsk(struct user_namespace *user_ns, | |||
65 | stats->ac_ppid = pid_alive(tsk) ? | 66 | stats->ac_ppid = pid_alive(tsk) ? |
66 | task_tgid_nr_ns(rcu_dereference(tsk->real_parent), pid_ns) : 0; | 67 | task_tgid_nr_ns(rcu_dereference(tsk->real_parent), pid_ns) : 0; |
67 | rcu_read_unlock(); | 68 | rcu_read_unlock(); |
68 | stats->ac_utime = cputime_to_usecs(tsk->utime); | 69 | |
69 | stats->ac_stime = cputime_to_usecs(tsk->stime); | 70 | task_cputime(tsk, &utime, &stime); |
70 | stats->ac_utimescaled = cputime_to_usecs(tsk->utimescaled); | 71 | stats->ac_utime = cputime_to_usecs(utime); |
71 | stats->ac_stimescaled = cputime_to_usecs(tsk->stimescaled); | 72 | stats->ac_stime = cputime_to_usecs(stime); |
73 | |||
74 | task_cputime_scaled(tsk, &utimescaled, &stimescaled); | ||
75 | stats->ac_utimescaled = cputime_to_usecs(utimescaled); | ||
76 | stats->ac_stimescaled = cputime_to_usecs(stimescaled); | ||
77 | |||
72 | stats->ac_minflt = tsk->min_flt; | 78 | stats->ac_minflt = tsk->min_flt; |
73 | stats->ac_majflt = tsk->maj_flt; | 79 | stats->ac_majflt = tsk->maj_flt; |
74 | 80 | ||
@@ -115,11 +121,8 @@ void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) | |||
115 | #undef KB | 121 | #undef KB |
116 | #undef MB | 122 | #undef MB |
117 | 123 | ||
118 | /** | 124 | static void __acct_update_integrals(struct task_struct *tsk, |
119 | * acct_update_integrals - update mm integral fields in task_struct | 125 | cputime_t utime, cputime_t stime) |
120 | * @tsk: task_struct for accounting | ||
121 | */ | ||
122 | void acct_update_integrals(struct task_struct *tsk) | ||
123 | { | 126 | { |
124 | if (likely(tsk->mm)) { | 127 | if (likely(tsk->mm)) { |
125 | cputime_t time, dtime; | 128 | cputime_t time, dtime; |
@@ -128,7 +131,7 @@ void acct_update_integrals(struct task_struct *tsk) | |||
128 | u64 delta; | 131 | u64 delta; |
129 | 132 | ||
130 | local_irq_save(flags); | 133 | local_irq_save(flags); |
131 | time = tsk->stime + tsk->utime; | 134 | time = stime + utime; |
132 | dtime = time - tsk->acct_timexpd; | 135 | dtime = time - tsk->acct_timexpd; |
133 | jiffies_to_timeval(cputime_to_jiffies(dtime), &value); | 136 | jiffies_to_timeval(cputime_to_jiffies(dtime), &value); |
134 | delta = value.tv_sec; | 137 | delta = value.tv_sec; |
@@ -145,6 +148,27 @@ void acct_update_integrals(struct task_struct *tsk) | |||
145 | } | 148 | } |
146 | 149 | ||
147 | /** | 150 | /** |
151 | * acct_update_integrals - update mm integral fields in task_struct | ||
152 | * @tsk: task_struct for accounting | ||
153 | */ | ||
154 | void acct_update_integrals(struct task_struct *tsk) | ||
155 | { | ||
156 | cputime_t utime, stime; | ||
157 | |||
158 | task_cputime(tsk, &utime, &stime); | ||
159 | __acct_update_integrals(tsk, utime, stime); | ||
160 | } | ||
161 | |||
162 | /** | ||
163 | * acct_account_cputime - update mm integral after cputime update | ||
164 | * @tsk: task_struct for accounting | ||
165 | */ | ||
166 | void acct_account_cputime(struct task_struct *tsk) | ||
167 | { | ||
168 | __acct_update_integrals(tsk, tsk->utime, tsk->stime); | ||
169 | } | ||
170 | |||
171 | /** | ||
148 | * acct_clear_integrals - clear the mm integral fields in task_struct | 172 | * acct_clear_integrals - clear the mm integral fields in task_struct |
149 | * @tsk: task_struct whose accounting fields are cleared | 173 | * @tsk: task_struct whose accounting fields are cleared |
150 | */ | 174 | */ |