From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by dpdk.org (Postfix) with ESMTP id B76451DB1 for ; Wed, 31 Aug 2016 17:30:29 +0200 (CEST) Received: by mail-pa0-f50.google.com with SMTP id fu3so11894764pad.3 for ; Wed, 31 Aug 2016 08:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g7p6kueThlg6mNdWPt6GCxMn95kvqfBfdgYWWK94s2U=; b=ouA4ztjNdH1DfnDV+RxaqOVwWNRkoFs1CNpIXlGvT1iBQqT/yMGci9tPZYrl36isK4 ZvAZlAkHGpdE+qLM2vomK1/jisdRd7i/DldSoMFhqhItJKSJ6msE3Zuewz/oAyAA3E0Z 2BPC8RJ30oLx3gdJW+eLtl5BhHENOTmG0DMBkAM/zkd3G4VtWDT7AX7u3a5dHKmo9ZV8 pUxx/0RhMI3JLS8anpsaga/gPZinolsGa5IFamuTNUOqjqxy0795S97zPowM86KH82hX 14d6cSzqLxE1WCrySRns7ByfO3oMQL0TqT/yLRMJvnquSfSjSzK0VL2SfRQ8utt1VedL QU1A== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=g7p6kueThlg6mNdWPt6GCxMn95kvqfBfdgYWWK94s2U=; b=Oz+sddximVGoNUd5ewqeX8EE0ywx5bHokyPqNOG0/iDJAhwajp7G51Bfj3RsYBeQ5r eMlx3/Bjbe0N+ca++GR7FBG5G9edo2rpSBZ+GXI60TAKncbJYdKuF3HoHM6VGRP7pIFl +GvnaEZ1Hxh1FTW/RytDl8uj0wHgXvXYjGbyel4NBRgAr1FwuXYcIuSzDFJs7egTK+Sp wbQShnHflpX8eJ7MiLEUaa1mP6Di8zsvrdQMeFXMIRFGMkQ9OzmdcIo+7pBpNJrg0A/c vN0VXdZq9bYTQwz5KpHq5q7u3As4yKMEUOyu5uE4xk212scNEOKi0XhBscAggBG3dqdx BFXQ== X-Gm-Message-State: AE9vXwNhfQt5vmaFRrHz3bDVcdU3G6D93JXvFSOaj8s56XTqr8HphhG/tvXMc9AN7n2cWw== X-Received: by 10.66.76.9 with SMTP id g9mr17578205paw.51.1472657428964; Wed, 31 Aug 2016 08:30:28 -0700 (PDT) Received: from xeon-e3 (static-50-53-69-251.bvtn.or.frontiernet.net. [50.53.69.251]) by smtp.gmail.com with ESMTPSA id 9sm555491pfo.74.2016.08.31.08.30.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Aug 2016 08:30:28 -0700 (PDT) Date: Wed, 31 Aug 2016 08:30:40 -0700 From: Stephen Hemminger To: Jianfeng Tan Cc: dev@dpdk.org, david.marchand@6wind.com, pmatilai@redhat.com, thomas.monjalon@6wind.com Message-ID: <20160831083040.252b4dd5@xeon-e3> In-Reply-To: <1472612830-131693-1-git-send-email-jianfeng.tan@intel.com> References: <1453661393-85704-1-git-send-email-jianfeng.tan@intel.com> <1472612830-131693-1-git-send-email-jianfeng.tan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] 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: Wed, 31 Aug 2016 15:30:30 -0000 On Wed, 31 Aug 2016 03:07:10 +0000 Jianfeng Tan wrote: > 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. > > Note: previously, some users are using isolated CPUs, which could > be excluded by default. Please add commands like taskset to use > those cores. > > Test example: > $ taskset 0xc0000 ./examples/helloworld/build/helloworld -m 1024 > > Signed-off-by: Jianfeng Tan > Acked-by: Neil Horman > --- > v2: > - Make it as default instead of adding the new options. > lib/librte_eal/common/eal_common_lcore.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/common/eal_common_lcore.c b/lib/librte_eal/common/eal_common_lcore.c > index 2cd4132..62e4f67 100644 > --- a/lib/librte_eal/common/eal_common_lcore.c > +++ b/lib/librte_eal/common/eal_common_lcore.c > @@ -57,6 +57,14 @@ rte_eal_cpu_init(void) > struct rte_config *config = rte_eal_get_configuration(); > unsigned lcore_id; > unsigned count = 0; > + rte_cpuset_t cs; > + pthread_t tid = pthread_self(); > + > + /* Add below method to obtain core restrictions, like ulimit, > + * cgroup.cpuset, etc. Will not use those cores, which are rebuffed. > + */ > + if (pthread_getaffinity_np(tid, sizeof(rte_cpuset_t), &cs) < 0) > + CPU_ZERO(&cs); > This patch makes sense but the comment is hard to read because of wording and grammar. If you choose variable names better then there really is no need for a comment in many cases. Code is often easier to read/write than comments for non-native English speakers. Remove the comment and rename 'cs' as 'affinity_set' or something equally as descriptive.