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 6D6CDA32A8 for ; Sat, 26 Oct 2019 18:02:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3334F1BF7D; Sat, 26 Oct 2019 18:02:45 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id AED8D1BF6C for ; Sat, 26 Oct 2019 18:02:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572105761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6/wpFH44xAmfObZYqn8XkFFw/e9O2jwu3qH16p0x2Pg=; b=i/iCmlznqcYshXhzQ1/iPK89VIt3J7JNrIZyHwYfD5XS/kGklBgRfMB61CYBhlx/CRlWac el897luHw9ZqU4rVHpuaLBzIq9g/rV4AoGpm+xjTz5xghRC9idrywy4ffyveZaazdil+fD t6YflqrSPSxzQ/kO43kYp3YH8cK6vG8= Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-2Yozvy8-NsGoTku06_K7PQ-1; Sat, 26 Oct 2019 12:02:38 -0400 Received: by mail-vk1-f200.google.com with SMTP id o67so428316vke.6 for ; Sat, 26 Oct 2019 09:02:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xW78k4L4vl1YY0gd3soVqOAYN9/AyP6sqycs8gcKjUo=; b=JiR1JuqgG8SfT1OtY1ygeKbDdDi5T6bTkgU7kLFx7RXR6gpCGK4MpNQpHoE85HxFlb OR0hgM7MTPKLWEi0F3bO0V0nD1JuBO/ojThoMUUBobB1ZKzW5oJSENQeg+VCaAdxBMKi mImsCkmVx8pZkuO/oKlvfBEl5MoCizhArUQ1QKreaI8vLEhcywQ/1ve/ASuTEJy5pk3X i+f84jwt9IRH95M9HgToJ8Ud29ZarrHrZdH83IzlqKoqzoVS4EMsCPxO7yQF1cq+HXfv iPywS/W270+8D0YYiJLJs3GZru9fTbD+zXJuvRahB9H41BmM6s8ibqWJXryxk3Kdk2Hc 6UQg== X-Gm-Message-State: APjAAAU9ph0ytT72ejqJN8zryLpMr6zsqrgiaMNVLDrua0I3pTptvUW0 NV1pF8FGUl2X0iMp37gXONneX8iowFVse1xkX2xbFoUmk6unAIDQgQqqD690hO7aTfDv8lQ7dV+ BDwJ9QS0Xi/VgxMGUJ47+7pc= X-Received: by 2002:a67:7790:: with SMTP id s138mr795719vsc.198.1572105756755; Sat, 26 Oct 2019 09:02:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuT7O/cAJ9VldIcxaAByAD0pyP7kZMoPZsfuwrrEqCsKXvHoLLk1ge2DCU2JW8KZa56sJ8kPT6VsOOHt86YZA= X-Received: by 2002:a67:7790:: with SMTP id s138mr795633vsc.198.1572105754969; Sat, 26 Oct 2019 09:02:34 -0700 (PDT) MIME-Version: 1.0 References: <09c3f9d74e1e49aa5b3608d4bf4a773d086e83ff.1564577214.git.anatoly.burakov@intel.com> In-Reply-To: From: David Marchand Date: Sat, 26 Oct 2019 18:02:23 +0200 Message-ID: To: Anatoly Burakov Cc: dev , Bruce Richardson , Stephen Hemminger , Li Han , dpdk stable X-MC-Unique: 2Yozvy8-NsGoTku06_K7PQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-stable] [PATCH v5 2/2] eal: use base address hint to reserve space for mem config 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" On Thu, Oct 24, 2019 at 2:37 PM Anatoly Burakov wrote: > > Currently, mem config will be mapped without using the virtual > area reservation infrastructure, which means it will be mapped > at an arbitrary location. This may cause failures to map the > shared config in secondary process due to things like PCI > whitelist arguments allocating memory in a space where the > primary has allocated the shared mem config. > > Fix this by using virtual area reservation to reserve space for > the mem config, thereby avoiding the problem and reserving the > shared config (hopefully) far away from any normal memory > allocations. > > Cc: stable@dpdk.org > > Signed-off-by: Anatoly Burakov > --- > > Notes: > v4: > - Fix mem config length to always be page-aligned > > v3: > - Fix alignment issues with base address > > v2: > - Fix issue with unneeded ADDR_IS_HINT flag that broke things > on 32-bit builds > > lib/librte_eal/freebsd/eal/eal.c | 28 +++++++++++++++++++++------ > lib/librte_eal/linux/eal/eal.c | 33 +++++++++++++++++++++++--------- > 2 files changed, 46 insertions(+), 15 deletions(-) > > diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/ea= l/eal.c > index f86e9aa318..5b869b895a 100644 > --- a/lib/librte_eal/freebsd/eal/eal.c > +++ b/lib/librte_eal/freebsd/eal/eal.c > @@ -218,7 +218,10 @@ eal_parse_sysfs_value(const char *filename, unsigned= long *val) > static int > rte_eal_config_create(void) > { > - void *rte_mem_cfg_addr; > + size_t page_sz =3D sysconf(_SC_PAGE_SIZE); > + size_t cfg_len =3D sizeof(*rte_config.mem_config); > + size_t cfg_len_aligned =3D RTE_ALIGN(cfg_len, page_sz); > + void *rte_mem_cfg_addr, *mapped_mem_cfg_addr; > int retval; > > const char *pathname =3D eal_runtime_config_path(); Updated existing call to sysconf with page_sz variable. if (internal_config.base_virtaddr !=3D 0) rte_mem_cfg_addr =3D (void *) RTE_ALIGN_FLOOR(internal_config.base_virtaddr - - sizeof(struct rte_mem_config), sysconf(_SC_PAGE_SIZE= )); + sizeof(struct rte_mem_config), page_sz); else rte_mem_cfg_addr =3D NULL; > @@ -235,7 +238,7 @@ rte_eal_config_create(void) > } > } > > - retval =3D ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config)); > + retval =3D ftruncate(mem_cfg_fd, cfg_len); > if (retval < 0){ > close(mem_cfg_fd); > mem_cfg_fd =3D -1; > @@ -253,15 +256,28 @@ rte_eal_config_create(void) > return -1; > } > > - rte_mem_cfg_addr =3D mmap(NULL, sizeof(*rte_config.mem_config), > - PROT_READ | PROT_WRITE, MAP_SHARED, mem_c= fg_fd, 0); > - > - if (rte_mem_cfg_addr =3D=3D MAP_FAILED){ > + /* reserve space for config */ > + rte_mem_cfg_addr =3D eal_get_virtual_area(NULL, &cfg_len_aligned,= page_sz, > + 0, 0); Fixed conflict with base-virtaddr patches. > + if (rte_mem_cfg_addr =3D=3D NULL) { > RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config\n"); > close(mem_cfg_fd); > mem_cfg_fd =3D -1; > return -1; > } Applied, thanks. -- David Marchand