From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-f194.google.com (mail-vk1-f194.google.com [209.85.221.194]) by dpdk.org (Postfix) with ESMTP id 7C6361B202 for ; Wed, 13 Feb 2019 21:21:32 +0100 (CET) Received: by mail-vk1-f194.google.com with SMTP id v131so621145vkd.3 for ; Wed, 13 Feb 2019 12:21:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DqOpcI97crOzFP9QyJDysFTr9y8EtXRy/zsmj/zRigg=; b=Q5RDQnSY8WDj2M24j5OIC+n9Gt4cPvmNInzsULlo9VnqMFTYsBnpGwm6zTqGA9VSbs SwDh1VEZtgzgYYGj2XbW/xksLTgM4pNY7tqobQLEiEsLYwysYJOZ+vNVtuBmpAw1ROnU aokryo+unmm2EaLHoZTDHsrAPv3egogUk73/F/jiwDsCzdU6H99KqONI8aVOm2NokqJn v3qgSSO/0d13EUPcmv6XVixvQXQ326D4+Qzrli8noGur2xt1V7vVpn4/I+cCgWjxdjpq eIZv0gB0fTz1IOXDayWn/qTtpKeaxkQM7ZVQteo/rI3iHconrMPbvCLoq5YXij1gfcR6 FD+Q== X-Gm-Message-State: AHQUAub+z9QyBHvRb/wirFYXCsNutbDLRaG7ThPQcpdBJ1eIlPrdpq6A p+AZkFFG56hDC0YsLoP+LNcX0/ZZiRh4rdBpOXF3TJmTiPk= X-Google-Smtp-Source: AHgI3IbXWTq8tZRkYoPaHu72Y7uhW27t+iLtV7V1IM6i+GreusHP2/JOaR0VqgEJo9QU9xon15Ah7/pK+42lg2gj+kQ= X-Received: by 2002:a1f:35f:: with SMTP id 92mr428740vkd.52.1550089291703; Wed, 13 Feb 2019 12:21:31 -0800 (PST) MIME-Version: 1.0 References: <1550074412-31285-1-git-send-email-david.marchand@redhat.com> In-Reply-To: <1550074412-31285-1-git-send-email-david.marchand@redhat.com> From: David Marchand Date: Wed, 13 Feb 2019 21:21:20 +0100 Message-ID: To: dev@dpdk.org Cc: Olivier Matz , "Burakov, Anatoly" , Kevin Traynor , dpdk stable Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] eal: restrict ctrl threads to startup cpu affinity X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Feb 2019 20:21:32 -0000 On Wed, Feb 13, 2019 at 5:14 PM David Marchand 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 > --- > 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)* 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