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 F29F1A32A8 for ; Sat, 26 Oct 2019 18:02:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DB56B1BF6C; Sat, 26 Oct 2019 18:02:42 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 9855E1BF57 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-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-226-HM91FPVlP1mKCWy3E4Od7g-1; Sat, 26 Oct 2019 12:02:37 -0400 Received: by mail-vk1-f197.google.com with SMTP id q5so2413964vkg.20 for ; Sat, 26 Oct 2019 09:02:37 -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=FO6T/lGTpdWfGdTSBf12g/re6oTCXRdbQV59aOS6axsgjhJAV9LaokGLQyEozjQZ8O kFZ+MlgUNxFfjknGYnc7tV0SQ8rmhD/g70L3gDDHMRydKShSDpS0cUikV/NreUXriiPl nNW0x/lauGsCB2lnRWTL/jncZq+tTi4hP7yaIjevzrvC8g/PkXyVBjr+B5hbJNEhunEY Mw0lIynoeqB6nJ02NtedHVIJIWSRMg1Rj+NAEHDmZ/Ydb9FjjL4kz3WmqyfDHmWuc8zl WFz04iji6Pau7DW+cXzObuUHVhAAMeUaeNj9hFHX+pwIxPbGZ1CIKDajpp/KjJwNbWr3 wTvw== X-Gm-Message-State: APjAAAUoH2d/VzAX3Yk4IL6eICpDJkz1OvkQipA4ilstZm/W43gNG7eP rMzkyyT8hhlZyiZkDk5F6shrNX1VczDKJPZttWirgO2Bdco7HtRFwMeufKmHH8rmUAJYeqLcqcV HTUgilIqVibicENyn8RI= X-Received: by 2002:a67:7790:: with SMTP id s138mr795714vsc.198.1572105756752; 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: HM91FPVlP1mKCWy3E4Od7g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v5 2/2] eal: use base address hint to reserve space for mem config 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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