Skip to content

Commit

Permalink
selftest/task_diag: Add TASK_DIAG_SHOW_STAT test.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
  • Loading branch information
aryabinin authored and avagin committed Nov 15, 2018
1 parent 014f2ff commit 2a9e0ea
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/testing/selftests/task_diag/task_diag_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ int main(int argc, char *argv[])
int last_pid = 0;
int opt, idx;
int err, size = 0;
static const char short_opts[] = "p:cmslq";
static const char short_opts[] = "p:cmslqx";
static struct option long_opts[] = {
{ "pid", required_argument, 0, 'p' },
{ "maps", no_argument, 0, 'm' },
{ "smaps", no_argument, 0, 's' },
{ "cred", no_argument, 0, 'c' },
{ "cmdline", no_argument, 0, 'l' },
{ "quiet", no_argument, 0, 'q' },
{ "stat", no_argument, 0, 'x' },
{},
};

Expand Down Expand Up @@ -123,6 +124,9 @@ int main(int argc, char *argv[])
case 'q':
quiet = 1;
break;
case 'x':
req->show_flags |= TASK_DIAG_SHOW_STAT;
break;
default:
usage(argv[0]);
return 1;
Expand Down
26 changes: 26 additions & 0 deletions tools/testing/selftests/task_diag/task_diag_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,32 @@ int show_task(struct nlmsghdr *hdr, void *arg)
}
}
break;
case TASK_DIAG_STAT:
{
struct task_diag_stat *stat;
stat = NLA_DATA(na);

pr_info(
"minflt: %llu\n"
"cminflt: %llu\n"
"majflt: %llu\n"
"cmajflt: %llu\n"
"utime: %llu\n"
"stime: %llu\n"
"cutime: %llu\n"
"cstime: %llu\n"
"threads: %u\n",
stat->minflt,
stat->cminflt,
stat->majflt,
stat->cmajflt,
stat->utime,
stat->stime,
stat->cutime,
stat->cstime,
stat->threads);
}
break;
default:
pr_info("Unknown nla_type %d\n",
na->nla_type);
Expand Down

0 comments on commit 2a9e0ea

Please sign in to comment.