4 * Test upcall performance. WARNING! This test does not reflect
5 * reality... the test is effectively making two system calls for
6 * each upcall when under normal conditions no system calls should be
7 * necessary when handling an upcall.
9 * $DragonFly: src/test/sysperf/upcall1.c,v 1.3 2004/01/12 16:48:37 drhodus Exp $
12 #include <sys/types.h>
13 #include <sys/upcall.h>
18 #define MAXCOUNT 10000000
20 struct upcall upc; /* simple single-cpu upcall test */
22 extern void callused_wrapper(void *); /* assembly */
23 static void myfunc(void *data);
29 main(int ac, char **av)
31 id = upc_register(&upc, callused_wrapper, myfunc, "blah");
32 printf("Warning: extra system calls in test means performance\n");
33 printf("does not reflect reality. Divide times by 3 for raw\n");
34 printf("per-upcall overhead (approximately)\n");
35 printf("register upcall %d\n", id);
36 printf("try to dispatch the upcall\n");
37 upc_control(UPC_CONTROL_DISPATCH, id, NULL);
38 stop_timing(MAXCOUNT, "Full-up upcall test");
39 printf("final: %d %d (should be 0 0)\n", upc.upc_critoff, upc.upc_pending);
47 * Dispatch a reentrant UPC. It should not stack because we are in a
48 * critical section, but the context code will catch it when it calls
52 upc_control(UPC_CONTROL_DISPATCH, id, NULL);
54 if (count > MAXCOUNT - 3) {
55 printf("UPCALL! (%s) upc: %d crit=%d pend=%d (should be 32 1) @sp %p\n",
56 data, upc.upc_magic, upc.upc_critoff, upc.upc_pending, &data);
57 if (count == MAXCOUNT - 2) {
58 printf("(sp should be same as before)\n");
59 printf("doing a total of %d upcalls\n", MAXCOUNT);