From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0086.outbound.protection.outlook.com [104.47.33.86]) by dpdk.org (Postfix) with ESMTP id 4F8131B93B for ; Wed, 25 Oct 2017 12:21:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Vcftj+CS0uOV7wf9oTFzNroaFnyc7c3cEIPFOZadRiA=; b=V7Huc97wG6Imyfq0wuSQ4nWk1BErORah/IO3Cm1++eJCyXMcB6QHB3gMwI4JqoqytiWTSdl2nHdh6t8SHi3B90WhX24/tKSb0r476G/kGRlJxc6Wb6k3FVnrk9UuV9YryNOymNq1j3Zx5UQlrEPw5wOHHV99+7ivg82oTVlV5Fg= Received: from PBHAGAVATULA-LT (111.93.218.67) by CY4PR07MB3463.namprd07.prod.outlook.com (10.171.252.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Wed, 25 Oct 2017 10:21:49 +0000 Date: Wed, 25 Oct 2017 15:51:26 +0530 From: Pavan Nikhilesh Bhagavatula To: Harry van Haaren Cc: dev@dpdk.org Message-ID: <20171025102125.GA29948@PBHAGAVATULA-LT> References: <1508779012-56186-1-git-send-email-harry.van.haaren@intel.com> <1508779012-56186-2-git-send-email-harry.van.haaren@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1508779012-56186-2-git-send-email-harry.van.haaren@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MAXPR0101CA0030.INDPRD01.PROD.OUTLOOK.COM (10.174.62.144) To CY4PR07MB3463.namprd07.prod.outlook.com (10.171.252.144) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66ea5433-7b70-4436-61b7-08d51b9234be X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603238); SRVR:CY4PR07MB3463; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3463; 3:p9VpNNl6fIg72fubrF6v9uWULhJq3Q/7RM7Uu4zd7EoU5n82Er+EuXIcXVqkuQtsjygScoWwnMu9Ekax6zpj30q2zXN8AMFHH0AHT8CBCO5LPRkN/XGPaJ1SMjhvadRMZVohbECd5LabNgT+ZW+9Kq8fxx15DSAwIf9Z9CuLxi5UgUyuZpdXH2qaLAAz3OFuZxiL46dbiMKksSn2zRG2lphrgLILynVZTMeBuItJrl5JWwxJdpYV0OqewBknT9ko; 25:irlKbfsW48Mgq82dB3Sfh/CNzW6t4PUeVWNGKWtofWKa+HG/jui1jFnQth8Gnz71R+qhPBZRTE/kbrSXZMn+E8C2RSy7BiZgA972i5ypFJrMh4OoB+R09aFLy21fumTLh+hh6GCuGka09JaCMESsBhB36xo/IKBJHiMA9SzlFttoKuGa3hvdughhUNRXA6N5TquSLh/Ps6UQ2qBpLoBtWD45lV6wMNtmuOGRnUekuKgtg7LR1YAtHxev6MeMMJEZ37y1rhT9+HfDaKvRs6JxsGxLmYSASmFEcF6xvvxkskQHJT+YPeRroEhou+MZdygP8v6B9gwC8XSxY5+tDKxiY7JeeQ7bi3g6XleTKSo4bas=; 31:bffsxydxtvzeOMVeQs8iRcAkRBGM7cjoXYCXCMDqfGGIgwEAr4x1EP6vs60Ry/7aU73Cu7ItLtNtZjGe8e2pZ1S96ljryAs9rPguRHtqsrkrRCJemW14b2vrXKwUd/cv/LGdQIDKK3erdon5iAcM6GZ+TcWXcAtuzvFGNAG5A96tnRg9a/Kji05r94ZyPXssyn8dQLOqZP8W1XEXNr1EIW6PhdaSl5IoR7lbvCMXNNQ= X-MS-TrafficTypeDiagnostic: CY4PR07MB3463: X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3463; 20:EEStKvVcqQmHk+66MKFF+YHXwZ92/Cs52rvyte93fbnuKwG82e5fKhff4IRuh8isRsMBU+fs3GalF6kJBPTiMZ5MSFAi+sPakhSdM43rLMg7fvSg8TOMyec1MSWko8X1pKgD+Io/HlTisyddmWmwcgKXpp1m7JzlSJTS/vBM0RvRZGJ3dskfpa/ktn9sIKZnhv7cT3Aw7o5+ReqLhz91wYfmjtQ5iYGaD6WpaKZ1accl48unQSML3sevldxGqCcRhJa3iVnY27CF3H3nml0xeAcAcjNgzRhSg6/0ntTl43mA3WNC26P2NJZaBQwXW10WJ+kLVwbx1Ymi4Rvm1RclUOMDrnV+wX7H/v4Shf5dL9yymJ3PbEBHtuqOHQ60GDxy3qMzDKmh9IugJH24nxncAQB08ESjg3t+Q/iNQZIyzQhWcUC05q4KJS2O3YTwB/PUaPd4E1lQvmQtdv5WHZ2Mekf1gka54cLlRhD4euz5FCNpQPOek4Gu273Q7ch8gu3llyI1lEcfUsqjx0VPe8DSrxddiqplgrqBdY3KdMzaawmmnLQ8aefHzLwR744UVagArGRh4qaVcsF+M910GOTqK1cTlGWJXh7ST/FgOKIvOSM= X-Exchange-Antispam-Report-Test: UriScan:(278428928389397)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3002001)(93006095)(100000703101)(100105400095)(10201501046)(3231020)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(20161123558100)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR07MB3463; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR07MB3463; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3463; 4:wcGNwnjpiCsLD0kddyFV17aZpaJs/GueqqKFFqnGSm9uj0NblUB69Y6gwMfmal7nMphEdtJvaPz7ZWFILnGa+puiNI7Yz2og3HWFFv5vH8G0eJcO18Pc/HCqtI8YM+H1uvXvho1ZAViRGocx0IDoxW00d4F1qG+jXbxBC4V+yA3XoOPTB+cBrifo2mDfEqj+cCIpcuCiaaVdjv8wRLaC/Gz3rDEXzsZL4cVTc0wRHhsgNDYVkBkuRxlZ7xjE0Rggq/iUGjSTmo7O55jfTlFd/e1JQwsF80ZEse5T4Yc4Xf7/TRuQDKSp9FB/kF38UeJpZC4X//qIEoQtOCSCYLK4Jw== X-Forefront-PRVS: 0471B73328 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(189002)(199003)(57704003)(24454002)(66066001)(58126008)(229853002)(966005)(5660300001)(72206003)(83506002)(47776003)(33656002)(53936002)(101416001)(9686003)(106356001)(105586002)(97736004)(305945005)(55016002)(16586007)(3846002)(50466002)(7736002)(5009440100003)(23726003)(478600001)(6666003)(316002)(6496005)(16526018)(6916009)(33716001)(42882006)(1076002)(4326008)(8676002)(6306002)(2906002)(2950100002)(6246003)(53376002)(76176999)(25786009)(8936002)(54356999)(81156014)(189998001)(68736007)(50986999)(81166006)(6116002)(18370500001)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR07MB3463; H:PBHAGAVATULA-LT; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR07MB3463; 23:Xe48dN3ZZHvw2118p+BTogrRcFQE0oA/9bKo5VyfL?= =?us-ascii?Q?zR4qyW5FWC9TIDNfNvHrAldK7WdCh0vYBWlLu8n7gP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egr+JDHzSpbTvG08HCci/Ji0ODyyVPyXX5A=; 7:wteYxJpdDryqlGAkpHUvuHTsv1gyc+LhvLiRABpMqGWBL4Qehgj04ANPCwD5Hc1T6hAuBE3XQa2qC3Oo8qwks5E6v0rWYWGFchmgyfxwWKX3hl0diAhL9wJuIJVaIr/Q1MbICQXwplR5kK3fQGiVUvN6LzBFgYLpzNuw7fJeX0IZAdq3Wvdtr5N5ndAA8u0ubf21KeC6EfmeI3X24wdiJiBFVNWH3wD4shjbeBw1POg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2017 10:21:49.7016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66ea5433-7b70-4436-61b7-08d51b9234be X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3463 Subject: Re: [dpdk-dev] [PATCH 1/2] service: add function for app lcore to run service 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, 25 Oct 2017 10:21:52 -0000 On Mon, Oct 23, 2017 at 06:16:51PM +0100, Harry van Haaren wrote: > This commit adds a new function which allows an application lcore > (aka; *not* a dedicated service-lcore) to run a service. This > function is required to allow applications to gradually port > functionality to using services, while still being able to run > ordinary application functions. > > This requirement became clear when a patch to the existing > eventdev/pipeline sample app was modified to use a service-core > for scheduling - and that same core should be capable of running > the "worker()" function from the application too. > > This patch refactors the existing running code into a smaller > "service_run" function, which can be called by the dedicated > service-core loop, and the newly added function. > > Signed-off-by: Harry van Haaren > > [1] http://dpdk.org/ml/archives/dev/2017-October/079876.html > --- > lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + > lib/librte_eal/common/include/rte_service.h | 21 +++++++++ > lib/librte_eal/common/rte_service.c | 59 ++++++++++++++++--------- > lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + > 4 files changed, 61 insertions(+), 21 deletions(-) > > diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > index 080896f..ee8dc98 100644 > --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map > +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > @@ -229,6 +229,7 @@ EXPERIMENTAL { > rte_service_map_lcore_set; > rte_service_probe_capability; > rte_service_reset; > + rte_service_run_iter_on_app_lcore; > rte_service_runstate_get; > rte_service_runstate_set; > rte_service_set_stats_enable; > diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h > index 21da739..63d3170 100644 > --- a/lib/librte_eal/common/include/rte_service.h > +++ b/lib/librte_eal/common/include/rte_service.h > @@ -211,6 +211,27 @@ int32_t rte_service_runstate_get(uint32_t id); > * @warning > * @b EXPERIMENTAL: this API may change without prior notice > * > + * This function runs a service callback from a non-service lcore context. > + * The *id* of the service to be run is passed in, and the service-callback > + * is executed on the calling lcore immediately if possible. If the service is > + * not multi-thread capable and another thread is currently executing it, this > + * function returns without running the callback. > + * > + * Note that any thread calling this function MUST be a DPDK EAL thread, as > + * the *rte_lcore_id* function is used to access internal data structures. > + * > + * @retval 0 Service was run on the calling thread successfully > + * @retval -EBUSY Another lcore is executing the service, and it is not a > + * multi-thread safe service, so the service was not run on this lcore > + * @retval -ENOEXEC Service is not in a runnable state > + * @retval -EINVAL Invalid service id > + */ > +int32_t rte_service_run_iter_on_app_lcore(uint32_t id); > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice > + * > * Start a service core. > * > * Starting a core makes the core begin polling. Any services assigned to it > diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c > index e598e16..4e27f75 100644 > --- a/lib/librte_eal/common/rte_service.c > +++ b/lib/librte_eal/common/rte_service.c > @@ -331,6 +331,42 @@ rte_service_runner_do_callback(struct rte_service_spec_impl *s, > s->spec.callback(userdata); > } > > + > +static inline int32_t > +service_run(uint32_t i, struct core_state *cs, uint64_t service_mask) > +{ > + if (!service_valid(i)) > + return -EINVAL; > + struct rte_service_spec_impl *s = &rte_services[i]; > + if (s->comp_runstate != RUNSTATE_RUNNING || > + s->app_runstate != RUNSTATE_RUNNING || > + !(service_mask & (UINT64_C(1) << i))) > + return -ENOEXEC; > + > + /* check do we need cmpset, if MT safe or <= 1 core > + * mapped, atomic ops are not required. > + */ > + const int use_atomics = (service_mt_safe(s) == 0) && > + (s->num_mapped_cores > 1); > + if (use_atomics) { > + if (!rte_atomic32_cmpset((uint32_t *)&s->execute_lock, 0, 1)) > + return -EBUSY; > + > + rte_service_runner_do_callback(s, cs, i); > + rte_atomic32_clear(&s->execute_lock); > + } else > + rte_service_runner_do_callback(s, cs, i); > + > + return 0; > +} > + > +int32_t rte_service_run_iter_on_app_lcore(uint32_t id) > +{ > + /* run service on calling core, using all-ones as the service mask */ > + struct core_state *cs = &lcore_states[rte_lcore_id()]; > + return service_run(id, cs, UINT64_MAX); > +} > + > static int32_t > rte_service_runner_func(void *arg) > { > @@ -343,27 +379,8 @@ rte_service_runner_func(void *arg) > const uint64_t service_mask = cs->service_mask; > > for (i = 0; i < RTE_SERVICE_NUM_MAX; i++) { > - if (!service_valid(i)) > - continue; > - struct rte_service_spec_impl *s = &rte_services[i]; > - if (s->comp_runstate != RUNSTATE_RUNNING || > - s->app_runstate != RUNSTATE_RUNNING || > - !(service_mask & (UINT64_C(1) << i))) > - continue; > - > - /* check do we need cmpset, if MT safe or <= 1 core > - * mapped, atomic ops are not required. > - */ > - const int use_atomics = (service_mt_safe(s) == 0) && > - (s->num_mapped_cores > 1); > - if (use_atomics) { > - uint32_t *lock = (uint32_t *)&s->execute_lock; > - if (rte_atomic32_cmpset(lock, 0, 1)) { > - rte_service_runner_do_callback(s, cs, i); > - rte_atomic32_clear(&s->execute_lock); > - } > - } else > - rte_service_runner_do_callback(s, cs, i); > + /* return value ignored as no change to code flow */ > + service_run(i, cs, service_mask); > } > > rte_smp_rmb(); > diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map > index c173ccf..c4d2c27 100644 > --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map > +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map > @@ -233,6 +233,7 @@ EXPERIMENTAL { > rte_service_map_lcore_set; > rte_service_probe_capability; > rte_service_reset; > + rte_service_run_iter_on_app_lcore; > rte_service_runstate_get; > rte_service_runstate_set; > rte_service_set_stats_enable; > -- > 2.7.4 > Acked-by: Pavan Nikhilesh