[dpdk-dev] [RFC 02/11] eal: add function to rerieve socket index by socket ID
Alejandro Lucero
alejandro.lucero at netronome.com
Tue Jul 10 15:03:32 CEST 2018
On Fri, Jul 6, 2018 at 2:17 PM, Anatoly Burakov <anatoly.burakov at intel.com>
wrote:
> We are preparing to switch to index heap based on heap indexes
> rather than by NUMA nodes. First few indexes will be equal to
> NUMA node ID indexes. For example, currently on a machine with
> NUMA nodes [0, 8], heaps 0 and 8 will be active, while we want
> to make it so that heaps 0 and 1 are active. However, currently
> we don't have a function to map a specific NUMA node to a node
> index, so add it in this patch.
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
> ---
> lib/librte_eal/common/eal_common_lcore.c | 15 +++++++++++++++
> lib/librte_eal/common/include/rte_lcore.h | 19 ++++++++++++++++++-
> lib/librte_eal/rte_eal_version.map | 1 +
> 3 files changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/common/eal_common_lcore.c
> b/lib/librte_eal/common/eal_common_lcore.c
> index 3167e9d79..579f5a0a1 100644
> --- a/lib/librte_eal/common/eal_common_lcore.c
> +++ b/lib/librte_eal/common/eal_common_lcore.c
> @@ -132,3 +132,18 @@ rte_socket_id_by_idx(unsigned int idx)
> }
> return config->numa_nodes[idx];
> }
> +
> +int __rte_experimental
> +rte_socket_idx_by_id(unsigned int socket)
> +{
> + const struct rte_config *config = rte_eal_get_configuration();
> + int i;
> +
> + for (i = 0; i < (int) config->numa_node_count; i++) {
> + unsigned int cur_socket = config->numa_nodes[i];
> + if (cur_socket == socket)
> + return i;
> + }
> + rte_errno = EINVAL;
> + return -1;
> +}
> diff --git a/lib/librte_eal/common/include/rte_lcore.h
> b/lib/librte_eal/common/include/rte_lcore.h
> index 6e09d9181..f58cda09a 100644
> --- a/lib/librte_eal/common/include/rte_lcore.h
> +++ b/lib/librte_eal/common/include/rte_lcore.h
> @@ -156,11 +156,28 @@ rte_socket_count(void);
> *
> * @return
> * - physical socket id as recognized by EAL
> - * - -1 on error, with errno set to EINVAL
> + * - -1 on error, with rte_errno set to EINVAL
> */
> int __rte_experimental
> rte_socket_id_by_idx(unsigned int idx);
>
> +/**
> + * Return index for a particular socket id.
> + *
> + * This will return position in list of all detected physical socket id's
> for a
> + * given socket. For example, on a machine with sockets [0, 8], passing
> + * 8 as a parameter will return 1.
> + *
> + * @param socket
> + * physical socket id to return index for
> + *
> + * @return
> + * - index of physical socket id as recognized by EAL
> + * - -1 on error, with rte_errno set to EINVAL
> + */
> +int __rte_experimental
> +rte_socket_idx_by_id(unsigned int socket);
> +
> /**
> * Get the ID of the physical socket of the specified lcore
> *
> diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_
> version.map
> index f7dd0e7bc..e7fb37b2a 100644
> --- a/lib/librte_eal/rte_eal_version.map
> +++ b/lib/librte_eal/rte_eal_version.map
> @@ -296,6 +296,7 @@ EXPERIMENTAL {
> rte_mp_sendmsg;
> rte_socket_count;
> rte_socket_id_by_idx;
> + rte_socket_idx_by_id;
> rte_vfio_dma_map;
> rte_vfio_dma_unmap;
> rte_vfio_get_container_fd;
> --
> 2.17.1
>
Acked-by: Alejandro Lucero <alejandro.lucero at netronome.com>
More information about the dev
mailing list