From mboxrd@z Thu Jan 1 00:00:00 1970 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) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2018 06:32:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,364,1517904000"; d="scan'208";a="28916586" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga006.jf.intel.com with ESMTP; 26 Mar 2018 06:32:37 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w2QDWafG001072; Mon, 26 Mar 2018 14:32:36 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w2QDWaH0020472; Mon, 26 Mar 2018 14:32:36 +0100 Received: (from lma25@localhost) by sivswdev01.ir.intel.com with LOCAL id w2QDWaaP020468; Mon, 26 Mar 2018 14:32:36 +0100 Date: Mon, 26 Mar 2018 14:32:36 +0100 From: "Liang, Ma" To: "Van Haaren, Harry" Cc: "dev@dpdk.org" , "Jain, Deepak K" , "Geary, John" , "Mccarthy, Peter" , "jerin.jacob@caviumnetworks.com" 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 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Subject: Re: [dpdk-dev] [PATCH] event/opdl: fix atomic queue race condition issue 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: Mon, 26 Mar 2018 13:32:40 -0000 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.