diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:26:12 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:26:12 -0400 |
commit | 7a9787e1eba95a166265e6a260cf30af04ef0a99 (patch) | |
tree | e730a4565e0318140d2fbd2f0415d18a339d7336 /fs/proc/array.c | |
parent | 41b9eb264c8407655db57b60b4457fe1b2ec9977 (diff) | |
parent | 0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff) |
Merge commit 'v2.6.28-rc2' into x86/pci-ioapic-boot-irq-quirks
Diffstat (limited to 'fs/proc/array.c')
-rw-r--r-- | fs/proc/array.c | 83 |
1 files changed, 11 insertions, 72 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c index 797d775e0354..bb9f4b05703d 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -80,16 +80,12 @@ | |||
80 | #include <linux/delayacct.h> | 80 | #include <linux/delayacct.h> |
81 | #include <linux/seq_file.h> | 81 | #include <linux/seq_file.h> |
82 | #include <linux/pid_namespace.h> | 82 | #include <linux/pid_namespace.h> |
83 | #include <linux/tracehook.h> | ||
83 | 84 | ||
84 | #include <asm/pgtable.h> | 85 | #include <asm/pgtable.h> |
85 | #include <asm/processor.h> | 86 | #include <asm/processor.h> |
86 | #include "internal.h" | 87 | #include "internal.h" |
87 | 88 | ||
88 | /* Gcc optimizes away "strlen(x)" for constant x */ | ||
89 | #define ADDBUF(buffer, string) \ | ||
90 | do { memcpy(buffer, string, strlen(string)); \ | ||
91 | buffer += strlen(string); } while (0) | ||
92 | |||
93 | static inline void task_name(struct seq_file *m, struct task_struct *p) | 89 | static inline void task_name(struct seq_file *m, struct task_struct *p) |
94 | { | 90 | { |
95 | int i; | 91 | int i; |
@@ -168,8 +164,12 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns, | |||
168 | rcu_read_lock(); | 164 | rcu_read_lock(); |
169 | ppid = pid_alive(p) ? | 165 | ppid = pid_alive(p) ? |
170 | task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; | 166 | task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; |
171 | tpid = pid_alive(p) && p->ptrace ? | 167 | tpid = 0; |
172 | task_pid_nr_ns(rcu_dereference(p->parent), ns) : 0; | 168 | if (pid_alive(p)) { |
169 | struct task_struct *tracer = tracehook_tracer_task(p); | ||
170 | if (tracer) | ||
171 | tpid = task_pid_nr_ns(tracer, ns); | ||
172 | } | ||
173 | seq_printf(m, | 173 | seq_printf(m, |
174 | "State:\t%s\n" | 174 | "State:\t%s\n" |
175 | "Tgid:\t%d\n" | 175 | "Tgid:\t%d\n" |
@@ -256,7 +256,6 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p) | |||
256 | sigemptyset(&ignored); | 256 | sigemptyset(&ignored); |
257 | sigemptyset(&caught); | 257 | sigemptyset(&caught); |
258 | 258 | ||
259 | rcu_read_lock(); | ||
260 | if (lock_task_sighand(p, &flags)) { | 259 | if (lock_task_sighand(p, &flags)) { |
261 | pending = p->pending.signal; | 260 | pending = p->pending.signal; |
262 | shpending = p->signal->shared_pending.signal; | 261 | shpending = p->signal->shared_pending.signal; |
@@ -267,7 +266,6 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p) | |||
267 | qlim = p->signal->rlim[RLIMIT_SIGPENDING].rlim_cur; | 266 | qlim = p->signal->rlim[RLIMIT_SIGPENDING].rlim_cur; |
268 | unlock_task_sighand(p, &flags); | 267 | unlock_task_sighand(p, &flags); |
269 | } | 268 | } |
270 | rcu_read_unlock(); | ||
271 | 269 | ||
272 | seq_printf(m, "Threads:\t%d\n", num_threads); | 270 | seq_printf(m, "Threads:\t%d\n", num_threads); |
273 | seq_printf(m, "SigQ:\t%lu/%lu\n", qsize, qlim); | 271 | seq_printf(m, "SigQ:\t%lu/%lu\n", qsize, qlim); |
@@ -332,65 +330,6 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, | |||
332 | return 0; | 330 | return 0; |
333 | } | 331 | } |
334 | 332 | ||
335 | /* | ||
336 | * Use precise platform statistics if available: | ||
337 | */ | ||
338 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING | ||
339 | static cputime_t task_utime(struct task_struct *p) | ||
340 | { | ||
341 | return p->utime; | ||
342 | } | ||
343 | |||
344 | static cputime_t task_stime(struct task_struct *p) | ||
345 | { | ||
346 | return p->stime; | ||
347 | } | ||
348 | #else | ||
349 | static cputime_t task_utime(struct task_struct *p) | ||
350 | { | ||
351 | clock_t utime = cputime_to_clock_t(p->utime), | ||
352 | total = utime + cputime_to_clock_t(p->stime); | ||
353 | u64 temp; | ||
354 | |||
355 | /* | ||
356 | * Use CFS's precise accounting: | ||
357 | */ | ||
358 | temp = (u64)nsec_to_clock_t(p->se.sum_exec_runtime); | ||
359 | |||
360 | if (total) { | ||
361 | temp *= utime; | ||
362 | do_div(temp, total); | ||
363 | } | ||
364 | utime = (clock_t)temp; | ||
365 | |||
366 | p->prev_utime = max(p->prev_utime, clock_t_to_cputime(utime)); | ||
367 | return p->prev_utime; | ||
368 | } | ||
369 | |||
370 | static cputime_t task_stime(struct task_struct *p) | ||
371 | { | ||
372 | clock_t stime; | ||
373 | |||
374 | /* | ||
375 | * Use CFS's precise accounting. (we subtract utime from | ||
376 | * the total, to make sure the total observed by userspace | ||
377 | * grows monotonically - apps rely on that): | ||
378 | */ | ||
379 | stime = nsec_to_clock_t(p->se.sum_exec_runtime) - | ||
380 | cputime_to_clock_t(task_utime(p)); | ||
381 | |||
382 | if (stime >= 0) | ||
383 | p->prev_stime = max(p->prev_stime, clock_t_to_cputime(stime)); | ||
384 | |||
385 | return p->prev_stime; | ||
386 | } | ||
387 | #endif | ||
388 | |||
389 | static cputime_t task_gtime(struct task_struct *p) | ||
390 | { | ||
391 | return p->gtime; | ||
392 | } | ||
393 | |||
394 | static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | 333 | static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, |
395 | struct pid *pid, struct task_struct *task, int whole) | 334 | struct pid *pid, struct task_struct *task, int whole) |
396 | { | 335 | { |
@@ -449,20 +388,20 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
449 | 388 | ||
450 | /* add up live thread stats at the group level */ | 389 | /* add up live thread stats at the group level */ |
451 | if (whole) { | 390 | if (whole) { |
391 | struct task_cputime cputime; | ||
452 | struct task_struct *t = task; | 392 | struct task_struct *t = task; |
453 | do { | 393 | do { |
454 | min_flt += t->min_flt; | 394 | min_flt += t->min_flt; |
455 | maj_flt += t->maj_flt; | 395 | maj_flt += t->maj_flt; |
456 | utime = cputime_add(utime, task_utime(t)); | ||
457 | stime = cputime_add(stime, task_stime(t)); | ||
458 | gtime = cputime_add(gtime, task_gtime(t)); | 396 | gtime = cputime_add(gtime, task_gtime(t)); |
459 | t = next_thread(t); | 397 | t = next_thread(t); |
460 | } while (t != task); | 398 | } while (t != task); |
461 | 399 | ||
462 | min_flt += sig->min_flt; | 400 | min_flt += sig->min_flt; |
463 | maj_flt += sig->maj_flt; | 401 | maj_flt += sig->maj_flt; |
464 | utime = cputime_add(utime, sig->utime); | 402 | thread_group_cputime(task, &cputime); |
465 | stime = cputime_add(stime, sig->stime); | 403 | utime = cputime.utime; |
404 | stime = cputime.stime; | ||
466 | gtime = cputime_add(gtime, sig->gtime); | 405 | gtime = cputime_add(gtime, sig->gtime); |
467 | } | 406 | } |
468 | 407 | ||