git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
net/mlx5: fix mbuf overflow in vectorized MPRQ
[dpdk.git]
/
app
/
test
/
test_timer.c
diff --git
a/app/test/test_timer.c
b/app/test/test_timer.c
index
8e0a589
..
a10b2fe
100644
(file)
--- a/
app/test/test_timer.c
+++ b/
app/test/test_timer.c
@@
-37,7
+37,7
@@
* - All cores then simultaneously are set to schedule all the timers at
* the same time, so conflicts should occur.
* - Then there is a delay while we wait for the timers to expire
* - All cores then simultaneously are set to schedule all the timers at
* the same time, so conflicts should occur.
* - Then there is a delay while we wait for the timers to expire
- * - Then the ma
ster
lcore calls timer_manage() and we check that all
+ * - Then the ma
in
lcore calls timer_manage() and we check that all
* timers have had their callbacks called exactly once - no more no less.
* - Then we repeat the process, except after setting up the timers, we have
* all cores randomly reschedule them.
* timers have had their callbacks called exactly once - no more no less.
* - Then we repeat the process, except after setting up the timers, we have
* all cores randomly reschedule them.
@@
-58,7
+58,7
@@
*
* - timer0
*
*
* - timer0
*
- * - At initialization, timer0 is loaded by the ma
ster core, on master
core
+ * - At initialization, timer0 is loaded by the ma
in core, on main
core
* in "single" mode (time = 1 second).
* - In the first 19 callbacks, timer0 is reloaded on the same core,
* then, it is explicitly stopped at the 20th call.
* in "single" mode (time = 1 second).
* - In the first 19 callbacks, timer0 is reloaded on the same core,
* then, it is explicitly stopped at the 20th call.
@@
-66,21
+66,21
@@
*
* - timer1
*
*
* - timer1
*
- * - At initialization, timer1 is loaded by the ma
ster
core, on the
- * ma
ster
core in "single" mode (time = 2 seconds).
+ * - At initialization, timer1 is loaded by the ma
in
core, on the
+ * ma
in
core in "single" mode (time = 2 seconds).
* - In the first 9 callbacks, timer1 is reloaded on another
* core. After the 10th callback, timer1 is not reloaded anymore.
*
* - timer2
*
* - In the first 9 callbacks, timer1 is reloaded on another
* core. After the 10th callback, timer1 is not reloaded anymore.
*
* - timer2
*
- * - At initialization, timer2 is loaded by the ma
ster
core, on the
- * ma
ster
core in "periodical" mode (time = 1 second).
+ * - At initialization, timer2 is loaded by the ma
in
core, on the
+ * ma
in
core in "periodical" mode (time = 1 second).
* - In the callback, when t=25s, it stops timer3 and reloads timer0
* on the current core.
*
* - timer3
*
* - In the callback, when t=25s, it stops timer3 and reloads timer0
* on the current core.
*
* - timer3
*
- * - At initialization, timer3 is loaded by the ma
ster
core, on
+ * - At initialization, timer3 is loaded by the ma
in
core, on
* another core in "periodical" mode (time = 1 second).
* - It is stopped at t=25s by timer2.
*/
* another core in "periodical" mode (time = 1 second).
* - It is stopped at t=25s by timer2.
*/
@@
-137,8
+137,8
@@
mytimer_reset(struct mytimerinfo *timinfo, uint64_t ticks,
/* timer callback for stress tests */
static void
/* timer callback for stress tests */
static void
-timer_stress_cb(__
attribute__((unused))
struct rte_timer *tim,
- __
attribute__((unused))
void *arg)
+timer_stress_cb(__
rte_unused
struct rte_timer *tim,
+ __
rte_unused
void *arg)
{
long r;
unsigned lcore_id = rte_lcore_id();
{
long r;
unsigned lcore_id = rte_lcore_id();
@@
-163,7
+163,7
@@
timer_stress_cb(__attribute__((unused)) struct rte_timer *tim,
}
static int
}
static int
-timer_stress_main_loop(__
attribute__((unused))
void *arg)
+timer_stress_main_loop(__
rte_unused
void *arg)
{
uint64_t hz = rte_get_timer_hz();
unsigned lcore_id = rte_lcore_id();
{
uint64_t hz = rte_get_timer_hz();
unsigned lcore_id = rte_lcore_id();
@@
-201,68
+201,69
@@
timer_stress_main_loop(__attribute__((unused)) void *arg)
return 0;
}
return 0;
}
-/* Need to synchronize
slave
lcores through multiple steps. */
-enum {
SLAVE_WAITING = 1, SLAVE_RUN_SIGNAL, SLAVE_RUNNING, SLAVE
_FINISHED };
-static rte_atomic16_t
slav
e_state[RTE_MAX_LCORE];
+/* Need to synchronize
worker
lcores through multiple steps. */
+enum {
WORKER_WAITING = 1, WORKER_RUN_SIGNAL, WORKER_RUNNING, WORKER
_FINISHED };
+static rte_atomic16_t
lcor
e_state[RTE_MAX_LCORE];
static void
static void
-ma
ster_init_slave
s(void)
+ma
in_init_worker
s(void)
{
unsigned i;
{
unsigned i;
- RTE_LCORE_FOREACH_
SLAVE
(i) {
- rte_atomic16_set(&
slave_state[i], SLAVE
_WAITING);
+ RTE_LCORE_FOREACH_
WORKER
(i) {
+ rte_atomic16_set(&
lcore_state[i], WORKER
_WAITING);
}
}
static void
}
}
static void
-ma
ster_start_slave
s(void)
+ma
in_start_worker
s(void)
{
unsigned i;
{
unsigned i;
- RTE_LCORE_FOREACH_
SLAVE
(i) {
- rte_atomic16_set(&
slave_state[i], SLAVE
_RUN_SIGNAL);
+ RTE_LCORE_FOREACH_
WORKER
(i) {
+ rte_atomic16_set(&
lcore_state[i], WORKER
_RUN_SIGNAL);
}
}
- RTE_LCORE_FOREACH_
SLAVE
(i) {
- while (rte_atomic16_read(&
slave_state[i]) != SLAVE
_RUNNING)
+ RTE_LCORE_FOREACH_
WORKER
(i) {
+ while (rte_atomic16_read(&
lcore_state[i]) != WORKER
_RUNNING)
rte_pause();
}
}
static void
rte_pause();
}
}
static void
-ma
ster_wait_for_slave
s(void)
+ma
in_wait_for_worker
s(void)
{
unsigned i;
{
unsigned i;
- RTE_LCORE_FOREACH_
SLAVE
(i) {
- while (rte_atomic16_read(&
slave_state[i]) != SLAVE
_FINISHED)
+ RTE_LCORE_FOREACH_
WORKER
(i) {
+ while (rte_atomic16_read(&
lcore_state[i]) != WORKER
_FINISHED)
rte_pause();
}
}
static void
rte_pause();
}
}
static void
-
slave
_wait_to_start(void)
+
worker
_wait_to_start(void)
{
unsigned lcore_id = rte_lcore_id();
{
unsigned lcore_id = rte_lcore_id();
- while (rte_atomic16_read(&
slave_state[lcore_id]) != SLAVE
_RUN_SIGNAL)
+ while (rte_atomic16_read(&
lcore_state[lcore_id]) != WORKER
_RUN_SIGNAL)
rte_pause();
rte_pause();
- rte_atomic16_set(&
slave_state[lcore_id], SLAVE
_RUNNING);
+ rte_atomic16_set(&
lcore_state[lcore_id], WORKER
_RUNNING);
}
static void
}
static void
-
slave
_finish(void)
+
worker
_finish(void)
{
unsigned lcore_id = rte_lcore_id();
{
unsigned lcore_id = rte_lcore_id();
- rte_atomic16_set(&
slave_state[lcore_id], SLAVE
_FINISHED);
+ rte_atomic16_set(&
lcore_state[lcore_id], WORKER
_FINISHED);
}
static volatile int cb_count = 0;
/* callback for second stress test. will only be called
}
static volatile int cb_count = 0;
/* callback for second stress test. will only be called
- * on master lcore */
+ * on main lcore
+ */
static void
timer_stress2_cb(struct rte_timer *tim __rte_unused, void *arg __rte_unused)
{
static void
timer_stress2_cb(struct rte_timer *tim __rte_unused, void *arg __rte_unused)
{
@@
-272,41
+273,41
@@
timer_stress2_cb(struct rte_timer *tim __rte_unused, void *arg __rte_unused)
#define NB_STRESS2_TIMERS 8192
static int
#define NB_STRESS2_TIMERS 8192
static int
-timer_stress2_main_loop(__
attribute__((unused))
void *arg)
+timer_stress2_main_loop(__
rte_unused
void *arg)
{
static struct rte_timer *timers;
int i, ret;
uint64_t delay = rte_get_timer_hz() / 20;
{
static struct rte_timer *timers;
int i, ret;
uint64_t delay = rte_get_timer_hz() / 20;
- unsigned lcore_id = rte_lcore_id();
- unsigned
master = rte_get_master
_lcore();
+ unsigned
int
lcore_id = rte_lcore_id();
+ unsigned
int main_lcore = rte_get_main
_lcore();
int32_t my_collisions = 0;
static rte_atomic32_t collisions;
int32_t my_collisions = 0;
static rte_atomic32_t collisions;
- if (lcore_id == ma
ster
) {
+ if (lcore_id == ma
in_lcore
) {
cb_count = 0;
test_failed = 0;
rte_atomic32_set(&collisions, 0);
cb_count = 0;
test_failed = 0;
rte_atomic32_set(&collisions, 0);
- ma
ster_init_slave
s();
+ ma
in_init_worker
s();
timers = rte_malloc(NULL, sizeof(*timers) * NB_STRESS2_TIMERS, 0);
if (timers == NULL) {
printf("Test Failed\n");
printf("- Cannot allocate memory for timers\n" );
test_failed = 1;
timers = rte_malloc(NULL, sizeof(*timers) * NB_STRESS2_TIMERS, 0);
if (timers == NULL) {
printf("Test Failed\n");
printf("- Cannot allocate memory for timers\n" );
test_failed = 1;
- ma
ster_start_slave
s();
+ ma
in_start_worker
s();
goto cleanup;
}
for (i = 0; i < NB_STRESS2_TIMERS; i++)
rte_timer_init(&timers[i]);
goto cleanup;
}
for (i = 0; i < NB_STRESS2_TIMERS; i++)
rte_timer_init(&timers[i]);
- ma
ster_start_slave
s();
+ ma
in_start_worker
s();
} else {
} else {
-
slave
_wait_to_start();
+
worker
_wait_to_start();
if (test_failed)
goto cleanup;
}
if (test_failed)
goto cleanup;
}
- /* have all cores schedule all timers on ma
ster
lcore */
+ /* have all cores schedule all timers on ma
in
lcore */
for (i = 0; i < NB_STRESS2_TIMERS; i++) {
for (i = 0; i < NB_STRESS2_TIMERS; i++) {
- ret = rte_timer_reset(&timers[i], delay, SINGLE, ma
ster
,
+ ret = rte_timer_reset(&timers[i], delay, SINGLE, ma
in_lcore
,
timer_stress2_cb, NULL);
/* there will be collisions when multiple cores simultaneously
* configure the same timers */
timer_stress2_cb, NULL);
/* there will be collisions when multiple cores simultaneously
* configure the same timers */
@@
-320,14
+321,14
@@
timer_stress2_main_loop(__attribute__((unused)) void *arg)
rte_delay_ms(100);
/* all cores rendezvous */
rte_delay_ms(100);
/* all cores rendezvous */
- if (lcore_id == ma
ster
) {
- ma
ster_wait_for_slave
s();
+ if (lcore_id == ma
in_lcore
) {
+ ma
in_wait_for_worker
s();
} else {
} else {
-
slave
_finish();
+
worker
_finish();
}
/* now check that we get the right number of callbacks */
}
/* now check that we get the right number of callbacks */
- if (lcore_id == ma
ster
) {
+ if (lcore_id == ma
in_lcore
) {
my_collisions = rte_atomic32_read(&collisions);
if (my_collisions != 0)
printf("- %d timer reset collisions (OK)\n", my_collisions);
my_collisions = rte_atomic32_read(&collisions);
if (my_collisions != 0)
printf("- %d timer reset collisions (OK)\n", my_collisions);
@@
-338,23
+339,23
@@
timer_stress2_main_loop(__attribute__((unused)) void *arg)
printf("- Expected %d callbacks, got %d\n", NB_STRESS2_TIMERS,
cb_count);
test_failed = 1;
printf("- Expected %d callbacks, got %d\n", NB_STRESS2_TIMERS,
cb_count);
test_failed = 1;
- ma
ster_start_slave
s();
+ ma
in_start_worker
s();
goto cleanup;
}
cb_count = 0;
/* proceed */
goto cleanup;
}
cb_count = 0;
/* proceed */
- ma
ster_start_slave
s();
+ ma
in_start_worker
s();
} else {
/* proceed */
} else {
/* proceed */
-
slave
_wait_to_start();
+
worker
_wait_to_start();
if (test_failed)
goto cleanup;
}
/* now test again, just stop and restart timers at random after init*/
for (i = 0; i < NB_STRESS2_TIMERS; i++)
if (test_failed)
goto cleanup;
}
/* now test again, just stop and restart timers at random after init*/
for (i = 0; i < NB_STRESS2_TIMERS; i++)
- rte_timer_reset(&timers[i], delay, SINGLE, ma
ster
,
+ rte_timer_reset(&timers[i], delay, SINGLE, ma
in_lcore
,
timer_stress2_cb, NULL);
/* pick random timer to reset, stopping them first half the time */
timer_stress2_cb, NULL);
/* pick random timer to reset, stopping them first half the time */
@@
-362,7
+363,7
@@
timer_stress2_main_loop(__attribute__((unused)) void *arg)
int r = rand() % NB_STRESS2_TIMERS;
if (i % 2)
rte_timer_stop(&timers[r]);
int r = rand() % NB_STRESS2_TIMERS;
if (i % 2)
rte_timer_stop(&timers[r]);
- rte_timer_reset(&timers[r], delay, SINGLE, ma
ster
,
+ rte_timer_reset(&timers[r], delay, SINGLE, ma
in_lcore
,
timer_stress2_cb, NULL);
}
timer_stress2_cb, NULL);
}
@@
-370,8
+371,8
@@
timer_stress2_main_loop(__attribute__((unused)) void *arg)
rte_delay_ms(100);
/* now check that we get the right number of callbacks */
rte_delay_ms(100);
/* now check that we get the right number of callbacks */
- if (lcore_id == ma
ster
) {
- ma
ster_wait_for_slave
s();
+ if (lcore_id == ma
in_lcore
) {
+ ma
in_wait_for_worker
s();
rte_timer_manage();
if (cb_count != NB_STRESS2_TIMERS) {
rte_timer_manage();
if (cb_count != NB_STRESS2_TIMERS) {
@@
-386,14
+387,14
@@
timer_stress2_main_loop(__attribute__((unused)) void *arg)
}
cleanup:
}
cleanup:
- if (lcore_id == ma
ster
) {
- ma
ster_wait_for_slave
s();
+ if (lcore_id == ma
in_lcore
) {
+ ma
in_wait_for_worker
s();
if (timers != NULL) {
rte_free(timers);
timers = NULL;
}
} else {
if (timers != NULL) {
rte_free(timers);
timers = NULL;
}
} else {
-
slave
_finish();
+
worker
_finish();
}
return 0;
}
return 0;
@@
-457,7
+458,7
@@
timer_basic_cb(struct rte_timer *tim, void *arg)
}
static int
}
static int
-timer_basic_main_loop(__
attribute__((unused))
void *arg)
+timer_basic_main_loop(__
rte_unused
void *arg)
{
uint64_t hz = rte_get_timer_hz();
unsigned lcore_id = rte_lcore_id();
{
uint64_t hz = rte_get_timer_hz();
unsigned lcore_id = rte_lcore_id();
@@
-465,7
+466,7
@@
timer_basic_main_loop(__attribute__((unused)) void *arg)
int64_t diff = 0;
/* launch all timers on core 0 */
int64_t diff = 0;
/* launch all timers on core 0 */
- if (lcore_id == rte_get_ma
ster
_lcore()) {
+ if (lcore_id == rte_get_ma
in
_lcore()) {
mytimer_reset(&mytiminfo[0], hz/4, SINGLE, lcore_id,
timer_basic_cb);
mytimer_reset(&mytiminfo[1], hz/2, SINGLE, lcore_id,
mytimer_reset(&mytiminfo[0], hz/4, SINGLE, lcore_id,
timer_basic_cb);
mytimer_reset(&mytiminfo[1], hz/2, SINGLE, lcore_id,
@@
-563,7
+564,7
@@
test_timer(void)
/* start other cores */
printf("Start timer stress tests\n");
/* start other cores */
printf("Start timer stress tests\n");
- rte_eal_mp_remote_launch(timer_stress_main_loop, NULL, CALL_MA
STER
);
+ rte_eal_mp_remote_launch(timer_stress_main_loop, NULL, CALL_MA
IN
);
rte_eal_mp_wait_lcore();
/* stop timer 0 used for stress test */
rte_eal_mp_wait_lcore();
/* stop timer 0 used for stress test */
@@
-572,7
+573,7
@@
test_timer(void)
/* run a second, slightly different set of stress tests */
printf("\nStart timer stress tests 2\n");
test_failed = 0;
/* run a second, slightly different set of stress tests */
printf("\nStart timer stress tests 2\n");
test_failed = 0;
- rte_eal_mp_remote_launch(timer_stress2_main_loop, NULL, CALL_MA
STER
);
+ rte_eal_mp_remote_launch(timer_stress2_main_loop, NULL, CALL_MA
IN
);
rte_eal_mp_wait_lcore();
if (test_failed)
return TEST_FAILED;
rte_eal_mp_wait_lcore();
if (test_failed)
return TEST_FAILED;
@@
-584,7
+585,7
@@
test_timer(void)
/* start other cores */
printf("\nStart timer basic tests\n");
/* start other cores */
printf("\nStart timer basic tests\n");
- rte_eal_mp_remote_launch(timer_basic_main_loop, NULL, CALL_MA
STER
);
+ rte_eal_mp_remote_launch(timer_basic_main_loop, NULL, CALL_MA
IN
);
rte_eal_mp_wait_lcore();
/* stop all timers */
rte_eal_mp_wait_lcore();
/* stop all timers */