From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ie0-f178.google.com (mail-ie0-f178.google.com [209.85.223.178]) by dpdk.org (Postfix) with ESMTP id 8F7A3AD7F for ; Wed, 25 Feb 2015 05:10:16 +0100 (CET) Received: by iebtr6 with SMTP id tr6so1822157ieb.7 for ; Tue, 24 Feb 2015 20:10:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b4GDi2Am925x6UTawG5U4pxQaPbE1uAD/oAHhuGpSE4=; b=NeFL+TzwwGNFCKuIakXX3Q9MDLZkQMT6J4+cMsrFv/WSFVp/7FOOt9vgFAj+A8F6hZ reVHwNZCadQuJi3YVavv1mLOlghpbn+Dmnsj/y95cOO5IlO3zueNRm0rpOzGTN3NLYu8 0dfEMzBkf8om6bL0rvlM/VLxRLUuo7k22Oz0ip1wB8Pch6N+ae9aWOAXG3I2N9eVTucf H7g5GA3iKGK7F/ONDg/kRZeLgXOxDcijKDBlby5bmtsKbLt3qHuolPehfQzY/GhW607U bZTrdpbPOh4F+pN4+EEr+2LktmNy02fQFbpy9VUDPU+DW1szom139+M8Ptsy3hcgGvX4 rbRg== X-Received: by 10.50.124.73 with SMTP id mg9mr2164581igb.38.1424837416163; Tue, 24 Feb 2015 20:10:16 -0800 (PST) Received: from localhost.localdomain (adsl-065-013-043-223.sip.mia.bellsouth.net. [65.13.43.223]) by mx.google.com with ESMTPSA id m38sm25067554ioi.39.2015.02.24.20.10.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 20:10:15 -0800 (PST) From: Robert Sanford To: dev@dpdk.org Date: Tue, 24 Feb 2015 23:09:49 -0500 Message-Id: <1424837389-56276-4-git-send-email-rsanford2@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1422996127-64370-1-git-send-email-rsanford2@gmail.com> References: <1422996127-64370-1-git-send-email-rsanford2@gmail.com> Subject: [dpdk-dev] [PATCH v2 3/3] timer: fix rte_timer_reset return value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Feb 2015 04:10:17 -0000 - API rte_timer_reset() should return -1 when the timer is in the RUNNING or CONFIG state. Instead, it ignores the return value of internal function __rte_timer_reset() and always returns 0. We change rte_timer_reset() to return the value returned by __rte_timer_reset(). - Enhance timer stress test 2 to report how many timer reset collisions occur, i.e., how many times rte_timer_reset() fails due to a timer being in the CONFIG state. Signed-off-by: Robert Sanford --- app/test/test_timer.c | 19 ++++++++++++++++--- lib/librte_timer/rte_timer.c | 4 +--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/test/test_timer.c b/app/test/test_timer.c index 070437a..79fa955 100644 --- a/app/test/test_timer.c +++ b/app/test/test_timer.c @@ -247,10 +247,12 @@ static int timer_stress2_main_loop(__attribute__((unused)) void *arg) { static struct rte_timer *timers; - int i; + int i, ret; static volatile int ready = 0; uint64_t delay = rte_get_timer_hz() / 4; unsigned lcore_id = rte_lcore_id(); + int32_t my_collisions = 0; + static rte_atomic32_t collisions = RTE_ATOMIC32_INIT(0); if (lcore_id == rte_get_master_lcore()) { cb_count = 0; @@ -269,15 +271,25 @@ timer_stress2_main_loop(__attribute__((unused)) void *arg) } /* have all cores schedule all timers on master lcore */ - for (i = 0; i < NB_STRESS2_TIMERS; i++) - rte_timer_reset(&timers[i], delay, SINGLE, rte_get_master_lcore(), + for (i = 0; i < NB_STRESS2_TIMERS; i++) { + ret = rte_timer_reset(&timers[i], delay, SINGLE, rte_get_master_lcore(), timer_stress2_cb, NULL); + /* there will be collisions when multiple cores simultaneously + * configure the same timers */ + if (ret != 0) + my_collisions++; + } + if (my_collisions != 0) + rte_atomic32_add(&collisions, my_collisions); ready = 0; rte_delay_ms(500); /* now check that we get the right number of callbacks */ if (lcore_id == rte_get_master_lcore()) { + my_collisions = rte_atomic32_read(&collisions); + if (my_collisions != 0) + printf("- %d timer reset collisions (OK)\n", my_collisions); rte_timer_manage(); if (cb_count != NB_STRESS2_TIMERS) { printf("Test Failed\n"); @@ -317,6 +329,7 @@ timer_stress2_main_loop(__attribute__((unused)) void *arg) rte_free(timers); timers = NULL; ready = 0; + rte_atomic32_set(&collisions, 0); if (cb_count != NB_STRESS2_TIMERS) { printf("Test Failed\n"); diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index dae76cc..d18abf5 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -424,10 +424,8 @@ rte_timer_reset(struct rte_timer *tim, uint64_t ticks, else period = 0; - __rte_timer_reset(tim, cur_time + ticks, period, tim_lcore, + return __rte_timer_reset(tim, cur_time + ticks, period, tim_lcore, fct, arg, 0); - - return 0; } /* loop until rte_timer_reset() succeed */ -- 1.7.1