> Subject: [dpdk-dev] [PATCH v3 5/6] app/testpmd: add rte_mem_lockall in
> librte_eal
> 
> External email: Use caution opening links or attachments
> 
> 
> In order to replace POSIX mman APIs in testpmd, add rte_mem_lockall.
> - On Unix, it is a wrapper of mlockall
> - On Windows, it is just a stub
> 
> Signed-off-by: Jie Zhou <j...@microsoft.com>
> Signed-off-by: Jie Zhou <j...@linux.microsoft.com>
> ---
>  lib/librte_eal/include/rte_eal_paging.h | 20 ++++++++++++++++++++
>  lib/librte_eal/unix/eal_unix_memory.c   | 13 +++++++++++++
>  lib/librte_eal/version.map              |  1 +
>  lib/librte_eal/windows/eal_memory.c     | 10 ++++++++++
>  4 files changed, 44 insertions(+)
> 
> diff --git a/lib/librte_eal/include/rte_eal_paging.h
> b/lib/librte_eal/include/rte_eal_paging.h
> index ed98e70e9..959c2e135 100644
> --- a/lib/librte_eal/include/rte_eal_paging.h
> +++ b/lib/librte_eal/include/rte_eal_paging.h
> @@ -37,6 +37,14 @@ enum rte_map_flags {
>         RTE_MAP_FORCE_ADDRESS = 1 << 3
>  };
> 
> +/** Flags for memory lockall. */
> +enum rte_mem_lockall_flags {
> +       /** Lock all pages currently mapped into process's address space. */
> +       RTE_MCL_CURRENT = 1 << 0,
> +       /** Lock all pages mapped into process's address space in the 
> future.*/
> +       RTE_MCL_FUTURE = 1 << 1
> +};
> +
>  /**
>   * Map a portion of an opened file or the page file into memory.
>   *
> @@ -96,3 +104,15 @@ rte_mem_page_size(void);  __rte_internal  int
> rte_mem_lock(const void *virt, size_t size);
> +
> +/**
> + * locks all pages mapped into the address space of the calling process.
> + *
> + * @param flags
> + *  Memory lockall flags, a combination of rte_mem_lockall_flags.
> + * @return
> + *   0 on success, negative on error.
> + */
> +__rte_internal
> +int
> +rte_mem_lockall(int flags);
> diff --git a/lib/librte_eal/unix/eal_unix_memory.c
> b/lib/librte_eal/unix/eal_unix_memory.c
> index ec7156df9..90e0c547a 100644
> --- a/lib/librte_eal/unix/eal_unix_memory.c
> +++ b/lib/librte_eal/unix/eal_unix_memory.c
> @@ -150,3 +150,16 @@ rte_mem_lock(const void *virt, size_t size)
>                 rte_errno = errno;
>         return ret;
>  }
> +
> +int
> +rte_mem_lockall(int flags)
> +{
> +       int mlockall_flags = 0;
> +
> +       if (flags & RTE_MCL_CURRENT)
> +               mlockall_flags |= MCL_CURRENT;
> +       if (flags & RTE_MCL_FUTURE)
> +               mlockall_flags |= MCL_FUTURE;
> +
> +       return mlockall(mlockall_flags); }
> diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map index
> e7217ae28..8dd8333e5 100644
> --- a/lib/librte_eal/version.map
> +++ b/lib/librte_eal/version.map
> @@ -431,4 +431,5 @@ INTERNAL {
>         rte_mem_map;
>         rte_mem_page_size;
>         rte_mem_unmap;
> +       rte_mem_lockall;

Please keep alphabetical order.

>  };
> diff --git a/lib/librte_eal/windows/eal_memory.c
> b/lib/librte_eal/windows/eal_memory.c
> index 2cf5a5e64..4fe7e59a1 100644
> --- a/lib/librte_eal/windows/eal_memory.c
> +++ b/lib/librte_eal/windows/eal_memory.c
> @@ -715,3 +715,13 @@ rte_eal_hugepage_attach(void)
>         EAL_LOG_NOT_IMPLEMENTED();
>         return -1;
>  }
> +
> +int
> +rte_mem_lockall(int flags)
> +{
> +       RTE_SET_USED(flags);
> +
> +       EAL_LOG_NOT_IMPLEMENTED();
> +
> +       return -1;
> +}
> --
> 2.30.0.vfs.0.2

Reply via email to