From patchwork Fri Apr 26 14:41:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Carrillo, Erik G" X-Patchwork-Id: 53102 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 78FDA1B6CA; Fri, 26 Apr 2019 16:42:42 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 865331B691 for ; Fri, 26 Apr 2019 16:42:40 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2019 07:42:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,397,1549958400"; d="scan'208";a="153999487" Received: from txasoft-yocto.an.intel.com ([10.123.72.192]) by orsmga002.jf.intel.com with ESMTP; 26 Apr 2019 07:42:38 -0700 From: Erik Gabriel Carrillo To: rsanford@akamai.com, thomas@monjalon.net Cc: dev@dpdk.org Date: Fri, 26 Apr 2019 09:41:24 -0500 Message-Id: <1556289684-11276-1-git-send-email-erik.g.carrillo@intel.com> X-Mailer: git-send-email 1.7.10 Subject: [dpdk-dev] [PATCH] timer: fix reset/stop in callback for new API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The rte_timer_alt_manage function should track which is the running timer and whether or not it was updated by a callback in the priv_timer structure that corresponds to the running lcore, so that restarting or stopping the timer from the callback works correctly. Fixes: c0749f7096c7 ("timer: allow management in shared memory") Signed-off-by: Erik Gabriel Carrillo --- lib/librte_timer/rte_timer.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index d443b8c..9f2e921 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -830,7 +830,6 @@ rte_timer_alt_manage(uint32_t timer_data_id, union rte_timer_status status; struct rte_timer *tim, *next_tim, **pprev; struct rte_timer *run_first_tims[RTE_MAX_LCORE]; - unsigned int runlist_lcore_ids[RTE_MAX_LCORE]; unsigned int this_lcore = rte_lcore_id(); struct rte_timer *prev[MAX_SKIPLIST_DEPTH + 1]; uint64_t cur_time; @@ -899,7 +898,6 @@ rte_timer_alt_manage(uint32_t timer_data_id, /* transition run-list from PENDING to RUNNING */ run_first_tims[nb_runlists] = tim; - runlist_lcore_ids[nb_runlists] = poll_lcore; pprev = &run_first_tims[nb_runlists]; nb_runlists++; @@ -946,25 +944,24 @@ rte_timer_alt_manage(uint32_t timer_data_id, break; tim = run_first_tims[min_idx]; - privp = &data->priv_timer[runlist_lcore_ids[min_idx]]; /* Move down the runlist from which we picked a timer to * execute */ run_first_tims[min_idx] = run_first_tims[min_idx]->sl_next[0]; - privp->updated = 0; - privp->running_tim = tim; + data->priv_timer[this_lcore].updated = 0; + data->priv_timer[this_lcore].running_tim = tim; /* Call the provided callback function */ f(tim); - __TIMER_STAT_ADD(privp, pending, -1); + __TIMER_STAT_ADD(data->priv_timer, pending, -1); /* the timer was stopped or reloaded by the callback * function, we have nothing to do here */ - if (privp->updated == 1) + if (data->priv_timer[this_lcore].updated == 1) continue; if (tim->period == 0) { @@ -989,7 +986,7 @@ rte_timer_alt_manage(uint32_t timer_data_id, &data->priv_timer[this_lcore].list_lock); } - privp->running_tim = NULL; + data->priv_timer[this_lcore].running_tim = NULL; } return 0;