diff mbox

performance: l2fwd: obey -t in queue mode

Message ID 1441886116-31863-1-git-send-email-stuart.haslam@linaro.org
State Accepted
Commit 064af297d4614368769c204acf610ea185588c7a
Headers show

Commit Message

Stuart Haslam Sept. 10, 2015, 11:55 a.m. UTC
The -t command line argument specifies the length of time the application
should run before exiting, but this doesn't always work in queue mode as
the odp_schedule() call may not return if no packets are received.

Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
---
 test/performance/odp_l2fwd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Stuart Haslam Oct. 14, 2015, 12:35 p.m. UTC | #1
Can someone review this?

On 10 September 2015 at 12:55, Stuart Haslam <stuart.haslam@linaro.org>
wrote:

> The -t command line argument specifies the length of time the application
> should run before exiting, but this doesn't always work in queue mode as
> the odp_schedule() call may not return if no packets are received.
>
> Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
> ---
>  test/performance/odp_l2fwd.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
> index 64fc1b2..75e5cb8 100644
> --- a/test/performance/odp_l2fwd.c
> +++ b/test/performance/odp_l2fwd.c
> @@ -131,6 +131,7 @@ static void *pktio_queue_thread(void *arg)
>         odp_packet_t pkt;
>         odp_event_t ev;
>         thread_args_t *thr_args = arg;
> +       uint64_t wait;
>
>         stats_t *stats = calloc(1, sizeof(stats_t));
>         *thr_args->stats = stats;
> @@ -140,10 +141,14 @@ static void *pktio_queue_thread(void *arg)
>         printf("[%02i] QUEUE mode\n", thr);
>         odp_barrier_wait(&barrier);
>
> +       wait = odp_schedule_wait_time(ODP_TIME_MSEC * 100);
> +
>         /* Loop packets */
>         while (!exit_threads) {
>                 /* Use schedule to get buf from any input queue */
> -               ev  = odp_schedule(NULL, ODP_SCHED_WAIT);
> +               ev  = odp_schedule(NULL, wait);
> +               if (ev == ODP_EVENT_INVALID)
> +                       continue;
>                 pkt = odp_packet_from_event(ev);
>
>                 /* Drop packets with errors */
> --
> 2.1.1
>
>
Maxim Uvarov Oct. 14, 2015, 12:59 p.m. UTC | #2
looks good for me.

Maxim.

On 10/14/2015 15:35, Stuart Haslam wrote:
> Can someone review this?
>
> On 10 September 2015 at 12:55, Stuart Haslam <stuart.haslam@linaro.org 
> <mailto:stuart.haslam@linaro.org>> wrote:
>
>     The -t command line argument specifies the length of time the
>     application
>     should run before exiting, but this doesn't always work in queue
>     mode as
>     the odp_schedule() call may not return if no packets are received.
>
>     Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org
>     <mailto:stuart.haslam@linaro.org>>
>     ---
>      test/performance/odp_l2fwd.c | 7 ++++++-
>      1 file changed, 6 insertions(+), 1 deletion(-)
>
>     diff --git a/test/performance/odp_l2fwd.c
>     b/test/performance/odp_l2fwd.c
>     index 64fc1b2..75e5cb8 100644
>     --- a/test/performance/odp_l2fwd.c
>     +++ b/test/performance/odp_l2fwd.c
>     @@ -131,6 +131,7 @@ static void *pktio_queue_thread(void *arg)
>             odp_packet_t pkt;
>             odp_event_t ev;
>             thread_args_t *thr_args = arg;
>     +       uint64_t wait;
>
>             stats_t *stats = calloc(1, sizeof(stats_t));
>             *thr_args->stats = stats;
>     @@ -140,10 +141,14 @@ static void *pktio_queue_thread(void *arg)
>             printf("[%02i] QUEUE mode\n", thr);
>             odp_barrier_wait(&barrier);
>
>     +       wait = odp_schedule_wait_time(ODP_TIME_MSEC * 100);
>     +
>             /* Loop packets */
>             while (!exit_threads) {
>                     /* Use schedule to get buf from any input queue */
>     -               ev  = odp_schedule(NULL, ODP_SCHED_WAIT);
>     +               ev  = odp_schedule(NULL, wait);
>     +               if (ev == ODP_EVENT_INVALID)
>     +                       continue;
>                     pkt = odp_packet_from_event(ev);
>
>                     /* Drop packets with errors */
>     --
>     2.1.1
>
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
Maxim Uvarov Oct. 15, 2015, 9:05 a.m. UTC | #3
Merged,

changed short description to test/performance to be clear that it's for 
tests.

Maxim.

On 09/10/2015 14:55, Stuart Haslam wrote:
> The -t command line argument specifies the length of time the application
> should run before exiting, but this doesn't always work in queue mode as
> the odp_schedule() call may not return if no packets are received.
>
> Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
> ---
>   test/performance/odp_l2fwd.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
> index 64fc1b2..75e5cb8 100644
> --- a/test/performance/odp_l2fwd.c
> +++ b/test/performance/odp_l2fwd.c
> @@ -131,6 +131,7 @@ static void *pktio_queue_thread(void *arg)
>   	odp_packet_t pkt;
>   	odp_event_t ev;
>   	thread_args_t *thr_args = arg;
> +	uint64_t wait;
>   
>   	stats_t *stats = calloc(1, sizeof(stats_t));
>   	*thr_args->stats = stats;
> @@ -140,10 +141,14 @@ static void *pktio_queue_thread(void *arg)
>   	printf("[%02i] QUEUE mode\n", thr);
>   	odp_barrier_wait(&barrier);
>   
> +	wait = odp_schedule_wait_time(ODP_TIME_MSEC * 100);
> +
>   	/* Loop packets */
>   	while (!exit_threads) {
>   		/* Use schedule to get buf from any input queue */
> -		ev  = odp_schedule(NULL, ODP_SCHED_WAIT);
> +		ev  = odp_schedule(NULL, wait);
> +		if (ev == ODP_EVENT_INVALID)
> +			continue;
>   		pkt = odp_packet_from_event(ev);
>   
>   		/* Drop packets with errors */
diff mbox

Patch

diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 64fc1b2..75e5cb8 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -131,6 +131,7 @@  static void *pktio_queue_thread(void *arg)
 	odp_packet_t pkt;
 	odp_event_t ev;
 	thread_args_t *thr_args = arg;
+	uint64_t wait;
 
 	stats_t *stats = calloc(1, sizeof(stats_t));
 	*thr_args->stats = stats;
@@ -140,10 +141,14 @@  static void *pktio_queue_thread(void *arg)
 	printf("[%02i] QUEUE mode\n", thr);
 	odp_barrier_wait(&barrier);
 
+	wait = odp_schedule_wait_time(ODP_TIME_MSEC * 100);
+
 	/* Loop packets */
 	while (!exit_threads) {
 		/* Use schedule to get buf from any input queue */
-		ev  = odp_schedule(NULL, ODP_SCHED_WAIT);
+		ev  = odp_schedule(NULL, wait);
+		if (ev == ODP_EVENT_INVALID)
+			continue;
 		pkt = odp_packet_from_event(ev);
 
 		/* Drop packets with errors */