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 BB4B8A0A02; Wed, 24 Mar 2021 20:32:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C390140F7A; Wed, 24 Mar 2021 20:32:36 +0100 (CET) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by mails.dpdk.org (Postfix) with ESMTP id D12BF140EE4 for ; Wed, 24 Mar 2021 20:32:35 +0100 (CET) Received: by mail-lf1-f43.google.com with SMTP id g8so26588442lfv.12 for ; Wed, 24 Mar 2021 12:32:35 -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=PrEkB7Vu4wl+/bNegeD7bJyCQVzD/yeKNcMTj8JJs/M=; b=Gvuklqkx5XUkEutovrQ3y8uqJxgNwzlgy3apA+zG27PAldP3K5TsgucyL0j2S/61EX Nu7ub04DMuFjzlvhVnriZhjDkm8OSHijzb98XNgfEx5hdZmGRJQ87/Ply5jS3Rv3fPce q4H58q2kmm1dI3aDwxEyhS63nGJ0uBQLw4cDnP0EBX0pJg56pQydZVdAt4+9acyhIP+Q hpNFYPOyQsmb1QmNXxNBts+/f1qKALO1WxSxg8xPpPTfjgIPzsdeUTR/Jxiy8xMTVnPR vhke61uhU62HD4Xlv9YXuwg25HIUvSyeR7fHmyI0ItFwvhuyuKoBMqt7BkDVKpyHLrf8 X+tw== 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=PrEkB7Vu4wl+/bNegeD7bJyCQVzD/yeKNcMTj8JJs/M=; b=RjKg38BC4cQOCNd9b4+s0u01DWY77p9ldja1Oz1q6gE4PC4be4f+ZFkSkMx82AS+tR l2SO0JKjoL0FPFaoeymasX0teBf7/+EhKGpznltJP0p+6IRdVEKcbg6Bnqgmtuwz3rJ7 pfzdi5LZS0ANZ+dAsIPhmHHKR6s9kTB/STxlyJHcdZ6SwTCb5vHTDOTrg7O/nDn/EJ/D QklP1UpdbDTb0MheOlan33KSZw7WamkiVoM1i9G9ap9CY9kLMPdperAp6tZvW6WW0IF5 Apcf1PWekB7yk+uwbuhkqhiInKwfdzhq8Lnh6HptnYzdTs6T2vBF6MYAKcBpNwP7tY0O pLNg== X-Gm-Message-State: AOAM533gO0KyxIITtomh9V1KpX65DiyyJoXdARD4TT0noUwziwoKBoq6 la2BxxKwQpSXVms7FOofkuecIK6HUw7ggQ== X-Google-Smtp-Source: ABdhPJzz3gwq+S0568LmjgxyjG9UxE2nx0BcSq7lQbr9SJXdyU5Vg5YZNJdGEhT0RDxkpAVjDYlMTg== X-Received: by 2002:a05:6512:243:: with SMTP id b3mr2870475lfo.529.1616614354939; Wed, 24 Mar 2021 12:32:34 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id a1sm312198lfh.142.2021.03.24.12.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 12:32:34 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Anatoly Burakov , Jie Zhou , David Marchand Date: Wed, 24 Mar 2021 22:32:26 +0300 Message-Id: <20210324193227.15497-1-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210324180128.32752-1-dmitry.kozliuk@gmail.com> References: <20210324180128.32752-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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" 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; -- 2.29.3