From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by dpdk.org (Postfix) with ESMTP id 232D1593A for ; Fri, 23 May 2014 21:43:08 +0200 (CEST) Received: by mail-wi0-f170.google.com with SMTP id bs8so1564040wib.3 for ; Fri, 23 May 2014 12:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=fuwZBvTXOFt8l0I7tjOfnOU7gI2q+9umPau2HI3Di+o=; b=xcbY1MtiJWg5O/B9nO7jxx2cNOHpf2RKFnd6xuPJct95fozCoCGZ9H0Hl7RDKb2yqW CH80Dhw6DwMqR0A2whQNEZpIunq2D4byofCPO23WUZIoFzbVW2ESiNMJIXJ4pQcfg/JS X3HZJ1fqq+SEmXn/bor4IGlScNgnweiJH0BSDA8cEyCevPAbjS2vP6423F9xcA1gSQHx hO1QWhOLnw8Xe76iHg3NtSBDBoVIodLgg7EGcpVgImAyd96JvhnKHA/7tCj7tsXysvLy lb3eVm9CIc5z1C82WR49wC0taF/RtOz3x2C+oRJDon6U5SgcKisUY7E9OtVyHUoCLqE9 PeKw== X-Received: by 10.194.8.170 with SMTP id s10mr6193493wja.6.1400874198103; Fri, 23 May 2014 12:43:18 -0700 (PDT) Received: from ubuntu.ubuntu-domain ([109.66.146.135]) by mx.google.com with ESMTPSA id m5sm4464707wie.23.2014.05.23.12.43.16 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 12:43:17 -0700 (PDT) From: Vadim Suraev To: dev@dpdk.org Date: Fri, 23 May 2014 22:43:04 +0300 Message-Id: <1400874184-15818-3-git-send-email-vadim.suraev@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1400874184-15818-1-git-send-email-vadim.suraev@gmail.com> References: <1400874184-15818-1-git-send-email-vadim.suraev@gmail.com> Subject: [dpdk-dev] [PATCH 2/2] 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 19:43:08 -0000 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 d07232b..f0f0c2f 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; -- 1.7.9.5