[dpdk-dev] [PATCH v6 51/70] mem: add support for mapping hugepages at runtime

Yongseok Koh yskoh at mellanox.com
Tue Apr 17 04:06:28 CEST 2018


> On Apr 11, 2018, at 5:30 AM, Anatoly Burakov <anatoly.burakov at intel.com> wrote:
> 
> Nothing uses this code yet. The bulk of it is copied from old
> memory allocation code (linuxapp eal_memory.c). We provide an
> EAL-internal API to allocate either one page or multiple pages,
> guaranteeing that we'll get contiguous VA for all of the pages
> that we requested.
> 
> Not supported on FreeBSD.
> 
> Locking is done via fcntl() because that way, when it comes to
> taking out write locks or unlocking on deallocation, we don't
> have to keep original fd's around. Plus, using fcntl() gives us
> ability to lock parts of a file, which is useful for single-file
> segments, which are coming down the line.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
> Tested-by: Santosh Shukla <santosh.shukla at caviumnetworks.com>
> Tested-by: Hemant Agrawal <hemant.agrawal at nxp.com>
> Tested-by: Gowrishankar Muthukrishnan <gowrishankar.m at linux.vnet.ibm.com>
> ---
[...]
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memalloc.c b/lib/librte_eal/linuxapp/eal/eal_memalloc.c
> new file mode 100644
> index 0000000..45ea0ad
> --- /dev/null
> +++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c
> @@ -0,0 +1,429 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2017-2018 Intel Corporation
> + */
> +
> +#define _FILE_OFFSET_BITS 64
> +#include <errno.h>
> +#include <stdarg.h>
> +#include <stdbool.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <stdint.h>
> +#include <inttypes.h>
> +#include <string.h>
> +#include <sys/mman.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <sys/queue.h>
> +#include <sys/file.h>
> +#include <unistd.h>
> +#include <limits.h>
> +#include <fcntl.h>

There's a bug in the old RedHat release:
Bug 1476120 - glibc headers don't include linux/falloc.h, and therefore doesn't include fallocate() flags [1]

How about adding "#include <linux/falloc.h>" ahead of fcntl.h?  I'm quite lazy
to update my host and using CentOS 7.2.1511, then it failed to compile due to
this bug.


[1] https://bugzilla.redhat.com/show_bug.cgi?id=1476120

Thanks,
Yongseok


More information about the dev mailing list