From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 53509A0093 for ; Tue, 19 May 2020 15:12:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4B0B81D702; Tue, 19 May 2020 15:12:20 +0200 (CEST) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id 78EF81D702 for ; Tue, 19 May 2020 15:12:19 +0200 (CEST) Received: by mail-wm1-f68.google.com with SMTP id z72so3516639wmc.2 for ; Tue, 19 May 2020 06:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5g1PQ7RBs/uAVE3ChkFMSQWqAzLLFvfLeUdE4/edugg=; b=IRIFIQzV8je4dzjiKLpCj14GXIWmSQisOL6+Y1R5JAsuTlMLnuTwFwKbM03BTchDF1 9bbXkNOADiRxcDyoSvIzM/M2R91AJ5V6Xd+BTKOXys3vt8G1moCY4Gv5JZ2ioIf1wgT1 Q+NLn2XgU86by4tK9CXaddQI0tqOLoyGpSTBHDoSBohP7LGSIgzUsiVj3zs6szK78B71 HN2Lh6fNY9taJSTLWDm5SB33SpXTyH18wPRpPpKOrzTQNhqYHAi50hdQKcxp8DheTUiH zJz17x3B5M8XgERHAkwLcZG5ofYNUTyGVbFYWXBuJanAjRafZ+b8lJENTFlXUPSkbQCI 256Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5g1PQ7RBs/uAVE3ChkFMSQWqAzLLFvfLeUdE4/edugg=; b=dDn+Oa/wq293jrtEkAPjvxFdT6fF8EVpkj5OT/ef1bpxRxEvjOP8J9utjzuNyU5vBR Q//2NQdJESmqSkBEGvvJlxx+n8ceWnqeYazzPTmwjM1ElwOoyNQoffWozyYdKzzkeKZt ddpkEbR/ZL8NRNBzAjpGG/+6f9WL+ojZdDDAxYKke2U8RGa3L2ydXRy0XkLnCV8L+vD4 jqVoDH29g/fGLDDEQX6WiPpYhpOpN6G+lw6ly2GLekZbtrL6KnGNJwXWwPtFMs+lAens BH71AZ6xt1V4sAhOLveg0LzRXBt9EbFpjCtV9qgFoNFC3Snt1bPWTxN4/8EgeIwpbHLL y41g== X-Gm-Message-State: AOAM532yuh+/dX9VlirjI/mTFeuTXZshHM/SC6JtlERhm/S/hBTcHvqs ST5aBFlHuUDw3vWBpfMeWGvxUepJ2JYKviVx X-Google-Smtp-Source: ABdhPJzuzN60ki+N1HD5Btw55xO/lGPnnjtEUyzeXvxG7kq8KXdokAmmgNbFGVXtzb9TWlsaSmk5jQ== X-Received: by 2002:a05:600c:21c1:: with SMTP id x1mr5306937wmj.173.1589893939188; Tue, 19 May 2020 06:12:19 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id v20sm24350061wrd.9.2020.05.19.06.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 06:12:18 -0700 (PDT) From: luca.boccassi@gmail.com To: Honnappa Nagarahalli Cc: Gavin Hu , Phil Yang , Erik Gabriel Carrillo , dpdk stable Date: Tue, 19 May 2020 14:04:16 +0100 Message-Id: <20200519130549.112823-121-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519130549.112823-1-luca.boccassi@gmail.com> References: <20200519125804.104349-1-luca.boccassi@gmail.com> <20200519130549.112823-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'timer: protect initialization with lock' has been queued to stable release 19.11.3 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/21/20. 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. Thanks. Luca Boccassi --- >From ccc676944f86c16151db2516a9bce37274c73f3b Mon Sep 17 00:00:00 2001 From: Honnappa Nagarahalli Date: Mon, 24 Feb 2020 14:42:18 +0800 Subject: [PATCH] timer: protect initialization with lock [ upstream commit 68f7f31aaa7479d36ae1d1e7853940ce4874cba7 ] rte_timer_subsystem_initialized is a global variable that can be accessed by multiple processes simultaneously. Hence, any access to rte_timer_subsystem_initialized should be protected by rte_mcfg_timer_lock. Fixes: f9d6cd8bfe9e ("timer: fix resource leak in finalize") Signed-off-by: Honnappa Nagarahalli Reviewed-by: Gavin Hu Reviewed-by: Phil Yang Acked-by: Erik Gabriel Carrillo --- lib/librte_timer/rte_timer.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index 4680a91b58..99862a3ba1 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -145,10 +145,12 @@ rte_timer_subsystem_init(void) const size_t mem_size = data_arr_size + sizeof(*rte_timer_mz_refcnt); bool do_full_init = true; - if (rte_timer_subsystem_initialized) + rte_mcfg_timer_lock(); + + if (rte_timer_subsystem_initialized) { + rte_mcfg_timer_unlock(); return -EALREADY; - - rte_mcfg_timer_lock(); + } mz = rte_memzone_lookup(mz_name); if (mz == NULL) { @@ -183,27 +185,29 @@ rte_timer_subsystem_init(void) rte_timer_data_arr[default_data_id].internal_flags |= FL_ALLOCATED; (*rte_timer_mz_refcnt)++; - rte_mcfg_timer_unlock(); - rte_timer_subsystem_initialized = 1; + rte_mcfg_timer_unlock(); + return 0; } void rte_timer_subsystem_finalize(void) { - if (!rte_timer_subsystem_initialized) - return; - rte_mcfg_timer_lock(); + if (!rte_timer_subsystem_initialized) { + rte_mcfg_timer_unlock(); + return; + } + if (--(*rte_timer_mz_refcnt) == 0) rte_memzone_free(rte_timer_data_mz); - rte_mcfg_timer_unlock(); - rte_timer_subsystem_initialized = 0; + + rte_mcfg_timer_unlock(); } /* Initialize the timer handle tim for use */ -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-05-19 14:04:49.393882410 +0100 +++ 0121-timer-protect-initialization-with-lock.patch 2020-05-19 14:04:44.392651562 +0100 @@ -1,15 +1,16 @@ -From 68f7f31aaa7479d36ae1d1e7853940ce4874cba7 Mon Sep 17 00:00:00 2001 +From ccc676944f86c16151db2516a9bce37274c73f3b Mon Sep 17 00:00:00 2001 From: Honnappa Nagarahalli Date: Mon, 24 Feb 2020 14:42:18 +0800 Subject: [PATCH] timer: protect initialization with lock +[ upstream commit 68f7f31aaa7479d36ae1d1e7853940ce4874cba7 ] + rte_timer_subsystem_initialized is a global variable that can be accessed by multiple processes simultaneously. Hence, any access to rte_timer_subsystem_initialized should be protected by rte_mcfg_timer_lock. Fixes: f9d6cd8bfe9e ("timer: fix resource leak in finalize") -Cc: stable@dpdk.org Signed-off-by: Honnappa Nagarahalli Reviewed-by: Gavin Hu @@ -20,7 +21,7 @@ 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c -index 89f27074f8..269e92114c 100644 +index 4680a91b58..99862a3ba1 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -145,10 +145,12 @@ rte_timer_subsystem_init(void)