From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Liang, Ma" Subject: Re: [PATCH] event/opdl: fix atomic queue race condition issue Date: Mon, 26 Mar 2018 14:32:36 +0100 Message-ID: <20180326133236.GA18416@sivswdev01.ir.intel.com> References: <1520940853-56748-1-git-send-email-liang.j.ma@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "dev@dpdk.org" , "Jain, Deepak K" , "Geary, John" , "Mccarthy, Peter" , "jerin.jacob@caviumnetworks.com" To: "Van Haaren, Harry" Return-path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 2A4892BF2 for ; Mon, 26 Mar 2018 15:32:39 +0200 (CEST) Content-Disposition: inline In-Reply-To: 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 26 Mar 05:29, Van Haaren, Harry wrote: > > From: Ma, Liang J > > Sent: Tuesday, March 13, 2018 11:34 AM > > To: jerin.jacob@caviumnetworks.com > > Cc: dev@dpdk.org; Van Haaren, Harry ; Jain, Deepak > > K ; Geary, John ; Mccarthy, > > Peter > > Subject: [PATCH] event/opdl: fix atomic queue race condition issue > > > > If application link one atomic queue to multiple ports, > > and each worker core update flow_id, there will have a > > chance to hit race condition issue and lead to double processing > > same event. This fix solve the problem and eliminate > > the race condition issue. > > > > Fixes: 4236ce9bf5bf ("event/opdl: add OPDL ring infrastructure library") > > > > General notes > - Spaces around & % << >> and other bitwise manipulations (https://dpdk.org/doc/guides/contributing/coding_style.html#operators) > - I've noted a few below, but there are more > - Usually checkpatch flags these - I'm curious why it didn't in this case > > It would be nice if we didn't have to rely on __atomic_load_n() and friends, > however I don't see a better alternative. Given other DPDK components are > also using __atomic_* functions, no objection here. > > > > > > @@ -520,7 +528,17 @@ opdl_stage_claim_singlethread(struct opdl_stage *s, void > > *entries, > > > > for (j = 0; j < num_entries; j++) { > > ev = (struct rte_event *)get_slot(t, s->head+j); > > - if ((ev->flow_id%s->nb_instance) == s->instance_id) { > > Spaces around the % > > > + > > + event = __atomic_load_n(&(ev->event), > > + __ATOMIC_ACQUIRE); > > + > > + opa_id = OPDL_OPA_MASK&(event>>OPDL_OPA_OFFSET); > > Spaces & > > > + flow_id = OPDL_FLOWID_MASK&event; > > Spaces & > > > + > > + if (opa_id >= s->queue_id) > > + continue; > > + > > + if ((flow_id%s->nb_instance) == s->instance_id) { > > Spaces % > > > > > Will re-review v2. Cheers, -Harry Thanks, I will send V2 later.