bce: Disable RX max BDs based interrupt moderation
[dragonfly.git] / test / sysperf / upcall1.c
CommitLineData
3eb3763b
MD
1/*
2 * UPCALL1.C
3 *
300aac00
MD
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.
3eb3763b 8 *
34db7d32 9 * $DragonFly: src/test/sysperf/upcall1.c,v 1.3 2004/01/12 16:48:37 drhodus Exp $
3eb3763b
MD
10 */
11
12#include <sys/types.h>
13#include <sys/upcall.h>
14#include <sys/time.h>
15#include <stdio.h>
16#include "blib.h"
17
18#define MAXCOUNT 10000000
19
20struct upcall upc; /* simple single-cpu upcall test */
21
22extern void callused_wrapper(void *); /* assembly */
23static void myfunc(void *data);
24
25int count = MAXCOUNT;
26int id;
27
28int
29main(int ac, char **av)
30{
31 id = upc_register(&upc, callused_wrapper, myfunc, "blah");
300aac00
MD
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");
3eb3763b
MD
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");
34db7d32 39 printf("final: %d %d (should be 0 0)\n", upc.upc_critoff, upc.upc_pending);
3eb3763b
MD
40 return 0;
41}
42
43static void
44myfunc(void *data)
45{
46 /*
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
49 * UPC_CONTROL_NEXT.
50 */
51 if (--count > 0) {
52 upc_control(UPC_CONTROL_DISPATCH, id, NULL);
53 }
54 if (count > MAXCOUNT - 3) {
55 printf("UPCALL! (%s) upc: %d crit=%d pend=%d (should be 32 1) @sp %p\n",
34db7d32 56 data, upc.upc_magic, upc.upc_critoff, upc.upc_pending, &data);
3eb3763b
MD
57 if (count == MAXCOUNT - 2) {
58 printf("(sp should be same as before)\n");
59 printf("doing a total of %d upcalls\n", MAXCOUNT);
60 usleep(20000);
61 start_timing();
62 }
63 }
64}
65