From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DE8E3A00C2 for ; Thu, 3 Nov 2022 10:31:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D4C3D40694; Thu, 3 Nov 2022 10:31:38 +0100 (CET) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by mails.dpdk.org (Postfix) with ESMTP id 3B72B40694 for ; Thu, 3 Nov 2022 10:31:38 +0100 (CET) Received: by mail-wm1-f41.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso2861238wme.5 for ; Thu, 03 Nov 2022 02:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JUtjJbk42Qf/VDPOgPgsD+cnsakYherzaqdjK2gd0YI=; b=dElEZ5d1bYRpMCSlnMfC6kQwU2MFCOOQbDOPnxlEnczibExbMeIkfIbB/5mVom1cUL 44FlqojT3SCiFBTDZW+CGXoRyZifhexmZ6/ddgyLKhNnXoSmiaLxCdPLZN47+FIrLZyI I83aAWBMITdRASmoct4hE286wpWo0Gmjw029AKv2jaoCrGMd2Es5ASK0NQ0n39nrByQC K+3kaVXFLTjYpIiQ4LKK4qlQfyM1peluOUlbSz2HsYprYboNj4hoYKoVpVJJ0q7yz9nX /jqd68oK/Wt2TOe0ZJMVCWGWZQtcZi3/+bERPaQ4WpnFuO+zJzKozbsKbAf8NrPTfXrd tHCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JUtjJbk42Qf/VDPOgPgsD+cnsakYherzaqdjK2gd0YI=; b=kwv4yFFA88bF7X0UtrmxAEY1cUW+5AxI5CHMaIPLR+Bt+3fV8ySRjBz50PFEKy9vCE os44/a2XCewND+9zJGak4aipqQaFnzyRFk5TckfhYta+9AOPPwgafxJfJr0Xcq0kfet2 CexH/5ImB3v+klnjaYYeVEHJEIzea1EUH2jSGlcPWn586gNimSbXKob3a/Dz9CG3kj4L RpgvXyRAlLgZISLwodV8OYqdl+XX0jTSTUiTISRs2ahGLAK4fd1W8nj367JuQt6pQquN qFt293whpvvzW9cqqBZDHzD4Iwh+tQdiywJUsqutk7tszIBKIAoE6o3pUAF1Cgk+1B5c dK/w== X-Gm-Message-State: ACrzQf3h5IQyv3dIW7T+d7kWuN5bamdCVXP0iYa0t0XhaP5RLkQsQDFA VmdAtDn+0bOgCmW4Y3IO+80CkjY5LDkvltZx X-Google-Smtp-Source: AMsMyM6zA6cPsCBDCHLtdH/2jHG9fus38T3b2eK51hIpHKCCrsBs/w0psUoDvIuxMDlabKcGEbi7Bg== X-Received: by 2002:a05:600c:a4c:b0:3b4:fc1b:81 with SMTP id c12-20020a05600c0a4c00b003b4fc1b0081mr18388819wmq.125.1667467897964; Thu, 03 Nov 2022 02:31:37 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id e19-20020a05600c4e5300b003b49ab8ff53sm671952wmq.8.2022.11.03.02.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 02:31:37 -0700 (PDT) From: luca.boccassi@gmail.com To: Naga Harish K S V Cc: Erik Gabriel Carrillo , dpdk stable Subject: patch 'timer: fix stopping all timers' has been queued to stable release 20.11.7 Date: Thu, 3 Nov 2022 09:27:23 +0000 Message-Id: <20221103092758.1099402-65-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221103092758.1099402-1-luca.boccassi@gmail.com> References: <20221103092758.1099402-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 20.11.7 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/05/22. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/75564c250f61a4ab069c6eb8b95a9f1206e5efc3 Thanks. Luca Boccassi --- >From 75564c250f61a4ab069c6eb8b95a9f1206e5efc3 Mon Sep 17 00:00:00 2001 From: Naga Harish K S V Date: Wed, 14 Sep 2022 10:33:18 -0500 Subject: [PATCH] timer: fix stopping all timers [ upstream commit eb63c85d7bae32fdc1cbafcd91e88bd6515c39cf ] There is a possibility of deadlock in this API, as same spinlock is tried to be acquired in nested manner. If the lcore that is stopping the timer is different from the lcore that owns the timer, the timer list lock is acquired in timer_del(), even if local_is_locked is true. Because the same lock was already acquired in rte_timer_stop_all(), the thread will hang. This patch removes the acquisition of nested lock. Fixes: 821c51267bcd63a ("timer: add function to stop all timers in a list") Signed-off-by: Naga Harish K S V Acked-by: Erik Gabriel Carrillo --- lib/librte_timer/rte_timer.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index 6d19ce469b..98c1941cb1 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -587,7 +587,7 @@ rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks, } static int -__rte_timer_stop(struct rte_timer *tim, int local_is_locked, +__rte_timer_stop(struct rte_timer *tim, struct rte_timer_data *timer_data) { union rte_timer_status prev_status, status; @@ -609,7 +609,7 @@ __rte_timer_stop(struct rte_timer *tim, int local_is_locked, /* remove it from list */ if (prev_status.state == RTE_TIMER_PENDING) { - timer_del(tim, prev_status, local_is_locked, priv_timer); + timer_del(tim, prev_status, 0, priv_timer); __TIMER_STAT_ADD(priv_timer, pending, -1); } @@ -638,7 +638,7 @@ rte_timer_alt_stop(uint32_t timer_data_id, struct rte_timer *tim) TIMER_DATA_VALID_GET_OR_ERR_RET(timer_data_id, timer_data, -EINVAL); - return __rte_timer_stop(tim, 0, timer_data); + return __rte_timer_stop(tim, timer_data); } /* loop until rte_timer_stop() succeed */ @@ -994,21 +994,16 @@ rte_timer_stop_all(uint32_t timer_data_id, unsigned int *walk_lcores, walk_lcore = walk_lcores[i]; priv_timer = &timer_data->priv_timer[walk_lcore]; - rte_spinlock_lock(&priv_timer->list_lock); - for (tim = priv_timer->pending_head.sl_next[0]; tim != NULL; tim = next_tim) { next_tim = tim->sl_next[0]; - /* Call timer_stop with lock held */ - __rte_timer_stop(tim, 1, timer_data); + __rte_timer_stop(tim, timer_data); if (f) f(tim, f_arg); } - - rte_spinlock_unlock(&priv_timer->list_lock); } return 0; -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-11-03 09:27:29.301470562 +0000 +++ 0065-timer-fix-stopping-all-timers.patch 2022-11-03 09:27:25.485424608 +0000 @@ -1 +1 @@ -From eb63c85d7bae32fdc1cbafcd91e88bd6515c39cf Mon Sep 17 00:00:00 2001 +From 75564c250f61a4ab069c6eb8b95a9f1206e5efc3 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit eb63c85d7bae32fdc1cbafcd91e88bd6515c39cf ] + @@ -17 +18,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ - lib/timer/rte_timer.c | 13 ++++--------- + lib/librte_timer/rte_timer.c | 13 ++++--------- @@ -25,5 +26,5 @@ -diff --git a/lib/timer/rte_timer.c b/lib/timer/rte_timer.c -index 9994813d0d..85d67573eb 100644 ---- a/lib/timer/rte_timer.c -+++ b/lib/timer/rte_timer.c -@@ -580,7 +580,7 @@ rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks, +diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c +index 6d19ce469b..98c1941cb1 100644 +--- a/lib/librte_timer/rte_timer.c ++++ b/lib/librte_timer/rte_timer.c +@@ -587,7 +587,7 @@ rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks, @@ -38 +39 @@ -@@ -602,7 +602,7 @@ __rte_timer_stop(struct rte_timer *tim, int local_is_locked, +@@ -609,7 +609,7 @@ __rte_timer_stop(struct rte_timer *tim, int local_is_locked, @@ -47 +48 @@ -@@ -631,7 +631,7 @@ rte_timer_alt_stop(uint32_t timer_data_id, struct rte_timer *tim) +@@ -638,7 +638,7 @@ rte_timer_alt_stop(uint32_t timer_data_id, struct rte_timer *tim) @@ -56 +57 @@ -@@ -987,21 +987,16 @@ rte_timer_stop_all(uint32_t timer_data_id, unsigned int *walk_lcores, +@@ -994,21 +994,16 @@ rte_timer_stop_all(uint32_t timer_data_id, unsigned int *walk_lcores,