wait_task_zombie: remove unneeded child->signal check
[safe/jmp/linux-2.6] / Documentation / accounting / getdelays.c
index 6207e2f..cbee3a2 100644 (file)
@@ -49,6 +49,7 @@ char name[100];
 int dbg;
 int print_delays;
 int print_io_accounting;
+int print_task_context_switch_counts;
 __u64 stime, utime;
 
 #define PRINTF(fmt, arg...) {                  \
@@ -61,8 +62,6 @@ __u64 stime, utime;
 #define MAX_MSG_SIZE   1024
 /* Maximum number of cpus expected to be specified in a cpumask */
 #define MAX_CPUS       32
-/* Maximum length of pathname to log file */
-#define MAX_FILENAME   256
 
 struct msgtemplate {
        struct nlmsghdr n;
@@ -197,7 +196,7 @@ void print_delayacct(struct taskstats *t)
               "IO    %15s%15s\n"
               "      %15llu%15llu\n"
               "MEM   %15s%15s\n"
-              "      %15llu%15llu\n\n",
+              "      %15llu%15llu\n",
               "count", "real total", "virtual total", "delay total",
               t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total,
               t->cpu_delay_total,
@@ -206,6 +205,14 @@ void print_delayacct(struct taskstats *t)
               "count", "delay total", t->swapin_count, t->swapin_delay_total);
 }
 
+void task_context_switch_counts(struct taskstats *t)
+{
+       printf("\n\nTask   %15s%15s\n"
+              "       %15lu%15lu\n",
+              "voluntary", "nonvoluntary",
+              t->nvcsw, t->nivcsw);
+}
+
 void print_ioacct(struct taskstats *t)
 {
        printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n",
@@ -231,13 +238,13 @@ int main(int argc, char *argv[])
        int count = 0;
        int write_file = 0;
        int maskset = 0;
-       char logfile[128];
+       char *logfile = NULL;
        int loop = 0;
 
        struct msgtemplate msg;
 
        while (1) {
-               c = getopt(argc, argv, "diw:r:m:t:p:vl");
+               c = getopt(argc, argv, "qdiw:r:m:t:p:vl");
                if (c < 0)
                        break;
 
@@ -250,8 +257,12 @@ int main(int argc, char *argv[])
                        printf("printing IO accounting\n");
                        print_io_accounting = 1;
                        break;
+               case 'q':
+                       printf("printing task/process context switch rates\n");
+                       print_task_context_switch_counts = 1;
+                       break;
                case 'w':
-                       strncpy(logfile, optarg, MAX_FILENAME);
+                       logfile = strdup(optarg);
                        printf("write to file %s\n", logfile);
                        write_file = 1;
                        break;
@@ -391,6 +402,8 @@ int main(int argc, char *argv[])
                                                        print_delayacct((struct taskstats *) NLA_DATA(na));
                                                if (print_io_accounting)
                                                        print_ioacct((struct taskstats *) NLA_DATA(na));
+                                               if (print_task_context_switch_counts)
+                                                       task_context_switch_counts((struct taskstats *) NLA_DATA(na));
                                                if (fd) {
                                                        if (write(fd, NLA_DATA(na), na->nla_len) < 0) {
                                                                err(1,"write error\n");