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 83AA4A0544 for ; Fri, 11 Nov 2022 12:40:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7E6F3410F2; Fri, 11 Nov 2022 12:40:44 +0100 (CET) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by mails.dpdk.org (Postfix) with ESMTP id 7551742D0C for ; Fri, 11 Nov 2022 12:40:43 +0100 (CET) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 4379742240 for ; Fri, 11 Nov 2022 11:40:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1668166843; bh=L1N9riXeFnlZyUnZx8pNp/WeX99y/Z5oXAqhLJ7uJhY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L3J9skDpC85OY5c07jYBDtYWJDXAWEjw/cL0stAFWg3ODHFdSLQznfYLSlJMW5dN+ iXZx8SIxh1bsnGD+cWujoE2TrkJJOd8KHGM43Brps9rLVbXdj5BILxgierv1L4gWd5 v4r/Mp3JW8SBdS55zXFn+PhL4bdfloVe+xGtyPoN+XikjIVgPTOi8M4MuDTCdSAufs dNCWt7ik79ilT0mC4lVoRXeS0cS9pKFM75fsw/wdOucZMda2gW2WaH6gyMizgfDGhY 9ikeTz9ag2VfAopqeHvZ+ELjuHUS93dQwRS9g3GBn7UwxvnqYXGIFuWwHZECbzhAlH kGx3NFGHMjhGg== Received: by mail-ed1-f71.google.com with SMTP id s15-20020a056402520f00b0046321fff42dso3448992edd.0 for ; Fri, 11 Nov 2022 03:40:43 -0800 (PST) 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=L1N9riXeFnlZyUnZx8pNp/WeX99y/Z5oXAqhLJ7uJhY=; b=4GtRMwNtBE8I1S62B+PcD8FP9WHUAyw/rJ5UmCzkv/V20jK1YlSpWwEWY+quXP848T xSAUlRaReiJZ2vIhj/x5eOSgBDwxODMkdagIBElimVGOfqwzBQ3nrqkzcsnFZoDbp0pc CnteHWbZ/DPMbbYbQQSSZxS/6kq6JPAMwPqv7SnjRIB2Gm9qHfpePlum+7k648IfvSpN fceLvSfMOKkVZDnL16E+n6mJ3oXjguK4XvU8hRn4UJkBHEHhvjZyEPWcikY0kiZH3dsr g7DtaawAZ+VeGAz4C4+Ohvzz67drnri4KVEJ3nJwTnphuhes28DHpWG3OWRseMnufk70 YoXg== X-Gm-Message-State: ANoB5plFvFKxmjgTGsnZTJuE26aCqofM9p/OQbrurSVrnfjgGSl9BV4u VvF/0CrGqw/qCdJiMOKuo2B1e67fw9OVyQAQIULIiyLJjNeHMQugZZvphnZ2cxq06QCd/KjFerk HeqWMz1o0EB1UyJeXJLR5z7iK X-Received: by 2002:a17:906:5156:b0:7ad:db82:d071 with SMTP id jr22-20020a170906515600b007addb82d071mr1616056ejc.200.1668166842914; Fri, 11 Nov 2022 03:40:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf69bLJpQZSE68eFpEp4UU+I1UUGZfabmDDTkgRKK44hT4VZb2rGmasLQQfydnX/fiTE4iH7Lw== X-Received: by 2002:a17:906:5156:b0:7ad:db82:d071 with SMTP id jr22-20020a170906515600b007addb82d071mr1616042ejc.200.1668166842630; Fri, 11 Nov 2022 03:40:42 -0800 (PST) Received: from localhost.localdomain ([2a02:6d40:39af:c100:1891:6c61:50fd:e567]) by smtp.gmail.com with ESMTPSA id r19-20020a170906a21300b007ad96726c42sm803553ejy.91.2022.11.11.03.40.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 03:40:41 -0800 (PST) From: christian.ehrhardt@canonical.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 19.11.14 Date: Fri, 11 Nov 2022 12:38:46 +0100 Message-Id: <20221111113904.1549618-29-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221111113904.1549618-1-christian.ehrhardt@canonical.com> References: <20221111113904.1549618-1-christian.ehrhardt@canonical.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 19.11.14 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/18/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/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/5915ced554f186a3e9397ca32c368a7535ef4adb Thanks. Christian Ehrhardt --- >From 5915ced554f186a3e9397ca32c368a7535ef4adb 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 99862a3ba1..7ea27f9878 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -573,7 +573,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; @@ -595,7 +595,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); } @@ -622,7 +622,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 */ @@ -961,21 +961,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.38.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-11-11 12:35:05.814217310 +0100 +++ 0029-timer-fix-stopping-all-timers.patch 2022-11-11 12:35:04.773192062 +0100 @@ -1 +1 @@ -From eb63c85d7bae32fdc1cbafcd91e88bd6515c39cf Mon Sep 17 00:00:00 2001 +From 5915ced554f186a3e9397ca32c368a7535ef4adb 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 99862a3ba1..7ea27f9878 100644 +--- a/lib/librte_timer/rte_timer.c ++++ b/lib/librte_timer/rte_timer.c +@@ -573,7 +573,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, +@@ -595,7 +595,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) +@@ -622,7 +622,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, +@@ -961,21 +961,16 @@ rte_timer_stop_all(uint32_t timer_data_id, unsigned int *walk_lcores,