Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
xcap
xcap-async-module
Commits
fb125ea3
Commit
fb125ea3
authored
Mar 23, 2016
by
Michael Quigley
Browse files
Start basic layout of context switch benchmark test for async module. Not tested or built yet.
parent
91713cc9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/tests/ctx-switch/main.c
0 → 100644
View file @
fb125ea3
/*
* main.c
*
* This file is part of the benchmarking tests for libasync.
* This file is responsible for measuring the context switch time.
*
* Author: Michael Quigley
* Date: March 2016
*/
#include
<libfipc.h>
#include
<linux/kernel.h>
#include
<linux/module.h>
#include
"../test_helpers.h"
MODULE_LICENSE
(
"GPL"
);
#define NUM_SWITCH_MEASUREMENTS 1000
static
unsigned
long
ctx_switch_measurements
[
NUM_SWITCH_MEASUREMENTS
];
static
int
setup_and_run_test
(
void
)
{
unsigned
long
start_time
,
end_time
,
elapsed_time
;
uint32_t
msg_id
;
thc_init
();
for
(
int
i
=
0
;
i
<
NUM_SWITCH_MEASUREMENTS
;
i
++
)
{
DO_FINISH_
(
ctx_switch
,{
ASYNC
({
msg_id
=
awe_mapper_create_id
();
THCYieldAndSave
(
msg_id
);
end_time
=
test_fipc_stop_stopwatch
();
});
ASYNC
({
start_time
=
test_fipc_start_stopwatch
();
THCYieldToId
(
msg_id
);
awe_mapper_remove_id
(
msg_id
);
});
});
ctx_switch_measurements
[
i
]
=
end_time
-
start_time
;
}
printk
(
KERN_ERR
"Timing results of performing %d switches between awe contexts:
\n
"
,
NUM_SWITCH_MEASUREMENTS
);
test_fipc_dump_time
(
ctx_switch_measurements
,
NUM_SWITCH_MEASUREMENTS
);
thc_done
();
}
static
int
__init
ctx_switch_init
(
void
)
{
int
ret
=
0
;
LCD_MAIN
({
ret
=
setup_and_run_test
();
});
return
ret
;
}
static
void
__exit
ctx_switch_rmmod
(
void
)
{
return
;
}
module_init
(
ctx_switch_init
);
module_exit
(
ctx_switch_rmmod
);
src/tests/test_helpers.c
0 → 100644
View file @
fb125ea3
#include
"test_helpers.h"
static
int
test_fipc_compare
(
const
void
*
_a
,
const
void
*
_b
){
u64
a
=
*
((
u64
*
)
_a
);
u64
b
=
*
((
u64
*
)
_b
);
if
(
a
<
b
)
return
-
1
;
if
(
a
>
b
)
return
1
;
return
0
;
}
src/tests/test_helpers.h
View file @
fb125ea3
...
...
@@ -14,6 +14,7 @@
#include
<linux/sched.h>
#include
<linux/kthread.h>
#include
<linux/kernel.h>
#include
<linux/sort.h>
#include
<libfipc.h>
#define LCD_MAIN(_CODE) do { \
...
...
@@ -260,4 +261,32 @@ static inline unsigned long test_fipc_stop_stopwatch(void)
return
stamp
;
}
static
int
test_fipc_compare
(
const
void
*
_a
,
const
void
*
_b
);
static
inline
void
test_fipc_dump_time
(
unsigned
long
*
time
,
unsigned
long
num_transactions
)
{
int
i
;
unsigned
long
long
counter
=
0
;
unsigned
long
min
;
unsigned
long
max
;
for
(
i
=
0
;
i
<
num_transactions
;
i
++
)
{
counter
+=
time
[
i
];
}
sort
(
time
,
num_transactions
,
sizeof
(
unsigned
long
),
test_fipc_compare
,
NULL
);
min
=
time
[
0
];
max
=
time
[
num_transactions
-
1
];
counter
=
min
;
printk
(
KERN_ERR
"MIN
\t
MAX
\t
AVG
\t
MEDIAN
\n
"
);
printk
(
KERN_ERR
"%lu & %lu & %llu & %lu
\n
"
,
min
,
max
,
counter
/
num_transactions
,
time
[
num_transactions
/
2
]);
}
#endif
/* FIPC_KERNEL_TEST_HELPERS_H */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment