From patchwork Tue Jul 18 01:00:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Erb X-Patchwork-Id: 129652 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 37FEF42EC6; Thu, 20 Jul 2023 07:19:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EFBD42BB1; Thu, 20 Jul 2023 07:18:54 +0200 (CEST) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by mails.dpdk.org (Postfix) with ESMTP id 41818406B3 for ; Tue, 18 Jul 2023 03:01:02 +0200 (CEST) Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7659cb9c42aso419739485a.3 for ; Mon, 17 Jul 2023 18:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=threatblockr-com.20221208.gappssmtp.com; s=20221208; t=1689642061; x=1692234061; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ftU5jVtwz+bAV2jqa2OHXPNHnR/6lrblDoaxG5GV5xA=; b=jaWT68oPT0AevaEcMKVHMpn2ILjAM46ngt6Mh55zqcVCsjoZR2WKuzZucCssiXvS06 3Y7AHnbU/+dCQ0k2oTa0uxR7vBX7Jn/BqGvW9Qp9tuYJQrzWOZrBSXcfe/B+ehN8BwvZ qAyelImRfuVOTLZJcGArTynEQQHOGOWu5PKWsQOt3Iz7zObHhlvdDqMvG7K10E/KeLT3 Pbm42L9Sh+ziaoxhJcQCL75gwbzZxgosqo4fiAFfTRAAgnYw3Qxe5brnBuCI32XnTgld TDF0uCg5Ou8yqdXvsI8+RIxohPmxvhLM4G4cTk1XruT2ROTQVXiSh/DaBA3YEUwsKJEb ezrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689642061; x=1692234061; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ftU5jVtwz+bAV2jqa2OHXPNHnR/6lrblDoaxG5GV5xA=; b=Ym++AyDzg3h5ev4gMKv0IPi7FEz9HU7Oxotb5MsEyp527zv0I206D4ZuI/Wrd4NBGP i5KaU+yx2OU6Cn5AVlMXEWPe3m3sOQXsg4S2n0N9BOrMZLAg6wQpYIpovoxJGO1TPVaM c83byPRR/RKnpl8x/xN9XNRlME4TyHIea4mt0EK+iY7I4e2LvB6RFEnzD+wYPNRWoCG8 P8T4dkxBwWaRs5tfkMVqntkCF6WQ/B7B7D6cIfeLg0qzLNEzRmU4I657TKaFffyjT+ki KUg4H73+S715QZ/tblX27UbF+bd3X305xC//nkuy9lXg8EQJLJFKTnISp2xPao8QYvB3 2Yag== X-Gm-Message-State: ABy/qLaDeR1DwjXHU7Atqo3TdisdbWCLlR9Ep7gMpGDkrEQynBNVNcAF dFnhtZj9KQBZ8ZCDxbRxt55i5g== X-Google-Smtp-Source: APBJJlEDrHtTs4XIP2D6ZtQeAgI32SRavrjngmH5feY9V9QZluL+POPU2kGv3+0gyWoyf38E0ndA7w== X-Received: by 2002:a05:620a:2950:b0:75e:d895:6a46 with SMTP id n16-20020a05620a295000b0075ed8956a46mr14529037qkp.44.1689642061514; Mon, 17 Jul 2023 18:01:01 -0700 (PDT) Received: from localhost.localdomain (dyn-170-246-97.myactv.net. [24.170.246.97]) by smtp.gmail.com with ESMTPSA id s2-20020a05620a030200b0076814f80d5asm238610qkm.4.2023.07.17.18.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 18:01:01 -0700 (PDT) From: Jonathan Erb To: Thomas Monjalon , Anatoly Burakov Cc: dev@dpdk.org, Jonathan Erb , stable@dpdk.org Subject: [PATCH] eal/linux: prevent deadlocks on rte init and cleanup Date: Mon, 17 Jul 2023 21:00:46 -0400 Message-Id: <20230718010047.456679-1-jonathan.erb@threatblockr.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 20 Jul 2023 07:18:50 +0200 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Resolves a deadlock that can occur when multiple secondary processes are starting and stopping. A deadlock can occur because eal_memalloc_init() is taking a second unnecessary read lock. If another DPDK process that is terminating enters rte_eal_memory_detach() and acquires a write lock wait state before the starting process can acquire it's second read lock then no process will be able to proceed. Cc: stable@dpdk.org Signed-off-by: Jonathan Erb --- .mailmap | 2 +- lib/eal/linux/eal_memalloc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.mailmap b/.mailmap index 6eccf0c555..a64bfcf1d2 100644 --- a/.mailmap +++ b/.mailmap @@ -663,7 +663,7 @@ John OLoughlin John Ousterhout John W. Linville Jonas Pfefferle -Jonathan Erb +Jonathan Erb Jon DeVree Jon Loeliger Joongi Kim diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c index f8b1588cae..a34f1cf2f9 100644 --- a/lib/eal/linux/eal_memalloc.c +++ b/lib/eal/linux/eal_memalloc.c @@ -1740,7 +1740,7 @@ eal_memalloc_init(void) eal_get_internal_configuration(); if (rte_eal_process_type() == RTE_PROC_SECONDARY) - if (rte_memseg_list_walk(secondary_msl_create_walk, NULL) < 0) + if (rte_memseg_list_walk_thread_unsafe(secondary_msl_create_walk, NULL) < 0) return -1; if (rte_eal_process_type() == RTE_PROC_PRIMARY && internal_conf->in_memory) { @@ -1778,7 +1778,7 @@ eal_memalloc_init(void) } /* initialize all of the fd lists */ - if (rte_memseg_list_walk(fd_list_create_walk, NULL)) + if (rte_memseg_list_walk_thread_unsafe(fd_list_create_walk, NULL)) return -1; return 0; }