patches for DPDK stable branches
 help / color / mirror / Atom feed
From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Alejandro Lucero <alejandro.lucero@netronome.com>, dev@dpdk.org
Cc: stable@dpdk.org, maxime.coquelin@redhat.com
Subject: Re: [dpdk-stable] [PATCH v2 4/6] mem: use address hint for mapping hugepages
Date: Tue, 3 Jul 2018 13:37:08 +0100	[thread overview]
Message-ID: <7e2608f0-24e5-a356-bfe2-9d2980f0f736@intel.com> (raw)
In-Reply-To: <1530619789-33337-5-git-send-email-alejandro.lucero@netronome.com>

On 03-Jul-18 1:09 PM, Alejandro Lucero wrote:
> Linux kernel uses a really high address as starting address for
> serving mmaps calls. If there exists addressing limitations and
> IOVA mode is VA, this starting address is likely too high for
> those devices. However, it is possible to use a lower address in
> the process virtual address space as with 64 bits there is a lot
> of available space.
> 
> This patch adds an address hint as starting address for 64 bits
> systems.
> 
> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
> ---

<snip>

> +static void *
> +get_addr_hint(void)
> +{
> +	if (internal_config.base_virtaddr != 0) {
> +		return (void *) (uintptr_t)
> +			    (internal_config.base_virtaddr +
> +			     baseaddr_offset);
> +	}
> +#ifdef RTE_ARCH_64
> +	else {
> +		return (void *) (uintptr_t) (baseaddr +
> +				baseaddr_offset);
> +	}
> +#else
> +	else {
> +		return NULL;
> +	}
> +#endif

Nitpicking, but probably ifdefs should be inside else clause? Two else's 
look weird.

> +}
> +
>   /*
>    * Try to mmap *size bytes in /dev/zero. If it is successful, return the
>    * pointer to the mmap'd area and keep *size unmodified. Else, retry
> @@ -260,16 +297,10 @@
>   static void *
>   get_virtual_area(size_t *size, size_t hugepage_sz)
>   {

<snip>

> -		addr = mmap(addr,
> +		addr_hint = get_addr_hint();
> +
> +		addr = mmap(addr_hint,
>   				(*size) + hugepage_sz, PROT_READ,
>   #ifdef RTE_ARCH_PPC_64
>   				MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
> @@ -286,8 +319,15 @@
>   				MAP_PRIVATE,
>   #endif
>   				fd, 0);
> -		if (addr == MAP_FAILED)
> +		if (addr == MAP_FAILED) {
> +			/* map failed. Let's try with less memory */
>   			*size -= hugepage_sz;
> +		} else if (addr_hint && addr != addr_hint) {
> +			/* hint was not used. Try with another offset */
> +			munmap(addr, (*size) + hugepage_sz);

Maybe store mapping size in a variable.

Otherwise,

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

  reply	other threads:[~2018-07-03 12:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-03 12:09 [dpdk-stable] [PATCH v2 0/6] use IOVAs check based on DMA mask Alejandro Lucero
2018-07-03 12:09 ` [dpdk-stable] [PATCH v2 1/6] mem: add function for checking memsegs IOVAs addresses Alejandro Lucero
2018-07-03 12:37   ` Burakov, Anatoly
2018-07-03 12:09 ` [dpdk-stable] [PATCH v2 2/6] ethdev: add function for checking IOVAs by a device Alejandro Lucero
2018-07-03 12:09 ` [dpdk-stable] [PATCH v2 3/6] bus/pci: use IOVAs check when setting IOVA mode Alejandro Lucero
2018-07-03 12:09 ` [dpdk-stable] [PATCH v2 4/6] mem: use address hint for mapping hugepages Alejandro Lucero
2018-07-03 12:37   ` Burakov, Anatoly [this message]
2018-07-03 12:09 ` [dpdk-stable] [PATCH v2 5/6] net/nfp: check hugepages IOVAs based on DMA mask Alejandro Lucero
2018-07-03 12:09 ` [dpdk-stable] [PATCH v2 6/6] net/nfp: support IOVA VA mode Alejandro Lucero
2018-07-03 12:33 ` [dpdk-stable] [PATCH v2 0/6] use IOVAs check based on DMA mask Burakov, Anatoly

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=7e2608f0-24e5-a356-bfe2-9d2980f0f736@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=alejandro.lucero@netronome.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.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).