From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: Re: Ring PMD: why are stats counters atomic? Date: Mon, 16 May 2016 14:16:33 +0100 Message-ID: <20160516131633.GA22356@bricha3-MOBL3> References: <20160510093629.GA1508@bricha3-MOBL3> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: dev@dpdk.org To: Mauricio =?iso-8859-1?Q?V=E1squez?= Return-path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 248359AA9 for ; Mon, 16 May 2016 15:16:43 +0200 (CEST) Content-Disposition: inline In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Mon, May 16, 2016 at 03:12:10PM +0200, Mauricio V=E1squez wrote: > Hello Bruce, >=20 > Although having this support does not harm anyone, I am not convinced t= hat > it is useful, mainly because there exists the single-thread limitation = in > other PMDs. Then, if an application has to use different kind of NICs (= i.e, > different PMDs) it has to implement the locking strategies. On the othe= r > hand, if an application only uses rte_rings, it could just use the > rte_ring library. >=20 > Thanks, Mauricio V >=20 I agree.=20 If you want, please submit a patch to remove this behaviour and see=20 if anyone objects to it. If there are no objections, I have no problem ac= cepting the patch. However, since this is a behaviour change to existing functionality, we m= ay need to implement function versionning for this for ABI compatibility. Pl= ease take that into account when drafting any patch. Regards, /Bruce > On Tue, May 10, 2016 at 11:36 AM, Bruce Richardson < > bruce.richardson@intel.com> wrote: >=20 > > On Tue, May 10, 2016 at 11:13:08AM +0200, Mauricio V=E1squez wrote: > > > Hello, > > > > > > Per-queue stats counters are defined as rte_atomic64_t, in the tx/r= x > > > functions, they are atomically increased if the rings have the mult= iple > > > consumers/producer flag enabled. > > > > > > According to the design principles, the application should not invo= ke > > those > > > functions on the same queue on different cores, then I think that a= tomic > > > increasing is not necessary. > > > > > > Is there something wrong with my reasoning?, If not, I am willing t= o > > send a > > > patch. > > > > > > Thank you very much, > > > > > Since the rte_rings, on which the ring pmd is obviously based, have > > multi-producer > > and multi-consumer support built-in, I thought it might be useful in = the > > ring > > PMD itself to allow multiple threads to access the ring queues at the= same > > time, > > if the underlying rings are marked as MP/MC safe. When doing enqueues= and > > dequeue > > from the ring, the stats are either incremented atomically, or > > non-atomically, > > depending on the underlying queue type. > > > > const uint16_t nb_rx =3D (uint16_t)rte_ring_dequeue_burst(r->= rng, > > ptrs, nb_bufs); > > if (r->rng->flags & RING_F_SC_DEQ) > > r->rx_pkts.cnt +=3D nb_rx; > > else > > rte_atomic64_add(&(r->rx_pkts), nb_rx); > > > > If people don't think this behaviour is worthwhile keeping, I'm ok wi= th > > removing > > it, since all other PMDs have the restriction that the queues are > > single-thread > > only. > > > > Regards, > > /Bruce > >