From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id AC1A91B023 for ; Tue, 16 Jan 2018 13:06:05 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2018 04:05:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,368,1511856000"; d="scan'208";a="10504353" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by orsmga008.jf.intel.com with ESMTP; 16 Jan 2018 04:05:49 -0800 Received: from irsmsx112.ger.corp.intel.com (10.108.20.5) by irsmsx105.ger.corp.intel.com (163.33.3.28) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 16 Jan 2018 12:05:48 +0000 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.180]) by irsmsx112.ger.corp.intel.com ([169.254.1.12]) with mapi id 14.03.0319.002; Tue, 16 Jan 2018 12:05:48 +0000 From: "Van Haaren, Harry" To: Pavan Nikhilesh , "jerin.jacob@caviumnetworks.com" , "santosh.shukla@caviumnetworks.com" , "Eads, Gage" , "hemant.agrawal@nxp.com" , "nipun.gupta@nxp.com" , "Ma, Liang J" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4 10/13] app/eventdev: add pipeline queue worker functions Thread-Index: AQHTi8TRxB4YoooZ80SDtRxCJaasSKN2awqg Date: Tue, 16 Jan 2018 12:05:48 +0000 Message-ID: References: <20171130072406.15605-1-pbhagavatula@caviumnetworks.com> <20180112164416.21374-1-pbhagavatula@caviumnetworks.com> <20180112164416.21374-10-pbhagavatula@caviumnetworks.com> In-Reply-To: <20180112164416.21374-10-pbhagavatula@caviumnetworks.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGI2YTQyZmEtM2QzMC00NDdlLTlmYzctNjcxM2JjNjI1MTkxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Ik9lMW1VZFwvUzhiY3E1RUhhUTB5Wjg1bm9TWldSYXVkZndnY3JvMGlwXC82OD0ifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 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 10/13] app/eventdev: add pipeline queue worker functions 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, 16 Jan 2018 12:06:06 -0000 > From: Pavan Nikhilesh [mailto:pbhagavatula@caviumnetworks.com] > Sent: Friday, January 12, 2018 4:44 PM > To: jerin.jacob@caviumnetworks.com; santosh.shukla@caviumnetworks.com; Va= n > Haaren, Harry ; Eads, Gage > ; hemant.agrawal@nxp.com; nipun.gupta@nxp.com; Ma, > Liang J > Cc: dev@dpdk.org; Pavan Nikhilesh > Subject: [dpdk-dev] [PATCH v4 10/13] app/eventdev: add pipeline queue wor= ker > functions >=20 > Signed-off-by: Pavan Nikhilesh Some of the code feels like duplication - but there are differences in each= implementation as far as I can see. The common initialization parts are "m= acro-ed" to ensure minimal duplication. In short, I'm not aware of a better= solution/implementation. Please see note on branch-optimization in the code below. Acked-by: Harry van Haaren > static int > worker_wrapper(void *arg) > { > - RTE_SET_USED(arg); > + struct worker_data *w =3D arg; > + struct evt_options *opt =3D w->t->opt; > + const bool burst =3D evt_has_burst_mode(w->dev_id); > + const bool mt_safe =3D !w->t->mt_unsafe; > + const uint8_t nb_stages =3D opt->nb_stages; > + RTE_SET_USED(opt); > + > + /* allow compiler to optimize */ > + if (nb_stages =3D=3D 1) { > + if (!burst && mt_safe) > + return pipeline_queue_worker_single_stage_tx(arg); > + else if (!burst && !mt_safe) > + return pipeline_queue_worker_single_stage_fwd(arg); > + else if (burst && mt_safe) > + return pipeline_queue_worker_single_stage_burst_tx(arg); > + else if (burst && !mt_safe) > + return pipeline_queue_worker_single_stage_burst_fwd( > + arg); > + } else { > + if (!burst && mt_safe) > + return pipeline_queue_worker_multi_stage_tx(arg); > + else if (!burst && !mt_safe) > + return pipeline_queue_worker_multi_stage_fwd(arg); > + else if (burst && mt_safe) > + return pipeline_queue_worker_multi_stage_burst_tx(arg); > + else if (burst && !mt_safe) > + return pipeline_queue_worker_multi_stage_burst_fwd(arg); > + > + } I don't think the compiler will optimize the below, as the nb_stages value = comes from opt, which is a uint8 originating from a pointer-dereference...= =20 As far as I know, an optimizing compiler will do "constant propagation" thr= ough function calls, but I would be amazed if it found a pointer initialize= d to a specific value, and optimized the branches away here based on the co= ntents of that pointer deref. So I see 2 options; 1) accept as is - I'll ack this patch here 2) Rework so that the worker_wrapper() accepts nb_stages, burst and mt_safe= as function arguments, allowing constant propagation for optimizing away t= he branches. @Pavan, I'll leave that choice up to you!