From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 4FF7234F0 for ; Mon, 26 Mar 2018 14:29:08 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2018 05:29:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,364,1517904000"; d="scan'208";a="28896946" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by orsmga006.jf.intel.com with ESMTP; 26 Mar 2018 05:29:06 -0700 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.176]) by irsmsx110.ger.corp.intel.com ([169.254.15.211]) with mapi id 14.03.0319.002; Mon, 26 Mar 2018 13:29:04 +0100 From: "Van Haaren, Harry" To: "Ma, Liang J" CC: "dev@dpdk.org" , "Jain, Deepak K" , "Geary, John" , "Mccarthy, Peter" , "jerin.jacob@caviumnetworks.com" Thread-Topic: [PATCH] event/opdl: fix atomic queue race condition issue Thread-Index: AQHTur8+vV8VuTNtLU+UMyFP+4dCqaPib5jA Date: Mon, 26 Mar 2018 12:29:04 +0000 Message-ID: References: <1520940853-56748-1-git-send-email-liang.j.ma@intel.com> In-Reply-To: <1520940853-56748-1-git-send-email-liang.j.ma@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDJmZWE2NzItZDg3YS00ZmI1LWFjZTItNjM0YzQxZjA4OTlmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJwcGNmMHg5c09rYVdhR1k0cHVUWlk3cWpVdWtRWUdlaVdjSmNmYkxRY0twcFNwa2NsRXRNYTBXXC95b0p5WlN0WiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 12:29:08 -0000 > 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, D= eepak > K ; Geary, John ; Mccarthy= , > Peter > Subject: [PATCH] event/opdl: fix atomic queue race condition issue >=20 > 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. >=20 > Fixes: 4236ce9bf5bf ("event/opdl: add OPDL ring infrastructure library") >=20 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, >=20 > for (j =3D 0; j < num_entries; j++) { > ev =3D (struct rte_event *)get_slot(t, s->head+j); > - if ((ev->flow_id%s->nb_instance) =3D=3D s->instance_id) { Spaces around the % > + > + event =3D __atomic_load_n(&(ev->event), > + __ATOMIC_ACQUIRE); > + > + opa_id =3D OPDL_OPA_MASK&(event>>OPDL_OPA_OFFSET); Spaces & > + flow_id =3D OPDL_FLOWID_MASK&event; Spaces & > + > + if (opa_id >=3D s->queue_id) > + continue; > + > + if ((flow_id%s->nb_instance) =3D=3D s->instance_id) { Spaces % Will re-review v2. Cheers, -Harry