[dpdk-dev] [PATCH] eal: restrict ctrl threads to startup cpu affinity
David Marchand
david.marchand at redhat.com
Wed Feb 13 21:21:20 CET 2019
On Wed, Feb 13, 2019 at 5:14 PM David Marchand <david.marchand at redhat.com>
wrote:
> Spawning the ctrl threads on anything that is not part of the eal
> coremask is not that polite to the rest of the system.
>
> Rather than introduce yet another eal options for this, let's take
> the startup cpu affinity as a reference and remove the eal coremask
> from it.
> If no cpu is left, then we default to the master core.
>
> The cpuset is computed once at init before the original cpu affinity.
>
Need to fix this last sentence...
> Fixes: d651ee4919cd ("eal: set affinity for control threads")
> Signed-off-by: David Marchand <david.marchand at redhat.com>
> ---
> lib/librte_eal/common/eal_common_options.c | 28
> ++++++++++++++++++++++++++++
> lib/librte_eal/common/eal_common_thread.c | 21 ++++-----------------
> lib/librte_eal/common/eal_internal_cfg.h | 3 +++
> 3 files changed, 35 insertions(+), 17 deletions(-)
>
> diff --git a/lib/librte_eal/common/eal_common_options.c
> b/lib/librte_eal/common/eal_common_options.c
> index 6c96f45..b766252 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -1360,6 +1361,31 @@ static int xdigit2val(unsigned char c)
> cfg->lcore_count -= removed;
> }
>
> +static void
> +compute_ctrl_threads_cpuset(struct internal_config *internal_cfg)
> +{
> + rte_cpuset_t *cpuset = &internal_cfg->ctrl_cpuset;
> + rte_cpuset_t default_set;
> + unsigned int lcore_id;
> +
> + for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
> + if (eal_cpu_detected(lcore_id) &&
> + rte_lcore_has_role(lcore_id, ROLE_OFF)) {
> + CPU_SET(lcore_id, cpuset);
> + }
> + }
> +
> + if (pthread_getaffinity_np(pthread_self(), sizeof(rte_cpuset_t),
> + &default_set) < 0)
> + CPU_ZERO(&default_set);
> +
> + CPU_AND(cpuset, cpuset, &default_set);
>
CPU_AND is different on Freebsd.
*CPU*_*AND*(*cpuset*_*t* **dst*, *cpuset*_*t* **src*);
The *CPU*_*AND*() macro removes CPUs absent from *src* from
*dst*. (It is the
*cpuset(9)*
<https://www.freebsd.org/cgi/man.cgi?query=cpuset&sektion=9&apropos=0&manpath=FreeBSD+11.0-RELEASE+and+Ports>
equivalent of the scalar: *dst* &= *src*.) *CPU*_*AND*_*ATOMIC*() is
similar, with the same atomic semantics as *CPU*_*OR*_*ATOMIC*().
Will fix in v2.
--
David Marchand
More information about the dev
mailing list