From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 0C1335398 for ; Tue, 11 Jul 2017 16:10:28 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2017 07:10:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,346,1496127600"; d="scan'208";a="125767572" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by fmsmga006.fm.intel.com with ESMTP; 11 Jul 2017 07:10:11 -0700 Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by irsmsx105.ger.corp.intel.com (163.33.3.28) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 11 Jul 2017 15:10:10 +0100 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.211]) by irsmsx155.ger.corp.intel.com ([169.254.14.182]) with mapi id 14.03.0319.002; Tue, 11 Jul 2017 15:10:09 +0100 From: "Van Haaren, Harry" To: Jerin Jacob CC: "dev@dpdk.org" , "thomas@monjalon.net" , "Wiles, Keith" , "Richardson, Bruce" Thread-Topic: [PATCH v4 1/7] service cores: header and implementation Thread-Index: AQHS9z/jwjXkVTa0DESrgHxIpVBb1KJOQHgAgABYJSA= Date: Tue, 11 Jul 2017 14:10:08 +0000 Message-ID: References: <1498735421-100164-1-git-send-email-harry.van.haaren@intel.com> <1499445667-32588-1-git-send-email-harry.van.haaren@intel.com> <1499445667-32588-2-git-send-email-harry.van.haaren@intel.com> <20170711082950.GB29792@jerin> In-Reply-To: <20170711082950.GB29792@jerin> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNmZkN2U3ZDAtNWI0OC00MTI0LWI3NWItZjdmYTliMDBmOWY0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IlpaVDdqdmZuZ1hwNDFSaDF4RHhNaUYxcGFsaFhlOUVEb2hTU2NUR1ZCUlk9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v4 1/7] service cores: header and implementation 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: Tue, 11 Jul 2017 14:10:29 -0000 > From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com] > To: Van Haaren, Harry > Cc: dev@dpdk.org; thomas@monjalon.net; Wiles, Keith ; Richardson, > Bruce > Subject: Re: [PATCH v4 1/7] service cores: header and implementation >=20 >=20 > Remove above info from the git commit. Done > Fix the below mentioned documentation warning. >=20 > +/export/dpdk.org/lib/librte_eal/common/include/rte_service.h:338: > warning: argument 'enabled' of command @param is not found in the > argument list of rte_service_set_stats_enable(int enable) > +/export/dpdk.org/lib/librte_eal/common/include/rte_service.h:346: > warning: The following parameters of rte_service_set_stats_enable(int > enable) are not documented: > + parameter 'enable' > +/export/dpdk.org/lib/librte_eal/common/include/rte_service.h:349: > warning: argument 'The' of command @param is not found in the argument > list of rte_service_lcore_list(uint32_t array[], uint32_t n) > +/export/dpdk.org/lib/librte_eal/common/include/rte_service.h:367: > warning: The following parameters of rte_service_lcore_list(uint32_t > array[], uint32_t n) are not documented: > + parameter 'n' Done > command to reproduce: > ./devtools/test-build.sh -j8 x86_64-native-linuxapp-gcc+shared x86_64-nat= ive-linuxapp- > gcc+debug Thanks - noted. > > + > > +/* the internal values of a service core */ > > +struct core_state { >=20 > Change to lcore_state. Done. > > + > > +void rte_service_set_stats_enable(int enabled) >=20 > IMO, It should be per service i.e > rte_service_set_stats_enable(const struct rte_service_spec *spec, int ena= ble) Improved service library to handle statistics collection on a per service b= asis. > > + /* check if this is the only core mapped, else use > > + * atomic to serialize cores mapped to this service > > + */ > > + uint32_t *lock =3D (uint32_t *)&s->execute_lock; > > + if ((s->spec.capabilities & RTE_SERVICE_CAP_MT_SAFE) || > > + (s->num_mapped_cores =3D=3D 1 || > > + rte_atomic32_cmpset(lock, 0, 1))) { > > + void *userdata =3D s->spec.callback_userdata; > > + > > + if (cs->collect_statistics) { > > + uint64_t start =3D rte_rdtsc(); > > + s->spec.callback(userdata); > > + uint64_t end =3D rte_rdtsc(); > > + s->cycles_spent +=3D end - start; > > + cs->calls_per_service[i]++; > > + s->calls++; > > + } else > > + s->spec.callback(userdata); > > + > > + if ((s->spec.capabilities & > > + RTE_SERVICE_CAP_MT_SAFE) =3D=3D 0 && > > + s->num_mapped_cores > 1) >=20 > How about computing the non rte_atomic32_cmpset() mode value first and > using in both place i.e here and in the top "if" loop >=20 > const int need_cmpset =3D (s->spec.capabilities & RTE_SERVICE_CAP_MT_SAF= E)... > if (need_cmpset || rte_atomic32_cmpset(lock, 0, 1)) > .. > if (need_cmpset) > rte_atomic32_clear().. Yes good idea. Indeed I wasn't happy with that, this is a good fix. The checks to detect if we need_cmpset are a little complex, but it's the o= nly solution I see. I've added another unit test to verify both MT safe and MT unsafe callback = operations. > > +int32_t > > +rte_service_set_default_mapping(void) > > +{ > > + /* create a default mapping from cores to services, then start the > > + * services to make them transparent to unaware applications. > > + */ > > + uint32_t i; > > + int ret; > > + uint32_t count =3D rte_service_get_count(); > > + > > + int32_t lcore_iter =3D 0; > > + uint32_t ids[RTE_MAX_LCORE]; > > + int32_t lcore_count =3D rte_service_lcore_list(ids, RTE_MAX_LCORE); > > + > > + for (i =3D 0; i < count; i++) { > > + struct rte_service_spec *s =3D rte_service_get_by_id(i); > > + if (!s) > > + return -EINVAL; > > + > > + /* if no lcores available as services cores, don't setup map. > > + * This means app logic must add cores, and setup mappings > > + */ > > + if (lcore_count > 0) { >=20 >=20 > > + /* do 1:1 core mapping here, with each service getting > > + * assigned a single core by default. Adding multiple > > + * services should multiplex to a single core, or 1:1 > > + * if services =3D=3D cores > > + */ > > + ret =3D rte_service_enable_on_lcore(s, ids[lcore_iter]); > > + if (ret) > > + return -ENODEV; > > + } > > + > > + lcore_iter++; > > + if (lcore_iter >=3D lcore_count) > > + lcore_iter =3D 0; > > + > > + ret =3D rte_service_start(s); >=20 > IMO, we don't need to start the service if lcore_count =3D=3D 0. How abou= t > moving the "if (lcore_count > 0)" check on top of for the loop and exist > from the function if lcore_count =3D=3D 0. Good point, added if() check for lcore_count at start of function, and re= turn if no service cores are available. > > + > > +int32_t > > +rte_service_lcore_add(uint32_t lcore) > > +{ > > + if (lcore >=3D RTE_MAX_LCORE) > > + return -EINVAL; > > + if (cores_state[lcore].is_service_core) > > + return -EALREADY; > > + > > + set_lcore_state(lcore, ROLE_SERVICE); > > + > > + /* ensure that after adding a core the mask and state are defaults */ > > + cores_state[lcore].service_mask =3D 0; > > + cores_state[lcore].runstate =3D RUNSTATE_STOPPED; >=20 > If worker core can call rte_service_lcore_add() then add rte_smp_wmb() > here. Applies to rte_service_lcore_del() as well. Added barriers to both add() and del().