From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 3D2D72946 for ; Thu, 1 Sep 2016 03:15:13 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP; 31 Aug 2016 18:15:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,264,1470726000"; d="scan'208";a="3341101" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga006.fm.intel.com with ESMTP; 31 Aug 2016 18:15:12 -0700 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 31 Aug 2016 18:15:12 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 31 Aug 2016 18:15:11 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.102]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.250]) with mapi id 14.03.0248.002; Thu, 1 Sep 2016 09:15:09 +0800 From: "Tan, Jianfeng" To: Stephen Hemminger CC: "dev@dpdk.org" , "david.marchand@6wind.com" , "pmatilai@redhat.com" , "thomas.monjalon@6wind.com" Thread-Topic: [dpdk-dev] [PATCH v2] eal: restrict cores detection Thread-Index: AQHSAzTK55+nEO34VU2v8wI4EjjdaqBirLwAgAEo8FA= Date: Thu, 1 Sep 2016 01:15:09 +0000 Message-ID: References: <1453661393-85704-1-git-send-email-jianfeng.tan@intel.com> <1472612830-131693-1-git-send-email-jianfeng.tan@intel.com> <20160831083040.252b4dd5@xeon-e3> In-Reply-To: <20160831083040.252b4dd5@xeon-e3> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: Thu, 01 Sep 2016 01:15:13 -0000 Hi Stephen, > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Wednesday, August 31, 2016 11:31 PM > To: Tan, Jianfeng > Cc: dev@dpdk.org; david.marchand@6wind.com; pmatilai@redhat.com; > thomas.monjalon@6wind.com > Subject: Re: [dpdk-dev] [PATCH v2] eal: restrict cores detection >=20 > On Wed, 31 Aug 2016 03:07:10 +0000 > Jianfeng Tan wrote: >=20 > > 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 =3D rte_eal_get_configuration(); > > unsigned lcore_id; > > unsigned count =3D 0; > > + rte_cpuset_t cs; > > + pthread_t tid =3D 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); > > >=20 > This patch makes sense but the comment is hard to read because of wording > and grammar. >=20 > 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. >=20 > Remove the comment and rename 'cs' as 'affinity_set' or something equally > as descriptive. Great suggestion. I'll resend one as you suggest. Thanks, Jianfeng