DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Anatoly Burakov <anatoly.burakov@intel.com>
Cc: dev <dev@dpdk.org>, Bruce Richardson <bruce.richardson@intel.com>,
	 Stephen Hemminger <stephen@networkplumber.org>,
	Li Han <han.li1@zte.com.cn>,  dpdk stable <stable@dpdk.org>
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v5 2/2] eal: use base address hint to reserve space for mem config
Date: Sat, 26 Oct 2019 18:02:23 +0200	[thread overview]
Message-ID: <CAJFAV8zUoxZE27s7scz44+0Tj_WGreKnB6CjRX7ZhiJaknFhXw@mail.gmail.com> (raw)
In-Reply-To: <e8d1128c93881950d23d44913ebec32cf3e5313e.1571920604.git.anatoly.burakov@intel.com>

On Thu, Oct 24, 2019 at 2:37 PM Anatoly Burakov
<anatoly.burakov@intel.com> 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 <anatoly.burakov@intel.com>
> ---
>
> 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/eal/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 = sysconf(_SC_PAGE_SIZE);
> +       size_t cfg_len = sizeof(*rte_config.mem_config);
> +       size_t cfg_len_aligned = RTE_ALIGN(cfg_len, page_sz);
> +       void *rte_mem_cfg_addr, *mapped_mem_cfg_addr;
>         int retval;
>
>         const char *pathname = eal_runtime_config_path();

Updated existing call to sysconf with page_sz variable.

       if (internal_config.base_virtaddr != 0)
               rte_mem_cfg_addr = (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 = NULL;


> @@ -235,7 +238,7 @@ rte_eal_config_create(void)
>                 }
>         }
>
> -       retval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));
> +       retval = ftruncate(mem_cfg_fd, cfg_len);
>         if (retval < 0){
>                 close(mem_cfg_fd);
>                 mem_cfg_fd = -1;
> @@ -253,15 +256,28 @@ rte_eal_config_create(void)
>                 return -1;
>         }
>
> -       rte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),
> -                               PROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);
> -
> -       if (rte_mem_cfg_addr == MAP_FAILED){
> +       /* reserve space for config */
> +       rte_mem_cfg_addr = eal_get_virtual_area(NULL, &cfg_len_aligned, page_sz,
> +                       0, 0);

Fixed conflict with base-virtaddr patches.

> +       if (rte_mem_cfg_addr == NULL) {
>                 RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config\n");
>                 close(mem_cfg_fd);
>                 mem_cfg_fd = -1;
>                 return -1;
>         }

Applied, thanks.


--
David Marchand


  reply	other threads:[~2019-10-26 16:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-29 12:42 [dpdk-dev] [PATCH 1/2] eal: make base address hint OS-specific Anatoly Burakov
2019-07-29 11:10 ` Anatoly Burakov
2019-07-29 11:18 ` Anatoly Burakov
2019-07-29 12:42 ` [dpdk-dev] [PATCH 2/2] eal: use base address hint to reserve space for mem config Anatoly Burakov
2019-07-29 11:10   ` Anatoly Burakov
2019-07-29 11:18   ` Anatoly Burakov
2019-07-29 13:13   ` Burakov, Anatoly
2019-07-30 15:37 ` [dpdk-dev] [PATCH v2 1/2] eal: make base address hint OS-specific Anatoly Burakov
2019-07-30 15:51   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2019-07-31 12:47     ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
2019-10-02 11:41       ` David Marchand
2019-10-02 14:42         ` Stephen Hemminger
2019-10-24 12:32           ` Burakov, Anatoly
2019-10-24 12:32         ` Burakov, Anatoly
2019-10-24 12:36       ` [dpdk-dev] [PATCH v5 " Anatoly Burakov
2019-10-26 16:02         ` [dpdk-dev] [dpdk-stable] " David Marchand
2019-10-24 12:36       ` [dpdk-dev] [PATCH v5 2/2] eal: use base address hint to reserve space for mem config Anatoly Burakov
2019-10-26 16:02         ` David Marchand [this message]
2019-07-31 12:47     ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
2019-07-30 15:51   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2019-07-30 15:37 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJFAV8zUoxZE27s7scz44+0Tj_WGreKnB6CjRX7ZhiJaknFhXw@mail.gmail.com \
    --to=david.marchand@redhat.com \
    --cc=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=han.li1@zte.com.cn \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).