From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 66DABFFA for ; Mon, 30 Apr 2018 16:43:56 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id t11so13644539wmt.0 for ; Mon, 30 Apr 2018 07:43:56 -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; bh=RgSKTftjeV5sxUELnM4d07UZDs0QLDGcmISVzSzt8uc=; b=UyaVE74j4fvO4Dl850jpeUjZEcZLhjNO2jOwkpCogdLHRNpXQKSXX8/0xLwiAPAgiJ SeTeI8JR2jBq4HgbD9bLnqN7oTe71AjWMT+HouRJvRxI4hPRZfn+/Wrge5i33SjXMI0G RiZ/Q7OCYbOKuHl5MVSscmRE7yT1tr6ynApSqIatqLnhaA8r4GzoOMQC23wiuLbM2ioO aJlzkumn7N45DlO9f8Ayn4ck2iUg40H2lRv8CZX2vSsZeDpaR0eBLjfOLDcy0yPM39Y9 phx7986RREaRz5n9w/oyilNtB9qUDhAfChmpqirs9qSM7BvqyI1csYl6pUe7nUOv6T4z 6kMA== 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; bh=RgSKTftjeV5sxUELnM4d07UZDs0QLDGcmISVzSzt8uc=; b=d7xIlbaGIZudS+nqHrQF478T+DBlgVnnjSrYTeezGBjRw1pFK0n43Eiggy1yPpmq2K 0L0qI6J6o7QHCuy4umo9fJB4AWcnwO7eBcMNYQOlWL5P+4MfSlucyvM0IVS+VXr8i68u DoK1wa6triScpdQ1Be33ABDP3L0guQw8GyLT5hmEfIMJzpxvvnBxp1NCJWLbcmvFesOQ 9NxSzLCxhBaMvMSAGhpoteMVlesaVG117ga5gwYekbE0YGcK6UVl3NdfO5DdEF8sgOyJ 1Sw/nNHiAJH23t9wjFQCc3DXpqBvfVFlJO85uX1dvJthaFLa4TgfqAVMlKzUdxkKWf7q vv3Q== X-Gm-Message-State: ALQs6tAAn2iCZNgP9ws3vSafQYniPG44qlz/wMtNiH58FQ8qybgWYKu4 tuOJfNSbKieXq8JbIfDJ7+g= X-Google-Smtp-Source: AB8JxZq9Bi3bWukv/9WTlNEO1KmSTND1TYSrnJmb29iDv0PfydQsxkLekuLK4GY3O/FtViXj/xvJVg== X-Received: by 10.28.176.201 with SMTP id z192mr7103806wme.62.1525099435132; Mon, 30 Apr 2018 07:43:55 -0700 (PDT) Received: from localhost ([2a00:23c5:be9a:5200:ce4c:82c0:d567:ecbb]) by smtp.gmail.com with ESMTPSA id m18sm5869605wma.23.2018.04.30.07.43.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Apr 2018 07:43:54 -0700 (PDT) From: luca.boccassi@gmail.com To: Anatoly Burakov Cc: dpdk stable Date: Mon, 30 Apr 2018 15:41:11 +0100 Message-Id: <20180430144223.18657-56-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180430144223.18657-1-luca.boccassi@gmail.com> References: <20180430140606.4615-80-luca.boccassi@gmail.com> <20180430144223.18657-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'ipc: fix missing mutex unlocks on failed send' has been queued to stable release 18.02.2 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: , X-List-Received-Date: Mon, 30 Apr 2018 14:43:56 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 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/02/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From 930272de80fdc00c87188dd4ccfde24d008bcda0 Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Fri, 13 Apr 2018 15:16:19 +0100 Subject: [PATCH] ipc: fix missing mutex unlocks on failed send [ upstream commit 48e97288982233f015185d632452ab6548c1bd2c ] Earlier fix for race condition introduced a bug where mutex wasn't unlocked if message failed to be sent. Fix all of this by moving locking out of mp_request_sync() altogether. Fixes: da5957821bdd ("eal: fix race condition in IPC request") Signed-off-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_proc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index dccf9ab09..6c315ddf5 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -557,12 +557,10 @@ mp_request_one(const char *dst, struct rte_mp_msg *req, sync_req.reply = &msg; pthread_cond_init(&sync_req.cond, NULL); - pthread_mutex_lock(&sync_requests.lock); exist = find_sync_request(dst, req->name); if (exist) { RTE_LOG(ERR, EAL, "A pending request %s:%s\n", dst, req->name); rte_errno = EEXIST; - pthread_mutex_unlock(&sync_requests.lock); return -1; } @@ -592,9 +590,7 @@ mp_request_one(const char *dst, struct rte_mp_msg *req, now.tv_usec * 1000 < ts->tv_nsec) break; } while (1); - /* We got the lock now */ TAILQ_REMOVE(&sync_requests.requests, &sync_req, next); - pthread_mutex_unlock(&sync_requests.lock); if (sync_req.reply_received == 0) { RTE_LOG(ERR, EAL, "Fail to recv reply for request %s:%s\n", @@ -645,8 +641,12 @@ rte_mp_request(struct rte_mp_msg *req, struct rte_mp_reply *reply, reply->msgs = NULL; /* for secondary process, send request to the primary process only */ - if (rte_eal_process_type() == RTE_PROC_SECONDARY) - return mp_request_one(eal_mp_socket_path(), req, reply, &end); + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + pthread_mutex_lock(&sync_requests.lock); + ret = mp_request_one(eal_mp_socket_path(), req, reply, &end); + pthread_mutex_unlock(&sync_requests.lock); + return ret; + } /* for primary process, broadcast request, and collect reply 1 by 1 */ mp_dir = opendir(mp_dir_path); @@ -656,6 +656,7 @@ rte_mp_request(struct rte_mp_msg *req, struct rte_mp_reply *reply, return -1; } + pthread_mutex_lock(&sync_requests.lock); while ((ent = readdir(mp_dir))) { char path[PATH_MAX]; @@ -665,9 +666,13 @@ rte_mp_request(struct rte_mp_msg *req, struct rte_mp_reply *reply, snprintf(path, sizeof(path), "%s/%s", mp_dir_path, ent->d_name); + /* unlocks the mutex while waiting for response, + * locks on receive + */ if (mp_request_one(path, req, reply, &end)) ret = -1; } + pthread_mutex_unlock(&sync_requests.lock); closedir(mp_dir); return ret; -- 2.14.2