Add a verbosity parameter to "pip"
authorBarret Rhoden <brho@cs.berkeley.edu>
Sun, 29 Jan 2017 22:25:04 +0000 (17:25 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 9 Feb 2017 17:30:27 +0000 (12:30 -0500)
Default is 0.  At verbosity >= 1, you'll also see the backtrace of
whatever SCP context was last saved (which might be dangerous or wrong)
and the amount of time spent on each vcore.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/include/process.h
kern/src/monitor.c
kern/src/process.c

index a4dcdbc..bae8b7b 100644 (file)
@@ -181,4 +181,4 @@ void __clear_owning_proc(uint32_t coreid);
 
 /* Degubbing */
 void print_allpids(void);
-void print_proc_info(pid_t pid);
+void print_proc_info(pid_t pid, int verbosity);
index f4a3288..fb9736b 100644 (file)
@@ -342,6 +342,8 @@ int mon_bin_run(int argc, char **argv, struct hw_trapframe *hw_tf)
 
 int mon_procinfo(int argc, char **argv, struct hw_trapframe *hw_tf)
 {
+       int verbosity = 0;
+
        if (argc < 2) {
                printk("Usage: procinfo OPTION\n");
                printk("\tall: show all active pids\n");
@@ -353,11 +355,13 @@ int mon_procinfo(int argc, char **argv, struct hw_trapframe *hw_tf)
        if (!strcmp(argv[1], "all")) {
                print_allpids();
        } else if (!strcmp(argv[1], "pid")) {
-               if (argc != 3) {
+               if (argc < 3) {
                        printk("Give me a pid number.\n");
                        return 1;
                }
-               print_proc_info(strtol(argv[2], 0, 0));
+               if (argc >= 4)
+                       verbosity = strtol(argv[3], 0, 0);
+               print_proc_info(strtol(argv[2], 0, 0), verbosity);
        } else if (!strcmp(argv[1], "unlock")) {
                if (argc != 3) {
                        printk("Gimme lock address!  Me want lock address!.\n");
@@ -390,11 +394,15 @@ int mon_procinfo(int argc, char **argv, struct hw_trapframe *hw_tf)
 
 int mon_pip(int argc, char **argv, struct hw_trapframe *hw_tf)
 {
-       if (argc != 2) {
+       int verbosity = 0;
+
+       if (argc < 2) {
                printk("Give me a pid number.\n");
                return 1;
        }
-       print_proc_info(strtol(argv[1], 0, 0));
+       if (argc >= 3)
+               verbosity = strtol(argv[2], 0, 0);
+       print_proc_info(strtol(argv[1], 0, 0), verbosity);
        return 0;
 }
 
@@ -813,7 +821,7 @@ int mon_trace(int argc, char **argv, struct hw_trapframe *hw_tf)
                        printk("ERRRRRRRRRR.\n");
                        return 1;
                }
-               print_proc_info(strtol(argv[2], 0, 0));
+               print_proc_info(strtol(argv[2], 0, 0), 0);
        } else {
                printk("Bad option\n");
                return 1;
index f9d754c..f8c80ed 100644 (file)
@@ -2371,7 +2371,7 @@ void proc_free_set(struct process_set *pset)
        kfree(pset->procs);
 }
 
-void print_proc_info(pid_t pid)
+void print_proc_info(pid_t pid, int verbosity)
 {
        int j = 0;
        uint64_t total_time = 0;
@@ -2394,6 +2394,10 @@ void print_proc_info(pid_t pid)
        printk("\tIs %san MCP\n", p->procinfo->is_mcp ? "" : "not ");
        if (!scp_is_vcctx_ready(vcpd))
                printk("\tIs NOT vcctx ready\n");
+       if (verbosity > 0 && !p->procinfo->is_mcp) {
+               printk("Last saved SCP context:");
+               backtrace_user_ctx(p, &p->scp_ctx);
+       }
        printk("Refcnt: %d\n", atomic_read(&p->p_kref.refcount) - 1);
        printk("Flags: 0x%08x\n", p->env_flags);
        printk("CR3(phys): %p\n", p->env_cr3);
@@ -2408,16 +2412,20 @@ void print_proc_info(pid_t pid)
        printk("Inactive / Yielded:\n");
        TAILQ_FOREACH(vc_i, &p->inactive_vcs, list)
                printk("\tVcore %d\n", vcore2vcoreid(p, vc_i));
-       printk("Nsec Online, up to the last offlining:\n------------------------");
-       for (int i = 0; i < p->procinfo->max_vcores; i++) {
-               uint64_t vc_time = tsc2nsec(vcore_account_gettotal(p, i));
-               if (i % 4 == 0)
-                       printk("\n");
-               printk("  VC %3d: %14llu", i, vc_time);
-               total_time += vc_time;
+       if (verbosity > 0) {
+               printk("Nsec Online, up to the last offlining:\n");
+               printk("------------------------");
+               for (int i = 0; i < p->procinfo->max_vcores; i++) {
+                       uint64_t vc_time = tsc2nsec(vcore_account_gettotal(p, i));
+
+                       if (i % 4 == 0)
+                               printk("\n");
+                       printk("  VC %3d: %14llu", i, vc_time);
+                       total_time += vc_time;
+               }
+               printk("\n");
+               printk("Total CPU-NSEC: %llu\n", total_time);
        }
-       printk("\n");
-       printk("Total CPU-NSEC: %llu\n", total_time);
        printk("Resources:\n------------------------\n");
        for (int i = 0; i < MAX_NUM_RESOURCES; i++)
                printk("\tRes type: %02d, amt wanted: %08d, amt granted: %08d\n", i,