From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by dpdk.org (Postfix) with ESMTP id B28EA6CC7 for ; Fri, 16 Sep 2016 16:02:02 +0200 (CEST) Received: by mail-wm0-f51.google.com with SMTP id 1so43576383wmz.1 for ; Fri, 16 Sep 2016 07:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding; bh=cDOgTRJn4gD/vorq2oFY2ME1Q4uurJWbmZAjIP9QvjA=; b=TUIo9bp9AO451yZXn895s/5An8Lez+xqefpbgCTDD4qJhGDgLiU6NnidUWpXkyuaej QyMcNphgQi0x/RR/7nMN2K59q2EVJrMhg8MqgU1KS+iPpbRLyJmKw3/FLd3ZJzJUg9Eu 03mz4/bIvWx/Gm48w4majiHCkLFDQe0BYISI9cnBV7ryxB6cuyCpdX71Sx/5R7315bLf zcSBIXHQrUF7lBRuEnp3z0BfIgqSKCjf36X9jzxnLL8j3mmZ3woEU5UylEi158rHQEhl qyJV+QRqrP6IcazgBgeALP+cJRRP98qm/xJ4P8uIeRKezuSQB2SSAwgtOQQb+cRO/Scj S+UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :in-reply-to:references:mime-version:content-transfer-encoding; bh=cDOgTRJn4gD/vorq2oFY2ME1Q4uurJWbmZAjIP9QvjA=; b=Wfjx+rOGPhreGlrIlbcKhC5r8SQNMY9biGs+fBRChhRynlTS348KB4gVloOBk08F1p qSbYs7AxtiYS5edN026Kj85NwOrPwKYpUuWZKogp23ypK+kl112sbUUZp7z66uV7Nk+0 gqvvY6lP/3rLAhYkh0XgdgsIkTX1o32BvgHS/5+dTwpTsZgkOirWqwSlKWlZbTUCdAzN 35O0CWr0+x7MP/8eZbrOdUWrMhfZRXuC9bEGcDxpopW0SzGY6aiiLIPTCcuMAAHm4DQm BYYCcNRjRrpDhRW3pk5Q5sof0gl4PvJ4MeHePCf1V6dpIHZTKnAdicb9gwxD0Qv0yfna WuqA== X-Gm-Message-State: AE9vXwMffFL7K8vbXB1bEPU9Bs4NXAC9TQjHriAL5DB36uuHjU8ToXDyoXRLs9Ub/0to5j3b X-Received: by 10.28.156.16 with SMTP id f16mr7772987wme.56.1474034522481; Fri, 16 Sep 2016 07:02:02 -0700 (PDT) Received: from xps13.localnet (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id u129sm7566206wmb.11.2016.09.16.07.02.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Sep 2016 07:02:01 -0700 (PDT) Date: Fri, 16 Sep 2016 07:02:01 -0700 (PDT) X-Google-Original-Date: Fri, 16 Sep 2016 16:02 +0200 From: Thomas Monjalon To: Jianfeng Tan Cc: dev@dpdk.org, david.marchand@6wind.com, pmatilai@redhat.com, stephen@networkplumber.org Message-ID: <2025520.348ocWrbUD@xps13> User-Agent: KMail/4.14.10 (Linux/4.5.4-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: <1472693507-11369-1-git-send-email-jianfeng.tan@intel.com> References: <1453661393-85704-1-git-send-email-jianfeng.tan@intel.com> <1472693507-11369-1-git-send-email-jianfeng.tan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v3] eal: restrict cores detection X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Sep 2016 14:02:02 -0000 2016-09-01 01:31, Jianfeng Tan: > This patch uses pthread_getaffinity_np() to narrow down detected > cores before parsing coremask (-c), corelist (-l), and coremap > (--lcores). > > The purpose of this patch is to leave out these core related options > when DPDK applications are deployed under container env, so that > users only specify core restriction as starting the instance. [...] > --- a/lib/librte_eal/common/eal_common_lcore.c > +++ b/lib/librte_eal/common/eal_common_lcore.c > @@ -57,6 +57,12 @@ rte_eal_cpu_init(void) > struct rte_config *config = rte_eal_get_configuration(); > unsigned lcore_id; > unsigned count = 0; > + rte_cpuset_t affinity_set; > + pthread_t tid = pthread_self(); > + A comment is needed here to explain which errors we are checking. > + if (pthread_getaffinity_np(tid, sizeof(rte_cpuset_t), > + &affinity_set) < 0) > + CPU_ZERO(&affinity_set); > > /* > * Parse the maximum set of logical cores, detect the subset of running > @@ -70,7 +76,8 @@ rte_eal_cpu_init(void) > > /* in 1:1 mapping, record related cpu detected state */ > lcore_config[lcore_id].detected = eal_cpu_detected(lcore_id); > - if (lcore_config[lcore_id].detected == 0) { > + if (lcore_config[lcore_id].detected == 0 || > + !CPU_ISSET(lcore_id, &affinity_set)) { > config->lcore_role[lcore_id] = ROLE_OFF; > lcore_config[lcore_id].core_index = -1; > continue; >