From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DF8CCA0093 for ; Tue, 19 May 2020 15:00:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D1EE91D60D; Tue, 19 May 2020 15:00:02 +0200 (CEST) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id 02FEC1D607 for ; Tue, 19 May 2020 15:00:01 +0200 (CEST) Received: by mail-wr1-f68.google.com with SMTP id l17so15818382wrr.4 for ; Tue, 19 May 2020 06:00:01 -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=rWuvIBuNPRU6apzCSc8t69zAzx+WVKesK7O68uogOrA=; b=eqK5K6haHd765e02hMaQ7Ac6nf0x84/0yQf4jQnE2pGThWyLSFlgNPpsKduAC6sWY9 7XZXXcwcZBx5aPvrFKkZ79/cHSFqcXoMLqFPb98MXRlBWT0YsBKMCEUwFO/pVa1JxFqN gp8kNv3EdvZpz1TRK2GJ6MYzQasmrjGzXyXqGFC71eZtg3HYIxzZyG81tU9mTDk9GImO r8a6b8g5Eu44PL3aGasCY6GZ8NQD2rmbX3xDnKBxYHAqXLwMPfWpIX+8CGHGj1Iw5QBI BiKDfkOgBf+AoMHQ/iXfFxUojlVLArdTvipC5n8WBfHg1f/DBeXinF/lzvRobrfKeQYk fMWQ== 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=rWuvIBuNPRU6apzCSc8t69zAzx+WVKesK7O68uogOrA=; b=NHr2JyGd2eIcGkQd8+ox9IMZkzQE+09T/pNdL9GZ2ZHpt1q3Ro0KDSKAiA8kTsMx8l Wz+pRrvoeaqWloDSjPw7j1myI8FJ7c6dtIRaWN5vzx2HD1tCI5prA9tkgbVqSy25TyEF MEdUlJVlPKuGkvTjCJI+Go+UENxJNkAsXNqXcGBvcOiRHLFpL9uEiCPEOKJjuFXfpOJ3 mUSylLaX6wsjveQv5NBr7OAQTZ2unQqhw69iTk8w3P6Rqe2NSIjHW5J3t0qwUAgAg4NS hmNLNHmEgimE3TP3+WQFPaJ5KvIWF+58ST9KkC+RWV2zXqCDaFejnHBCBvgxT5PH4//i Qypg== X-Gm-Message-State: AOAM533x4tR7Wqb1f6pMWDwCXOTX7DHE9BTv0iDrRqGImzWIhJT5wFPF QSY/Z+ChQVxxCnhtnvWY5t8= X-Google-Smtp-Source: ABdhPJxYLokfFJWBLWJ8w5P9jjUJvhENZPCbYtGH0itaribafsxtiUVj0787c+I6Qv1yz+OSplQNjA== X-Received: by 2002:a5d:6a8c:: with SMTP id s12mr26538481wru.345.1589893200745; Tue, 19 May 2020 06:00:00 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id f123sm3833042wmf.44.2020.05.19.05.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 06:00:00 -0700 (PDT) From: luca.boccassi@gmail.com To: Anatoly Burakov Cc: David Marchand , Jun W Zhou , dpdk stable Date: Tue, 19 May 2020 13:54:03 +0100 Message-Id: <20200519125804.104349-53-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519125804.104349-1-luca.boccassi@gmail.com> References: <20200519125804.104349-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'mem: preallocate VA space in no-huge mode' has been queued to stable release 19.11.3 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: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.3 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/21/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 9aebba7e3d54df3cb42215cb3547b3a4c77e53ca Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Fri, 7 Feb 2020 11:11:14 +0000 Subject: [PATCH] mem: preallocate VA space in no-huge mode [ upstream commit 4236694f0ae466b174a73a29df4cfa94753793f0 ] When --no-huge mode is used, the memory is currently allocated with mmap(NULL, ...). This is fine in most cases, but can fail in cases where DPDK is run on a machine with an IOMMU that is of more limited address width than that of a VA, because we're not specifying the address hint for mmap() call. Fix it by preallocating VA space before mapping it. Signed-off-by: Anatoly Burakov Tested-by: David Marchand Tested-by: Jun W Zhou --- lib/librte_eal/linux/eal/eal_memory.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c index 5604c2a7c0..7a9c97ff88 100644 --- a/lib/librte_eal/linux/eal/eal_memory.c +++ b/lib/librte_eal/linux/eal/eal_memory.c @@ -1340,6 +1340,8 @@ eal_legacy_hugepage_init(void) /* hugetlbfs can be disabled */ if (internal_config.no_hugetlbfs) { + void *prealloc_addr; + size_t mem_sz; struct rte_memseg_list *msl; int n_segs, cur_seg, fd, flags; #ifdef MEMFD_SUPPORTED @@ -1395,17 +1397,31 @@ eal_legacy_hugepage_init(void) } } #endif - addr = mmap(NULL, internal_config.memory, PROT_READ | PROT_WRITE, - flags, fd, 0); - if (addr == MAP_FAILED) { + /* preallocate address space for the memory, so that it can be + * fit into the DMA mask. + */ + mem_sz = internal_config.memory; + prealloc_addr = eal_get_virtual_area( + NULL, &mem_sz, page_sz, 0, 0); + if (prealloc_addr == NULL) { + RTE_LOG(ERR, EAL, + "%s: reserving memory area failed: " + "%s\n", + __func__, strerror(errno)); + return -1; + } + addr = mmap(prealloc_addr, mem_sz, PROT_READ | PROT_WRITE, + flags | MAP_FIXED, fd, 0); + if (addr == MAP_FAILED || addr != prealloc_addr) { RTE_LOG(ERR, EAL, "%s: mmap() failed: %s\n", __func__, strerror(errno)); + munmap(prealloc_addr, mem_sz); return -1; } msl->base_va = addr; msl->page_sz = page_sz; msl->socket_id = 0; - msl->len = internal_config.memory; + msl->len = mem_sz; msl->heap = 1; /* we're in single-file segments mode, so only the segment list -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-05-19 13:56:21.011646168 +0100 +++ 0053-mem-preallocate-VA-space-in-no-huge-mode.patch 2020-05-19 13:56:18.283502971 +0100 @@ -1,8 +1,10 @@ -From 4236694f0ae466b174a73a29df4cfa94753793f0 Mon Sep 17 00:00:00 2001 +From 9aebba7e3d54df3cb42215cb3547b3a4c77e53ca Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Fri, 7 Feb 2020 11:11:14 +0000 Subject: [PATCH] mem: preallocate VA space in no-huge mode +[ upstream commit 4236694f0ae466b174a73a29df4cfa94753793f0 ] + When --no-huge mode is used, the memory is currently allocated with mmap(NULL, ...). This is fine in most cases, but can fail in cases where DPDK is run on a machine with an IOMMU that is of more limited @@ -11,8 +13,6 @@ Fix it by preallocating VA space before mapping it. -Cc: stable@dpdk.org - Signed-off-by: Anatoly Burakov Tested-by: David Marchand Tested-by: Jun W Zhou