[RFC PATCH v1 5/5] lcore: store physical package ID internally

Stephen Hemminger stephen at networkplumber.org
Mon Oct 14 19:31:01 CEST 2024


On Fri,  6 Sep 2024 12:47:31 +0100
Anatoly Burakov <anatoly.burakov at intel.com> wrote:

> +/*
> + * Get CPU package ID for a logical core.
> + *
> + * This searches each nodeX directories in /sys for the symlink for the given
> + * lcore_id and returns the numa node where the lcore is found. If lcore is not
> + * found on any numa node, returns zero.
> + */
> +unsigned
> +eal_cpu_package_id(unsigned lcore_id)
> +{
> +	char path[PATH_MAX];
> +	unsigned long id;
> +
> +	int len = snprintf(path, sizeof(path),
> +			SYS_CPU_DIR "/%s", lcore_id, PACKAGE_ID_FILE);
> +	if (len <= 0 || (unsigned)len >= sizeof(path))
> +		goto err;
> +	if (eal_parse_sysfs_value(path, &id) != 0)
> +		goto err;
> +	return (unsigned)id;
> +
> +err:
> +	EAL_LOG(ERR, "Error reading package id value from %s "
> +			"for lcore %u - assuming package 0", SYS_CPU_DIR, lcore_id);
> +	return 0;
> +}

This is wrong. Lcore Id is not always the same as the CPU number in the system.

Also, it is not clear while package != numa node is something we want DPDK
to start supporting. Adding yet another layer adds complexity.


More information about the dev mailing list