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 6C556A32A2 for ; Thu, 24 Oct 2019 20:56:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 58F661EBEE; Thu, 24 Oct 2019 20:56:53 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id B09FF1C2A3 for ; Thu, 24 Oct 2019 20:56:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571943411; 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=aYsm35mteHllUAo2TDq3+BBCod3CJsRJ4vStaqVi/Ok=; b=LPlyDoJKzXkksJTrfdHvc/llQC1/8QKKvEWP83DVZ3Ng1sN3IjiDWQP4qExbnv9p+aLaxN CZXJoMuWQ7hYufcmGi4kxxSuTa5exdVw0DlA+QSO/oRyzM9Iu5op4zRiWKup+h49KttOtG 5QN+oojETcYc2nhF4oE3SXoOP8dU/cg= Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-375-xIi-CTXWP5Oe5zmuHuuMzg-1; Thu, 24 Oct 2019 14:56:49 -0400 Received: by mail-ua1-f69.google.com with SMTP id b5so473459uap.6 for ; Thu, 24 Oct 2019 11:56:49 -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=luTiRurqFeAMxCUhsah2IdPQLAXgo17rfkJBpYOWjJo=; b=hDYtzKdFyYr02eNDEdwTZWMXN5CqOV9cko4/RZpsx5GBJqpsdfKV05iAd+ODijl4j3 m3NFWyE/hU9FODV/m15AlvuvOiiqNDxK8h8V4JkaMXCOoP3mNhW5F5mAvoJnATdqxg9l ygBLKe2YfxBMCHYL0N+92/6PxZD9brWAKVtzl7h6PQVMcm+j1OFYRNmPnB4KVnZh/Ywb zcWOVzRXzJN8L/ysMMkXdFjbR+E01gXw6MrJY2CqFJV4VtfEyIROELhHZu4j68djQ4ea ybkgouXOwY6rbdgW6pJrDAUvUJOcIb6r2Xj43AXf5vox+7ggGXjH7cCnlcLkL3K5SlL5 iOXQ== X-Gm-Message-State: APjAAAXWMiDc9flx9lp+QUh4gu83n5jxzpQ9txivZ2zn2jnhU9DZC0st /voXs4eKpqq45lGO/yLABQJm2CQNYNg8uX7ql0gqdujEdXh0XyfJAwffe+N+fR0d5wbSLaAosS1 L9OWrL7x3503NI1GPOyU= X-Received: by 2002:a9f:3772:: with SMTP id a47mr1731282uae.53.1571943409018; Thu, 24 Oct 2019 11:56:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhaNp8lgpwwDcP+l/6FSGAXgXyqpAYldVc2iSWGIDqeUVAR9nOOGZhWycO8Ogmazwg0eGoi6StP3QMn+lXF6I= X-Received: by 2002:a9f:3772:: with SMTP id a47mr1731256uae.53.1571943408359; Thu, 24 Oct 2019 11:56:48 -0700 (PDT) MIME-Version: 1.0 References: <26384fad6f9afcba9d3311d1bf73e76f4577225d.1563276298.git.anatoly.burakov@intel.com> In-Reply-To: From: David Marchand Date: Thu, 24 Oct 2019 20:56:37 +0200 Message-ID: To: Anatoly Burakov Cc: dev , John McNamara , Marko Kovacevic , Bruce Richardson , Thomas Monjalon X-MC-Unique: xIi-CTXWP5Oe5zmuHuuMzg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH v2 1/2] eal/freebsd: add support for base virtaddr option 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 5:18 PM Anatoly Burakov wrote: > > According to our docs, only Linuxapp supports base-virtaddr option. > That is, strictly speaking, not true because most of the things > that are attempting to respect base-virtaddr are in common files, > so FreeBSD already *mostly* supports this option in practice. > > This commit fixes the remaining bits to explicitly support > base-virtaddr option, and moves the arg parsing from EAL to common > options parsing code. Documentation is also updated to reflect > that all platforms now support base-virtaddr. > > Signed-off-by: Anatoly Burakov > Reviewed-by: David Marchand > --- > > Notes: > v2: > - Harmonize FreeBSD reattach implementation with Linux > > doc/guides/linux_gsg/eal_args.include.rst | 6 +++ > doc/guides/linux_gsg/linux_eal_parameters.rst | 6 --- > doc/guides/rel_notes/release_19_11.rst | 5 +++ > lib/librte_eal/common/eal_common_options.c | 38 ++++++++++++++++++ I was about to apply it, and I realised that the usage() in Linux still references the --base-virtaddr option but it was not moved to the common code. What do you think of this hunk? diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 1cdbd35..020f36e 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1692,6 +1692,7 @@ static int xdigit2val(unsigned char c) " --"OPT_NO_PCI" Disable PCI\n" " --"OPT_NO_HPET" Disable HPET\n" " --"OPT_NO_SHCONF" No shared config (mmap'd files)= \n" + " --"OPT_BASE_VIRTADDR" Base virtual address\n" "\n", RTE_MAX_LCORE); rte_option_usage(); } diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.= c index ef5dafa..c0aac21 100644 --- a/lib/librte_eal/linux/eal/eal.c +++ b/lib/librte_eal/linux/eal/eal.c @@ -539,7 +539,6 @@ enum rte_proc_type_t " --"OPT_SOCKET_LIMIT" Limit memory allocation on sockets (comma separated values)\n" " --"OPT_HUGE_DIR" Directory where hugetlbfs is mounted\n" " --"OPT_FILE_PREFIX" Prefix for hugepage filenames\n= " - " --"OPT_BASE_VIRTADDR" Base virtual address\n" " --"OPT_CREATE_UIO_DEV" Create /dev/uioX (usually done by hotplug)\n" " --"OPT_VFIO_INTR" Interrupt mode for VFIO (legacy|msi|msix)\n" " --"OPT_LEGACY_MEM" Legacy memory mode (no dynamic allocation, contiguous segments)\n" > lib/librte_eal/freebsd/eal/eal.c | 31 ++++++++++----- > lib/librte_eal/linux/eal/eal.c | 39 ------------------- > 6 files changed, 70 insertions(+), 55 deletions(-) > > diff --git a/doc/guides/linux_gsg/eal_args.include.rst b/doc/guides/linux= _gsg/eal_args.include.rst > index cf421a56eb..ed8b0e35b0 100644 > --- a/doc/guides/linux_gsg/eal_args.include.rst > +++ b/doc/guides/linux_gsg/eal_args.include.rst > @@ -86,6 +86,12 @@ Multiprocessing-related options > > Set the type of the current process. > > +* ``--base-virtaddr
`` > + > + Attempt to use a different starting address for all memory maps of t= he > + primary DPDK process. This can be helpful if secondary processes can= not > + start due to conflicts in address map. > + > Memory-related options > ~~~~~~~~~~~~~~~~~~~~~~ > > diff --git a/doc/guides/linux_gsg/linux_eal_parameters.rst b/doc/guides/l= inux_gsg/linux_eal_parameters.rst > index c63f0f49a0..b2cc60e447 100644 > --- a/doc/guides/linux_gsg/linux_eal_parameters.rst > +++ b/doc/guides/linux_gsg/linux_eal_parameters.rst > @@ -49,12 +49,6 @@ Multiprocessing-related options > allows running multiple independent DPDK primary/secondary processes= under > different prefixes. > > -* ``--base-virtaddr
`` > - > - Attempt to use a different starting address for all memory maps of t= he > - primary DPDK process. This can be helpful if secondary processes can= not > - start due to conflicts in address map. > - > Memory-related options > ~~~~~~~~~~~~~~~~~~~~~~ > > diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_note= s/release_19_11.rst > index 856088c5c7..95231d13dd 100644 > --- a/doc/guides/rel_notes/release_19_11.rst > +++ b/doc/guides/rel_notes/release_19_11.rst > @@ -56,6 +56,11 @@ New Features > Also, make sure to start the actual text at the margin. > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > +* **FreeBSD now supports `--base-virtaddr` EAL option.** > + > + FreeBSD version now also supports setting base virtual address for map= ping > + pages and resources into its address space. > + > * **Added Lock-free Stack for aarch64.** > > The lock-free stack implementation is enabled for aarch64 platforms. > diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/= common/eal_common_options.c > index 05cae5f75c..1cdbd35655 100644 > --- a/lib/librte_eal/common/eal_common_options.c > +++ b/lib/librte_eal/common/eal_common_options.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1095,6 +1096,36 @@ eal_parse_iova_mode(const char *name) > return 0; > } > > +static int > +eal_parse_base_virtaddr(const char *arg) > +{ > + char *end; > + uint64_t addr; > + > + errno =3D 0; > + addr =3D strtoull(arg, &end, 16); > + > + /* check for errors */ > + if ((errno !=3D 0) || (arg[0] =3D=3D '\0') || end =3D=3D NULL || = (*end !=3D '\0')) > + return -1; > + > + /* make sure we don't exceed 32-bit boundary on 32-bit target */ > +#ifndef RTE_ARCH_64 > + if (addr >=3D UINTPTR_MAX) > + return -1; > +#endif > + > + /* align the addr on 16M boundary, 16MB is the minimum huge page > + * size on IBM Power architecture. If the addr is aligned to 16MB= , > + * it can align to 2MB for x86. So this alignment can also be use= d > + * on x86 and other architectures. > + */ > + internal_config.base_virtaddr =3D > + RTE_PTR_ALIGN_CEIL((uintptr_t)addr, (size_t)RTE_PGSIZE_16= M); > + > + return 0; > +} > + > /* caller is responsible for freeing the returned string */ > static char * > available_cores(void) > @@ -1408,6 +1439,13 @@ eal_parse_common_option(int opt, const char *optar= g, > return -1; > } > break; > + case OPT_BASE_VIRTADDR_NUM: > + if (eal_parse_base_virtaddr(optarg) < 0) { > + RTE_LOG(ERR, EAL, "invalid parameter for --" > + OPT_BASE_VIRTADDR "\n"); > + return -1; > + } > + break; > > /* don't know what to do, leave this to caller */ > default: > diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/ea= l/eal.c > index f86e9aa318..c7e1264205 100644 > --- a/lib/librte_eal/freebsd/eal/eal.c > +++ b/lib/librte_eal/freebsd/eal/eal.c > @@ -226,6 +226,14 @@ rte_eal_config_create(void) > if (internal_config.no_shconf) > return 0; > > + /* map the config before base address so that we don't waste a pa= ge */ > + 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_S= IZE)); > + else > + rte_mem_cfg_addr =3D NULL; > + > if (mem_cfg_fd < 0){ > mem_cfg_fd =3D open(pathname, O_RDWR | O_CREAT, 0600); > if (mem_cfg_fd < 0) { > @@ -253,8 +261,9 @@ 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); > + rte_mem_cfg_addr =3D mmap(rte_mem_cfg_addr, > + sizeof(*rte_config.mem_config), PROT_READ | PROT_= WRITE, > + MAP_SHARED, mem_cfg_fd, 0); > > if (rte_mem_cfg_addr =3D=3D MAP_FAILED){ > RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config\n"); > @@ -332,15 +341,17 @@ rte_eal_config_reattach(void) > close(mem_cfg_fd); > mem_cfg_fd =3D -1; > > - if (mem_config =3D=3D MAP_FAILED) { > + if (mem_config =3D=3D MAP_FAILED || mem_config !=3D rte_mem_cfg_a= ddr) { > + if (mem_config !=3D MAP_FAILED) { > + /* errno is stale, don't use */ > + RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_con= fig at [%p], got [%p]" > + " - please use '--base-virtaddr= ' option\n", > + rte_mem_cfg_addr, mem_config); > + munmap(mem_config, sizeof(struct rte_mem_config))= ; > + return -1; > + } > RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! err= or %i (%s)\n", > - errno, strerror(errno)); > - return -1; > - } else if (mem_config !=3D rte_mem_cfg_addr) { > - /* errno is stale, don't use */ > - RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config at [= %p], got [%p]\n", > - rte_mem_cfg_addr, mem_config); > - munmap(mem_config, sizeof(struct rte_mem_config)); > + errno, strerror(errno)); > return -1; > } > > diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/ea= l.c > index f39720637f..ef5dafa94f 100644 > --- a/lib/librte_eal/linux/eal/eal.c > +++ b/lib/librte_eal/linux/eal/eal.c > @@ -611,35 +611,6 @@ eal_parse_socket_arg(char *strval, volatile uint64_t= *socket_arg) > return 0; > } > > -static int > -eal_parse_base_virtaddr(const char *arg) > -{ > - char *end; > - uint64_t addr; > - > - errno =3D 0; > - addr =3D strtoull(arg, &end, 16); > - > - /* check for errors */ > - if ((errno !=3D 0) || (arg[0] =3D=3D '\0') || end =3D=3D NULL || = (*end !=3D '\0')) > - return -1; > - > - /* make sure we don't exceed 32-bit boundary on 32-bit target */ > -#ifndef RTE_ARCH_64 > - if (addr >=3D UINTPTR_MAX) > - return -1; > -#endif > - > - /* align the addr on 16M boundary, 16MB is the minimum huge page > - * size on IBM Power architecture. If the addr is aligned to 16MB= , > - * it can align to 2MB for x86. So this alignment can also be use= d > - * on x86 */ > - internal_config.base_virtaddr =3D > - RTE_PTR_ALIGN_CEIL((uintptr_t)addr, (size_t)RTE_PGSIZE_16= M); > - > - return 0; > -} > - > static int > eal_parse_vfio_intr(const char *mode) > { > @@ -798,16 +769,6 @@ eal_parse_args(int argc, char **argv) > internal_config.force_socket_limits =3D 1; > break; > > - case OPT_BASE_VIRTADDR_NUM: > - if (eal_parse_base_virtaddr(optarg) < 0) { > - RTE_LOG(ERR, EAL, "invalid parameter for = --" > - OPT_BASE_VIRTADDR "\n"); > - eal_usage(prgname); > - ret =3D -1; > - goto out; > - } > - break; > - > case OPT_VFIO_INTR_NUM: > if (eal_parse_vfio_intr(optarg) < 0) { > RTE_LOG(ERR, EAL, "invalid parameters for= --" > -- > 2.17.1