From patchwork Wed Jun 27 09:44:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 41647 X-Patchwork-Delegate: thomas@monjalon.net 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 E032E1BE1C; Wed, 27 Jun 2018 11:44:29 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 5324D1B8C8; Wed, 27 Jun 2018 11:44:28 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2018 02:44:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,278,1526367600"; d="scan'208";a="66720547" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga004.fm.intel.com with ESMTP; 27 Jun 2018 02:44:26 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w5R9iPT8025963; Wed, 27 Jun 2018 10:44:25 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w5R9iPRN014459; Wed, 27 Jun 2018 10:44:25 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w5R9iPIp014455; Wed, 27 Jun 2018 10:44:25 +0100 From: Anatoly Burakov To: dev@dpdk.org Cc: qi.z.zhang@intel.com, stable@dpdk.org Date: Wed, 27 Jun 2018 10:44:25 +0100 Message-Id: <164824cc66c16755416bb8d3d6911385f52f8c1e.1530092380.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] ipc: fix locking while sending messages 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" Previously, we were putting an exclusive lock to prevent secondary processes spinning up while we are sending our messages. However, using exclusive locks had an effect of disallowing multiple simultaenous unrelated messages/requests being sent, which was not the intention behind locking. Fix it to put a shared lock on the directory. That way, we still prevent secondary process initializations while sending data over IPC, but allow multiple unrelated transmissions to proceed. Fixes: 89f1fe7e6d95 ("eal: lock IPC directory on init and send") Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov Tested-by: Qi Zhang --- Notes: This patch is needed for multiprocess hotplug support [1], to avoid cases where multiple requests deadlock while in progress. [1] http://patches.dpdk.org/project/dpdk/list/?series=252 lib/librte_eal/common/eal_common_proc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index 707d8ab30..f010ef59e 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -786,7 +786,7 @@ mp_send(struct rte_mp_msg *msg, const char *peer, int type) dir_fd = dirfd(mp_dir); /* lock the directory to prevent processes spinning up while we send */ - if (flock(dir_fd, LOCK_EX)) { + if (flock(dir_fd, LOCK_SH)) { RTE_LOG(ERR, EAL, "Unable to lock directory %s\n", mp_dir_path); rte_errno = errno; @@ -1020,7 +1020,7 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, dir_fd = dirfd(mp_dir); /* lock the directory to prevent processes spinning up while we send */ - if (flock(dir_fd, LOCK_EX)) { + if (flock(dir_fd, LOCK_SH)) { RTE_LOG(ERR, EAL, "Unable to lock directory %s\n", mp_dir_path); closedir(mp_dir); @@ -1146,7 +1146,7 @@ rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts, dir_fd = dirfd(mp_dir); /* lock the directory to prevent processes spinning up while we send */ - if (flock(dir_fd, LOCK_EX)) { + if (flock(dir_fd, LOCK_SH)) { RTE_LOG(ERR, EAL, "Unable to lock directory %s\n", mp_dir_path); rte_errno = errno;