Measurement for async syscalls
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 7 May 2009 22:48:47 +0000 (15:48 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 7 May 2009 22:48:47 +0000 (15:48 -0700)
Needs error checking on the userspace syscall path.

inc/lib.h
inc/measure.h
kern/init.c
lib/printf.c
user/null.c

index e89eba2..14e15d7 100644 (file)
--- a/inc/lib.h
+++ b/inc/lib.h
@@ -47,7 +47,7 @@ error_t waiton_syscall(syscall_desc_t* desc, syscall_rsp_t* rsp);
 
 // async callback
 #define MAX_SYSCALLS 100
-#define MAX_ASYNCCALLS 10
+#define MAX_ASYNCCALLS 100
 // The high-level object a process waits on, with multiple syscalls within.
 typedef struct async_desc {
        syscall_desc_list_t syslist;
index ba387a2..a751bb8 100644 (file)
        ticks;                                                                     \
 })
 
+#define measure_function_async(func, desc_name, i_iters, o_iters, name)        \
+({                                                                             \
+       uint64_t ticks;                                                            \
+       cpuid(0, 0, 0, 0, 0);                                                      \
+       ticks = read_tsc();                                                        \
+       async_desc_t* desc_array[i_iters];                                         \
+       async_desc_t* desc_name;                                                   \
+       /* Run this a bunch of times to make sure its accurate */                  \
+       for(int i=0; i< (o_iters); i++) {                                          \
+               for (int j = 0; j < (i_iters); j++) {                                  \
+                       func ;                                                             \
+                       desc_array[j] = desc_name;                                         \
+               }                                                                      \
+               for (int j = 0; j < (i_iters); j++) {                                  \
+                       waiton_async_call(desc_array[j]);                                  \
+               }                                                                      \
+       }                                                                          \
+       cpuid(0, 0, 0, 0, 0);                                                      \
+       ticks = read_tsc() - ticks;                                                \
+       /* Compute the average and print it */                                     \
+       uint64_t a = (1000000000LL/((o_iters)*(i_iters)) * ticks) /                \
+                    (env->env_tscfreq);                                           \
+       if ((name))                                                                \
+               cprintf("Measuring %s:\n"                                              \
+                       "    Total ticks:        %20lld\n"                             \
+                       "    Num Iterations:     %20d\n"                               \
+                       "    Time Per Iteration: %20lld\n",                            \
+               name, ticks, ((o_iters)*(i_iters)), a);                            \
+       ticks;                                                                     \
+})
+
 #endif /* !ROS_INC_MEASURE_H */
index 37b2afb..0cc26dd 100644 (file)
@@ -80,9 +80,9 @@ void kernel_init(multiboot_info_t *mboot_info)
        //ENV_CREATE(user_badsegment);
        //ENV_CREATE(user_divzero);
        //ENV_CREATE(user_buggyhello);
-       ENV_CREATE(user_hello);
        //ENV_CREATE(user_hello);
-       //ENV_CREATE(user_null);
+       //ENV_CREATE(user_hello);
+       ENV_CREATE(user_null);
        //ENV_CREATE(user_evilhello);
 
        // We only have one user environment for now, so just run it.
index b07487e..f64ecea 100644 (file)
@@ -60,7 +60,7 @@ int cprintf(const char *fmt, ...)
 }
 
 // Temp async varieties
-#define MAX_BUFFERS 10
+#define MAX_BUFFERS 100
 POOL_TYPE_DEFINE(printbuf_t, print_buf_pool, MAX_BUFFERS);
 print_buf_pool_t print_buf_pool;
 
index 4f398f9..108a126 100644 (file)
@@ -5,6 +5,10 @@
 #include <inc/x86.h>
 #include <inc/measure.h>
 
+#ifdef __DEPUTY__
+#pragma nodeputy
+#endif
+
 #define NUM_ITERATIONS 100000
 uint64_t times[NUM_ITERATIONS];
 
@@ -22,7 +26,9 @@ void umain(void)
 {
        measure_function(sys_null(), NUM_ITERATIONS, "sys_null");
        measure_function(asm volatile("nop;"), NUM_ITERATIONS, "nop");
-       measure_function(cprintf("hello\n"), 2, "printf");
+       //measure_function(cprintf("Reg Sync call  \n"), 10, "printf");
+       //measure_function_async(cprintf_async(&desc, "Cross-Core call\n"), desc, 10,\
+                              1, "Async Printf");
 
        // Spin to make sure we don't have any resources deallocated before done
        while(1);