From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E5ADEA0526; Tue, 21 Jul 2020 19:10:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C81681BFE9; Tue, 21 Jul 2020 19:10:13 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 00A411BFD4 for ; Tue, 21 Jul 2020 19:10:11 +0200 (CEST) IronPort-SDR: YYWOOg1DN19FMGX3Jh1YLeNyAyZuDsQINqs9qBlJDiWX/KkbbWKYSf814g16vQ5ocFFrmj3bHj 2Jvg1WuUOp1A== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="138273696" X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="138273696" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 10:10:10 -0700 IronPort-SDR: RO6AHe1BnoYjoYY6xXQpjHMysIPCfzbalUgdaB1mPAI2YGCxKL7Js6P4J3rYScMXU3Wr6b3VgP N53TWDjbxsNA== X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="462149749" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.9.114]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 21 Jul 2020 10:10:08 -0700 Date: Tue, 21 Jul 2020 18:10:05 +0100 From: Bruce Richardson To: "Medvedkin, Vladimir" Cc: Ruifeng Wang , "dev@dpdk.org" , nd , Honnappa Nagarahalli , Phil Yang Message-ID: <20200721171005.GJ735@bricha3-MOBL.ger.corp.intel.com> References: <20200716051903.94195-1-ruifeng.wang@arm.com> <20200716154920.167185-1-ruifeng.wang@arm.com> <608e9beb-812e-2375-b532-79b6366d31f8@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [dpdk-dev] [PATCH v2] lpm: fix unchecked return value 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Jul 21, 2020 at 05:23:02PM +0100, Medvedkin, Vladimir wrote: > Hi Ruifeng, > > On 18/07/2020 10:22, Ruifeng Wang wrote: > > > > > -----Original Message----- > > > From: Medvedkin, Vladimir > > > Sent: Saturday, July 18, 2020 1:12 AM > > > To: Ruifeng Wang ; Bruce Richardson > > > > > > Cc: dev@dpdk.org; nd ; Honnappa Nagarahalli > > > ; Phil Yang > > > Subject: Re: [PATCH v2] lpm: fix unchecked return value > > > > > > Hi Ruifeng, > > > > > Hi Vladimir, > > > > > On 16/07/2020 16:49, Ruifeng Wang wrote: > > > > Coverity complains about unchecked return value of > > > rte_rcu_qsbr_dq_enqueue. > > > > By default, defer queue size is big enough to hold all tbl8 groups. > > > > When enqueue fails, return error to the user to indicate system issue. > > > > > > > > Coverity issue: 360832 > > > > Fixes: 8a9f8564e9f9 ("lpm: implement RCU rule reclamation") > > > > > > > > Signed-off-by: Ruifeng Wang > > > > --- > > > > v2: > > > > Converted return value to conform to LPM API convention. (Vladimir) > > > > > > > > lib/librte_lpm/rte_lpm.c | 19 +++++++++++++------ > > > > 1 file changed, 13 insertions(+), 6 deletions(-) > > > > > > > > diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index > > > > 2db9e16a2..757436f49 100644 > > > > --- a/lib/librte_lpm/rte_lpm.c > > > > +++ b/lib/librte_lpm/rte_lpm.c > > > > @@ -532,11 +532,12 @@ tbl8_alloc(struct rte_lpm *lpm) > > > > return group_idx; > > > > } > > > > > > > > -static void > > > > +static int32_t > > > > tbl8_free(struct rte_lpm *lpm, uint32_t tbl8_group_start) > > > > { > > > > struct rte_lpm_tbl_entry zero_tbl8_entry = {0}; > > > > struct __rte_lpm *internal_lpm; > > > > + int status; > > > > > > > > internal_lpm = container_of(lpm, struct __rte_lpm, lpm); > > > > if (internal_lpm->v == NULL) { > > > > @@ -552,9 +553,15 @@ tbl8_free(struct rte_lpm *lpm, uint32_t > > > tbl8_group_start) > > > > __ATOMIC_RELAXED); > > > > } else if (internal_lpm->rcu_mode == RTE_LPM_QSBR_MODE_DQ) { > > > > /* Push into QSBR defer queue. */ > > > > - rte_rcu_qsbr_dq_enqueue(internal_lpm->dq, > > > > + status = rte_rcu_qsbr_dq_enqueue(internal_lpm->dq, > > > > (void *)&tbl8_group_start); > > > > + if (status == 1) { > > > > + RTE_LOG(ERR, LPM, "Failed to push QSBR FIFO\n"); > > > > + return -rte_errno; > > > > + } > > > > } > > > > + > > > > + return 0; > > > > } > > > > > > > > static __rte_noinline int32_t > > > > @@ -1040,7 +1047,7 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t > > > ip_masked, > > > > #define group_idx next_hop > > > > uint32_t tbl24_index, tbl8_group_index, tbl8_group_start, > > > tbl8_index, > > > > tbl8_range, i; > > > > - int32_t tbl8_recycle_index; > > > > + int32_t tbl8_recycle_index, status = 0; > > > > > > > > /* > > > > * Calculate the index into tbl24 and range. Note: All depths > > > > larger @@ -1097,7 +1104,7 @@ delete_depth_big(struct rte_lpm *lpm, > > > uint32_t ip_masked, > > > > */ > > > > lpm->tbl24[tbl24_index].valid = 0; > > > > __atomic_thread_fence(__ATOMIC_RELEASE); > > > > - tbl8_free(lpm, tbl8_group_start); > > > > + status = tbl8_free(lpm, tbl8_group_start); > > > > } else if (tbl8_recycle_index > -1) { > > > > /* Update tbl24 entry. */ > > > > struct rte_lpm_tbl_entry new_tbl24_entry = { @@ -1113,10 > > > +1120,10 > > > > @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked, > > > > __atomic_store(&lpm->tbl24[tbl24_index], > > > &new_tbl24_entry, > > > > __ATOMIC_RELAXED); > > > > __atomic_thread_fence(__ATOMIC_RELEASE); > > > > - tbl8_free(lpm, tbl8_group_start); > > > > + status = tbl8_free(lpm, tbl8_group_start); > > > > } > > > > #undef group_idx > > > > - return 0; > > > > + return status; > > > > > > This will change rte_lpm_delete API. As a suggestion, you can leave it as it > > > was before ("return 0"), and send separate patch (with "return status)" > > > which will be targeted to 20.11. > > > > > > > Is the change of API because a variable is returned instead of constant? > > The patch passed ABI check on Travis: http://mails.dpdk.org/archives/test-report/2020-July/144864.html > > So I didn't know there is API/ABI issue. > > > Because new error status codes are returned. At the moment rte_lpm_delete() > returns only -EINVAL. After patches it will also returns -ENOSPC. The user's > code may not handle this returned error status. > > On the other hand, from documentation about returned value: > "0 on success, negative value otherwise", > and given the fact that this behavior is only after calling > rte_lpm_rcu_qsbr_add(), I think we can accept this patch. > Bruce, please correct me. > That sounds reasonable to me. No change in the committed ABI, since the specific values are not called out.