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 42A77A0A02; Thu, 25 Mar 2021 16:39:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2D71140E38; Thu, 25 Mar 2021 16:39:55 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 929D7140E37 for ; Thu, 25 Mar 2021 16:39:54 +0100 (CET) IronPort-SDR: MjqgQGa4ZYcuOr4Ky3gmi80k6JhvyqjNrwLPoV8rZ/Bw1CbIyz39ZF64Ymc4LrWhhXlNNRJw7R PgqnP3vr3nCA== X-IronPort-AV: E=McAfee;i="6000,8403,9934"; a="170933510" X-IronPort-AV: E=Sophos;i="5.81,277,1610438400"; d="scan'208";a="170933510" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 08:39:53 -0700 IronPort-SDR: YRse/4x/8rkkxtnphVXZACHpUJjfa1xTr9v3UQ6i7Rj1153PDUr+Kb66MOIYseKjRiVvvy8XmG EtVzjXapwhWw== X-IronPort-AV: E=Sophos;i="5.81,277,1610438400"; d="scan'208";a="442832315" Received: from rmenon-desk.amr.corp.intel.com (HELO [10.166.30.253]) ([10.166.30.253]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2021 08:39:53 -0700 To: Dmitry Kozlyuk , dev@dpdk.org Cc: Anatoly Burakov , Jie Zhou , David Marchand References: <20210324180128.32752-1-dmitry.kozliuk@gmail.com> <20210324193227.15497-1-dmitry.kozliuk@gmail.com> From: Ranjit Menon Message-ID: <9c5e4d85-47f6-189d-d64e-7222245329c3@intel.com> Date: Thu, 25 Mar 2021 08:39:49 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20210324193227.15497-1-dmitry.kozliuk@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH v2] mem: fix cleanup when multi-process is disabled 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 Sender: "dev" On 3/24/2021 12:32 PM, Dmitry Kozlyuk wrote: > rte_eal_memory_detach() did not account for cases where multi-process > mode is disabled: --in-memory and --no-shconf. This resulted > in unmapping memory that had not been mapped, which caused errors: > > EAL: Could not unmap memory: No error (Windows) > EAL: Cannot munmap(0x1d47f40, 0x7000): Invalid argument (Linux) > > Confusing "No error" was caused by using errno instead of rte_errno > set by rte_mem_unmap(). > > Skip detaching memory altogether when --in-memory is specified. > Skip unmapping configuration when it's not shared. > Fix and add error handling to produce proper log messages. > > Fixes: dfbc61a2f9a6 ("mem: detach memsegs on cleanup") > Cc: Anatoly Burakov > > Reported-by: Jie Zhou > Suggested-by: David Marchand > Signed-off-by: Dmitry Kozlyuk > --- > lib/librte_eal/common/eal_common_memory.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c > index 0e99986d3d..9495170c86 100644 > --- a/lib/librte_eal/common/eal_common_memory.c > +++ b/lib/librte_eal/common/eal_common_memory.c > @@ -1006,10 +1006,15 @@ rte_extmem_detach(void *va_addr, size_t len) > int > rte_eal_memory_detach(void) > { > + const struct internal_config *internal_conf = > + eal_get_internal_configuration(); > struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; > size_t page_sz = rte_mem_page_size(); > unsigned int i; > > + if (internal_conf->in_memory == 1) > + return 0; > + > rte_rwlock_write_lock(&mcfg->memory_hotplug_lock); > > /* detach internal memory subsystem data first */ > @@ -1032,7 +1037,7 @@ rte_eal_memory_detach(void) > if (!msl->external) > if (rte_mem_unmap(msl->base_va, msl->len) != 0) > RTE_LOG(ERR, EAL, "Could not unmap memory: %s\n", > - strerror(errno)); > + rte_strerror(rte_errno)); > > /* > * we are detaching the fbarray rather than destroying because > @@ -1050,7 +1055,10 @@ rte_eal_memory_detach(void) > * config - we can't zero it out because it might still be referenced > * by other processes. > */ > - rte_mem_unmap(mcfg, RTE_ALIGN(sizeof(*mcfg), page_sz)); > + if (internal_conf->no_shconf == 0) > + if (rte_mem_unmap(mcfg, RTE_ALIGN(sizeof(*mcfg), page_sz)) != 0) > + RTE_LOG(ERR, EAL, "Could not unmap shared memory config: %s\n", > + rte_strerror(rte_errno)); > rte_eal_get_configuration()->mem_config = NULL; > > return 0; Acked-by: Ranjit Menon