From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 95FFD6882 for ; Fri, 23 May 2014 16:44:10 +0200 (CEST) Received: from was59-1-82-226-113-214.fbx.proxad.net ([82.226.113.214] helo=[192.168.0.10]) by mail.droids-corp.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1WnqjR-0005qv-Iv; Fri, 23 May 2014 16:46:09 +0200 Message-ID: <537F5EC8.70109@6wind.com> Date: Fri, 23 May 2014 16:44:24 +0200 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.4.0 MIME-Version: 1.0 To: Vadim Suraev , dev@dpdk.org References: <1400704555-18818-1-git-send-email-vadim.suraev@gmail.com> In-Reply-To: <1400704555-18818-1-git-send-email-vadim.suraev@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] timer bug fix. 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: Fri, 23 May 2014 14:44:10 -0000 Acked-by: Olivier Matz On 05/21/2014 10:35 PM, Vadim Suraev wrote: > Bug: When a timer is running > - if rte_timer_stop is called, the pending decrement is > skipped (decremented only if the timer is pending) and due > to the update flag the future processing is skipped so the > timer is counted as pending while it is stopped. - the same > applies when rte_timer_reset is called but then the pending > statistics is additionally incremented so the timer is > counted pending twice. > Solution: decrement the pending > statistics after returning from the callback. If > rte_timer_stop was called, it skipped decrementing the > pending statistics. If rte_time_reset was called, the > pending statistics was incremented. If neither was called > and the timer is periodic, the pending statistics is > incremented when it is reloaded > > > Signed-off-by: Vadim Suraev > --- > lib/librte_timer/rte_timer.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c > index 1ebd223..7035bed 100755 > --- a/lib/librte_timer/rte_timer.c > +++ b/lib/librte_timer/rte_timer.c > @@ -551,7 +551,7 @@ void rte_timer_manage(void) > tim->f(tim, tim->arg); > > rte_spinlock_lock(&priv_timer[lcore_id].list_lock); > - > + __TIMER_STAT_ADD(pending, -1); > /* the timer was stopped or reloaded by the callback > * function, we have nothing to do here */ > if (priv_timer[lcore_id].updated == 1) > @@ -559,7 +559,6 @@ void rte_timer_manage(void) > > if (tim->period == 0) { > /* remove from done list and mark timer as stopped */ > - __TIMER_STAT_ADD(pending, -1); > status.state = RTE_TIMER_STOP; > status.owner = RTE_TIMER_NO_OWNER; > rte_wmb(); > @@ -568,6 +567,7 @@ void rte_timer_manage(void) > else { > /* keep it in list and mark timer as pending */ > status.state = RTE_TIMER_PENDING; > + __TIMER_STAT_ADD(pending, 1); > status.owner = (int16_t)lcore_id; > rte_wmb(); > tim->status.u32 = status.u32; >