From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by dpdk.org (Postfix) with ESMTP id 16AB61D72A; Fri, 15 Jun 2018 14:25:30 +0200 (CEST) Received: by mail-lf0-f66.google.com with SMTP id q11-v6so14365562lfc.7; Fri, 15 Jun 2018 05:25:30 -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; bh=D8NblHGN8B0Fh5Kvor8B7pJVBz3HEEPiHlsfKEAUwLc=; b=fr7NNvZD1LzqXNQvQU/6i8xw6d4xptYzXS04RisZPKmBRZrG9oJ7J6OJbJZm2Wg5Qf kfskJTpY56fM81nJiFoSF297p+Ax4kzltXTt8UkEJWEmGGadlV+akp/elKfQKSXiKUoe kEAUpO0X6Ha1IlWHZGXijIakGTawQeb9aZhMJk5iklWz4N6ZQKagIAeCR3KhCU1V5A6v 8J2i9wig0d/+vA6jVsbLUkQwwO6N/mo8fs608zSoidLEudnds32obdv1EdJ2b68FHXct n2HSbaC+t17SoFyuWoQkQa7C2dcsgfn9CfBZuTio1er5f9vC4C658Pvv0Z3EwfDpqSFN u0vQ== 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; bh=D8NblHGN8B0Fh5Kvor8B7pJVBz3HEEPiHlsfKEAUwLc=; b=BRZhkdDYQg4f+tE8fKic/KzYHrqQs+G1H4KjR/7mGkScgjqBWu3FYmPGqNiJ88cT1m tOLE+ciJPntW0OxGdnusTnzyHCAfWViDaztcBbtsysOIirC2Y+wIlpu8LFRhKiMTQ16i UQmDSEreC8LIQ59zufTJ261AODflvpjfrNBw7XSX+YkxrgOEex0Lca5Ri0AifZtUhlsO ESFlUPaHJ+bnczJcfAX08YTzRobi8OdQe7b27uEYyFax4ilvmo0CQadNH0uoyXi7zzFO ok+as1PnQR3uef3t+4O4DIBuN/zqrhMI3aAC0sy0tNnjTI46ROq4xPUowu7+hsI/mdH/ jqvw== X-Gm-Message-State: APt69E3wBJkrTHB49QE/kq6mp0NE/7uPazfgolb+FV3tRSSyCFvBNeHT 9RAhfbtEMT0fkcxE7VDY3mEKFw== X-Google-Smtp-Source: ADUXVKIDjubURXvuGLomKhhFRWxrzmatNOwahWPfWILLkWs9bIntKjjefnfiAjQ5DmIKWLbs3/uZNw== X-Received: by 2002:a19:2c94:: with SMTP id s142-v6mr1142223lfs.121.1529065529372; Fri, 15 Jun 2018 05:25:29 -0700 (PDT) Received: from localhost.localdomain (89-68-115-185.dynamic.chello.pl. [89.68.115.185]) by smtp.gmail.com with ESMTPSA id d19-v6sm1477770lfl.82.2018.06.15.05.25.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 05:25:28 -0700 (PDT) From: Dariusz Stojaczyk To: dev@dpdk.org, Anatoly Burakov Cc: Dariusz Stojaczyk , stable@dpdk.org Date: Fri, 15 Jun 2018 14:24:48 +0200 Message-Id: <20180615122448.28118-1-darek.stojaczyk@gmail.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-stable] [PATCH] memory: make eal_get_virtual_area() aware of base-virtaddr alignment 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: , X-List-Received-Date: Fri, 15 Jun 2018 12:25:30 -0000 From: Dariusz Stojaczyk Whenever a calculated base-virtaddr offset had to be manually aligned to requested page_sz, we did not take account of that alignment in incrementing the base-virtaddr offset further. The next requested virtual area could print a warning "hint [...] not respected!" and let the system pick an address instead. As a result, this breaks secondary process support on many system configurations. Fixes: b7cc54187ea4 ("mem: move virtual area function in common directory") Cc: anatoly.burakov@intel.com Cc: stable@dpdk.org Signed-off-by: Dariusz Stojaczyk --- lib/librte_eal/common/eal_common_memory.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c index 4f0688f9d..7c8a316c2 100644 --- a/lib/librte_eal/common/eal_common_memory.c +++ b/lib/librte_eal/common/eal_common_memory.c @@ -34,7 +34,7 @@ #define MEMSEG_LIST_FMT "memseg-%" PRIu64 "k-%i-%i" -static uint64_t baseaddr_offset; +static void *next_baseaddr; static uint64_t system_page_sz; void * @@ -56,9 +56,11 @@ eal_get_virtual_area(void *requested_addr, size_t *size, allow_shrink = (flags & EAL_VIRTUAL_AREA_ALLOW_SHRINK) > 0; unmap = (flags & EAL_VIRTUAL_AREA_UNMAP) > 0; - if (requested_addr == NULL && internal_config.base_virtaddr != 0) { - requested_addr = (void *) (internal_config.base_virtaddr + - (size_t)baseaddr_offset); + if (next_baseaddr == NULL && internal_config.base_virtaddr != 0) + next_baseaddr = (void *) internal_config.base_virtaddr; + + if (requested_addr == NULL && next_baseaddr) { + requested_addr = next_baseaddr; requested_addr = RTE_PTR_ALIGN(requested_addr, page_sz); addr_is_hint = true; } @@ -116,6 +118,8 @@ eal_get_virtual_area(void *requested_addr, size_t *size, RTE_LOG(WARNING, EAL, "WARNING! Base virtual address hint (%p != %p) not respected!\n", requested_addr, aligned_addr); RTE_LOG(WARNING, EAL, " This may cause issues with mapping memory into secondary processes\n"); + } else { + next_baseaddr = RTE_PTR_ADD(aligned_addr, *size); } RTE_LOG(DEBUG, EAL, "Virtual area found at %p (size = 0x%zx)\n", @@ -148,8 +152,6 @@ eal_get_virtual_area(void *requested_addr, size_t *size, munmap(aligned_end, after_len); } - baseaddr_offset += *size; - return aligned_addr; } -- 2.11.0