From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by dpdk.org (Postfix) with ESMTP id 37ABC1B525; Fri, 15 Jun 2018 17:13:16 +0200 (CEST) Received: by mail-lf0-f68.google.com with SMTP id v135-v6so15140386lfa.9; Fri, 15 Jun 2018 08:13:16 -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; bh=M+H83Tcb0f52QKFM/18/wmEVs02A1FQtz36SYLO1LAw=; b=j5J3DEhoUtuFrvTHgKSkG9NPPgmyr3xWc6AfuGd1Pgb+SoYAgpJZqePbua2WMAINc7 0MQjwItkMriGWdpwHRFc0vDcknidrEI5FZKKGAubrVN+Ex1dp9gnNgVneKw5lSt4dkLI cIQ6g+MuzoKns3FaCPzAuZr3TIEmtSSXmW+exdP/hy5oXzS6BuZ6cThsykWXIS7gDw0z c0BZc7RYAcQAXyH0NsOHgbtAd3r54LDwGcTfaek5yQJVI+YYKlYJIBTTfBUitCqDIFck MvTQsMV13dBUPEkD3NJmZhEJihF0dhXqTovrZ1EoC0f+U116Pf+cgyGqOC4YD754CaHe R+Rg== 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; bh=M+H83Tcb0f52QKFM/18/wmEVs02A1FQtz36SYLO1LAw=; b=Slu2JJROMcejcubSPfhuOMEwdmvXR9o0xOZUbIaHyEireFKyZYlGiK9kB1V5K78Nt+ 5rfORgulmj/f3NQc1wTGfK/ikQf3Xr0H72SGFt8Q7uptBJx00hd7Rm1FFH8QMNrSgQrM yE/3HWHk02XAwSPE5ft7kTplDl+zkdUOrT1lFgdI2UIMZFyPiqELtxu0YGV38CDEflcl jAmoBuwYQBaJDlqS1aHx+FhxXmFa2dXFi/S/qGi3eVHhT/odADnvCg7aUceBheZehpaE fu/1E/9olg72ubBuKbMB3A8eV3bIMT55k0ZdKnCHzT4pkW0vBW2mkcuC0FZyg4t56aal SeSw== X-Gm-Message-State: APt69E3qKfyEMrJqB74hisxrDcWJ2V+yybPHUXEqXu3QdAKigVveulHH 8J4JQdOWZYKedZ8kzIzGdPkKcVbW X-Google-Smtp-Source: ADUXVKKqRvHGud+dyIwYpoUd/swJN981UQLB9VkBBN7t59yhXctXZ4iV6m2p0iMW0E7qcvOjU6LDjg== X-Received: by 2002:a2e:529c:: with SMTP id n28-v6mr1701677lje.62.1529075595516; Fri, 15 Jun 2018 08:13:15 -0700 (PDT) Received: from localhost.localdomain (89-68-115-185.dynamic.chello.pl. [89.68.115.185]) by smtp.gmail.com with ESMTPSA id f8-v6sm1533138lfc.29.2018.06.15.08.13.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 08:13:14 -0700 (PDT) From: Dariusz Stojaczyk To: dev@dpdk.org, Anatoly Burakov Cc: Dariusz Stojaczyk , stable@dpdk.org Date: Fri, 15 Jun 2018 17:13:04 +0200 Message-Id: <20180615151304.32032-1-darek.stojaczyk@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180615122448.28118-1-darek.stojaczyk@gmail.com> References: <20180615122448.28118-1-darek.stojaczyk@gmail.com> Subject: [dpdk-dev] [PATCH v2] memory: make eal_get_virtual_area() aware of base-virtaddr alignment X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2018 15:13:16 -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 Acked-by: Anatoly Burakov --- Changes from v1: * do not increment next_baseaddr if its currently NULL. Otherwise this patch breaks applications without base-virtaddr specified * switched to explicit `!= NULL` comparisons 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..2413ce1e7 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 != NULL) { + 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 if (next_baseaddr != NULL) { + 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