diff options
-rw-r--r-- | fs/proc/array.c | 119 | ||||
-rw-r--r-- | fs/seq_file.c | 21 | ||||
-rw-r--r-- | include/linux/seq_file.h | 2 |
3 files changed, 86 insertions, 56 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c index c602b8d20f06..fbb53c249086 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -462,59 +462,56 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
462 | /* convert nsec -> ticks */ | 462 | /* convert nsec -> ticks */ |
463 | start_time = nsec_to_clock_t(start_time); | 463 | start_time = nsec_to_clock_t(start_time); |
464 | 464 | ||
465 | seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \ | 465 | seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state); |
466 | %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ | 466 | seq_put_decimal_ll(m, ' ', ppid); |
467 | %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld %lu %lu %lu\n", | 467 | seq_put_decimal_ll(m, ' ', pgid); |
468 | pid_nr_ns(pid, ns), | 468 | seq_put_decimal_ll(m, ' ', sid); |
469 | tcomm, | 469 | seq_put_decimal_ll(m, ' ', tty_nr); |
470 | state, | 470 | seq_put_decimal_ll(m, ' ', tty_pgrp); |
471 | ppid, | 471 | seq_put_decimal_ull(m, ' ', task->flags); |
472 | pgid, | 472 | seq_put_decimal_ull(m, ' ', min_flt); |
473 | sid, | 473 | seq_put_decimal_ull(m, ' ', cmin_flt); |
474 | tty_nr, | 474 | seq_put_decimal_ull(m, ' ', maj_flt); |
475 | tty_pgrp, | 475 | seq_put_decimal_ull(m, ' ', cmaj_flt); |
476 | task->flags, | 476 | seq_put_decimal_ull(m, ' ', cputime_to_clock_t(utime)); |
477 | min_flt, | 477 | seq_put_decimal_ull(m, ' ', cputime_to_clock_t(stime)); |
478 | cmin_flt, | 478 | seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cutime)); |
479 | maj_flt, | 479 | seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cstime)); |
480 | cmaj_flt, | 480 | seq_put_decimal_ll(m, ' ', priority); |
481 | cputime_to_clock_t(utime), | 481 | seq_put_decimal_ll(m, ' ', nice); |
482 | cputime_to_clock_t(stime), | 482 | seq_put_decimal_ll(m, ' ', num_threads); |
483 | cputime_to_clock_t(cutime), | 483 | seq_put_decimal_ull(m, ' ', 0); |
484 | cputime_to_clock_t(cstime), | 484 | seq_put_decimal_ull(m, ' ', start_time); |
485 | priority, | 485 | seq_put_decimal_ull(m, ' ', vsize); |
486 | nice, | 486 | seq_put_decimal_ll(m, ' ', mm ? get_mm_rss(mm) : 0); |
487 | num_threads, | 487 | seq_put_decimal_ull(m, ' ', rsslim); |
488 | start_time, | 488 | seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0); |
489 | vsize, | 489 | seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0); |
490 | mm ? get_mm_rss(mm) : 0, | 490 | seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0); |
491 | rsslim, | 491 | seq_put_decimal_ull(m, ' ', esp); |
492 | mm ? (permitted ? mm->start_code : 1) : 0, | 492 | seq_put_decimal_ull(m, ' ', eip); |
493 | mm ? (permitted ? mm->end_code : 1) : 0, | 493 | /* The signal information here is obsolete. |
494 | (permitted && mm) ? mm->start_stack : 0, | 494 | * It must be decimal for Linux 2.0 compatibility. |
495 | esp, | 495 | * Use /proc/#/status for real-time signals. |
496 | eip, | 496 | */ |
497 | /* The signal information here is obsolete. | 497 | seq_put_decimal_ull(m, ' ', task->pending.signal.sig[0] & 0x7fffffffUL); |
498 | * It must be decimal for Linux 2.0 compatibility. | 498 | seq_put_decimal_ull(m, ' ', task->blocked.sig[0] & 0x7fffffffUL); |
499 | * Use /proc/#/status for real-time signals. | 499 | seq_put_decimal_ull(m, ' ', sigign.sig[0] & 0x7fffffffUL); |
500 | */ | 500 | seq_put_decimal_ull(m, ' ', sigcatch.sig[0] & 0x7fffffffUL); |
501 | task->pending.signal.sig[0] & 0x7fffffffUL, | 501 | seq_put_decimal_ull(m, ' ', wchan); |
502 | task->blocked.sig[0] & 0x7fffffffUL, | 502 | seq_put_decimal_ull(m, ' ', 0); |
503 | sigign .sig[0] & 0x7fffffffUL, | 503 | seq_put_decimal_ull(m, ' ', 0); |
504 | sigcatch .sig[0] & 0x7fffffffUL, | 504 | seq_put_decimal_ll(m, ' ', task->exit_signal); |
505 | wchan, | 505 | seq_put_decimal_ll(m, ' ', task_cpu(task)); |
506 | 0UL, | 506 | seq_put_decimal_ull(m, ' ', task->rt_priority); |
507 | 0UL, | 507 | seq_put_decimal_ull(m, ' ', task->policy); |
508 | task->exit_signal, | 508 | seq_put_decimal_ull(m, ' ', delayacct_blkio_ticks(task)); |
509 | task_cpu(task), | 509 | seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime)); |
510 | task->rt_priority, | 510 | seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime)); |
511 | task->policy, | 511 | seq_put_decimal_ull(m, ' ', (mm && permitted) ? mm->start_data : 0); |
512 | (unsigned long long)delayacct_blkio_ticks(task), | 512 | seq_put_decimal_ull(m, ' ', (mm && permitted) ? mm->end_data : 0); |
513 | cputime_to_clock_t(gtime), | 513 | seq_put_decimal_ull(m, ' ', (mm && permitted) ? mm->start_brk : 0); |
514 | cputime_to_clock_t(cgtime), | 514 | seq_putc(m, '\n'); |
515 | (mm && permitted) ? mm->start_data : 0, | ||
516 | (mm && permitted) ? mm->end_data : 0, | ||
517 | (mm && permitted) ? mm->start_brk : 0); | ||
518 | if (mm) | 515 | if (mm) |
519 | mmput(mm); | 516 | mmput(mm); |
520 | return 0; | 517 | return 0; |
@@ -542,8 +539,20 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, | |||
542 | size = task_statm(mm, &shared, &text, &data, &resident); | 539 | size = task_statm(mm, &shared, &text, &data, &resident); |
543 | mmput(mm); | 540 | mmput(mm); |
544 | } | 541 | } |
545 | seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n", | 542 | /* |
546 | size, resident, shared, text, data); | 543 | * For quick read, open code by putting numbers directly |
544 | * expected format is | ||
545 | * seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n", | ||
546 | * size, resident, shared, text, data); | ||
547 | */ | ||
548 | seq_put_decimal_ull(m, 0, size); | ||
549 | seq_put_decimal_ull(m, ' ', resident); | ||
550 | seq_put_decimal_ull(m, ' ', shared); | ||
551 | seq_put_decimal_ull(m, ' ', text); | ||
552 | seq_put_decimal_ull(m, ' ', 0); | ||
553 | seq_put_decimal_ull(m, ' ', text); | ||
554 | seq_put_decimal_ull(m, ' ', 0); | ||
555 | seq_putc(m, '\n'); | ||
547 | 556 | ||
548 | return 0; | 557 | return 0; |
549 | } | 558 | } |
diff --git a/fs/seq_file.c b/fs/seq_file.c index 7d19816c4cc9..55c293f7024d 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -659,7 +659,8 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter, | |||
659 | if (m->count + 2 >= m->size) /* we'll write 2 bytes at least */ | 659 | if (m->count + 2 >= m->size) /* we'll write 2 bytes at least */ |
660 | goto overflow; | 660 | goto overflow; |
661 | 661 | ||
662 | m->buf[m->count++] = delimiter; | 662 | if (delimiter) |
663 | m->buf[m->count++] = delimiter; | ||
663 | 664 | ||
664 | if (num < 10) { | 665 | if (num < 10) { |
665 | m->buf[m->count++] = num + '0'; | 666 | m->buf[m->count++] = num + '0'; |
@@ -677,6 +678,24 @@ overflow: | |||
677 | } | 678 | } |
678 | EXPORT_SYMBOL(seq_put_decimal_ull); | 679 | EXPORT_SYMBOL(seq_put_decimal_ull); |
679 | 680 | ||
681 | int seq_put_decimal_ll(struct seq_file *m, char delimiter, | ||
682 | long long num) | ||
683 | { | ||
684 | if (num < 0) { | ||
685 | if (m->count + 3 >= m->size) { | ||
686 | m->count = m->size; | ||
687 | return -1; | ||
688 | } | ||
689 | if (delimiter) | ||
690 | m->buf[m->count++] = delimiter; | ||
691 | num = -num; | ||
692 | delimiter = '-'; | ||
693 | } | ||
694 | return seq_put_decimal_ull(m, delimiter, num); | ||
695 | |||
696 | } | ||
697 | EXPORT_SYMBOL(seq_put_decimal_ll); | ||
698 | |||
680 | /** | 699 | /** |
681 | * seq_write - write arbitrary data to buffer | 700 | * seq_write - write arbitrary data to buffer |
682 | * @seq: seq_file identifying the buffer to which data should be written | 701 | * @seq: seq_file identifying the buffer to which data should be written |
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 5bba42c99448..54e5ae7f8adc 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h | |||
@@ -123,6 +123,8 @@ int seq_open_private(struct file *, const struct seq_operations *, int); | |||
123 | int seq_release_private(struct inode *, struct file *); | 123 | int seq_release_private(struct inode *, struct file *); |
124 | int seq_put_decimal_ull(struct seq_file *m, char delimiter, | 124 | int seq_put_decimal_ull(struct seq_file *m, char delimiter, |
125 | unsigned long long num); | 125 | unsigned long long num); |
126 | int seq_put_decimal_ll(struct seq_file *m, char delimiter, | ||
127 | long long num); | ||
126 | 128 | ||
127 | #define SEQ_START_TOKEN ((void *)1) | 129 | #define SEQ_START_TOKEN ((void *)1) |
128 | /* | 130 | /* |