DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Bruce Richardson" <bruce.richardson@intel.com>,
	"David Marchand" <david.marchand@redhat.com>,
	<Honnappa.Nagarahalli@arm.com>,
	"Tyler Retzlaff" <roretzla@linux.microsoft.com>
Cc: "Kevin Laatz" <kevin.laatz@intel.com>, <dev@dpdk.org>,
	<Ruifeng.Wang@arm.com>, <thomas@monjalon.net>,
	<stephen@networkplumber.org>
Subject: RE: [PATCH v3 3/7] dma/idxd: replace rte atomics with GCC builtin atomics
Date: Thu, 25 May 2023 15:59:00 +0200	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D8794C@smartserver.smartshare.dk> (raw)
In-Reply-To: <ZG8fOmJTBFyEup1K@bricha3-MOBL.ger.corp.intel.com>

> From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> Sent: Thursday, 25 May 2023 10.42
> 
> On Wed, May 24, 2023 at 10:09:04PM +0200, David Marchand wrote:
> > Hello Bruce, Kevin,
> >
> > Review please.
> >
> >
> > On Thu, Mar 23, 2023 at 11:54 PM Tyler Retzlaff
> > <roretzla@linux.microsoft.com> wrote:
> > >
> > > Replace the use of rte_atomic.h types and functions, instead use GCC
> > > supplied C++11 memory model builtins.
> > >
> > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> 
> Two small comments inline below.
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> > > ---
> > >  drivers/dma/idxd/idxd_internal.h | 3 +--
> > >  drivers/dma/idxd/idxd_pci.c      | 8 +++++---
> > >  2 files changed, 6 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/dma/idxd/idxd_internal.h
> b/drivers/dma/idxd/idxd_internal.h
> > > index 180a858..cd41777 100644
> > > --- a/drivers/dma/idxd/idxd_internal.h
> > > +++ b/drivers/dma/idxd/idxd_internal.h
> > > @@ -7,7 +7,6 @@
> > >
> > >  #include <rte_dmadev_pmd.h>
> > >  #include <rte_spinlock.h>
> > > -#include <rte_atomic.h>
> > >
> > >  #include "idxd_hw_defs.h"
> > >
> > > @@ -34,7 +33,7 @@ struct idxd_pci_common {
> > >         rte_spinlock_t lk;
> > >
> > >         uint8_t wq_cfg_sz;
> > > -       rte_atomic16_t ref_count;
> > > +       uint16_t ref_count;
> > >         volatile struct rte_idxd_bar0 *regs;
> > >         volatile uint32_t *wq_regs_base;
> > >         volatile struct rte_idxd_grpcfg *grp_regs;
> > > diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c
> > > index 781fa02..2de5d15 100644
> > > --- a/drivers/dma/idxd/idxd_pci.c
> > > +++ b/drivers/dma/idxd/idxd_pci.c
> > > @@ -6,7 +6,6 @@
> > >  #include <rte_devargs.h>
> > >  #include <rte_dmadev_pmd.h>
> > >  #include <rte_malloc.h>
> > > -#include <rte_atomic.h>
> > >
> > >  #include "idxd_internal.h"
> > >
> > > @@ -136,7 +135,9 @@
> > >         /* if this is the last WQ on the device, disable the device and
> free
> > >          * the PCI struct
> > >          */
> > > -       is_last_wq = rte_atomic16_dec_and_test(&idxd->u.pci->ref_count);
> > > +       /* NOTE: review for potential ordering optimization */
> > > +       is_last_wq = __atomic_fetch_sub(&idxd->u.pci->ref_count, 1,
> > > +               __ATOMIC_SEQ_CST) - 1 == 0;
> 
> Rather than "__atomic_fetch_sub(...) - 1 == 0", I think just comparing
> "== 1" is simpler and better. I would also bracket the comparison for
> clarity.
> 
> > >         if (is_last_wq) {
> > >                 /* disable the device */
> > >                 err_code = idxd_pci_dev_command(idxd, idxd_disable_dev);
> > > @@ -350,7 +351,8 @@
> > >                                 free(idxd.u.pci);
> > >                         return ret;
> > >                 }
> > > -               rte_atomic16_inc(&idxd.u.pci->ref_count);
> > > +               /* NOTE: review for potential ordering optimization */
> 
> I think we can drop the note. Since this is not datapath code the perf is
> not that important.

Following up on my previous input to the discussion about these notes...

I agree with Bruce on this location. Here it is purely used in the control plane, and atomicity is required, but optimization of this would be a waste of brain power, so we can drop the notes in such situations. Perhaps Honnappa was referring to something similar - and then I agree with Honnappa too. ;-)

In principle: This specific note has been actively considered for optimization, and the conclusion was that further optimization is not required, and thus SEQ_CST is the correct choice here. Ideal to change now, but could be changed with a later (separate) patch as well.

> 
> > > +               __atomic_fetch_add(&idxd.u.pci->ref_count, 1,
> __ATOMIC_SEQ_CST);
> > >         }
> > >
> > >         return 0;
> > > --
> > > 1.8.3.1
> > >
> >
> > --
> > David Marchand
> >

  reply	other threads:[~2023-05-25 13:59 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 20:19 [PATCH 0/7] " Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 1/7] ring: " Tyler Retzlaff
2023-03-17 20:36   ` Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 2/7] stack: " Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 3/7] dma/idxd: " Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 4/7] net/ice: " Tyler Retzlaff
2023-03-17 20:41   ` Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 5/7] net/ixgbe: " Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 6/7] net/null: " Tyler Retzlaff
2023-03-17 20:44   ` Tyler Retzlaff
2023-03-17 20:19 ` [PATCH 7/7] net/ring: " Tyler Retzlaff
2023-03-17 21:42 ` [PATCH 0/7] " Stephen Hemminger
2023-03-17 21:49   ` Tyler Retzlaff
2023-03-22 11:28     ` Morten Brørup
2023-03-22 14:21       ` Tyler Retzlaff
2023-03-22 14:58         ` Morten Brørup
2023-03-22 15:29           ` Tyler Retzlaff
2023-03-22 16:13             ` Morten Brørup
2023-03-22 16:40               ` Honnappa Nagarahalli
2023-03-22 17:07                 ` Morten Brørup
2023-03-22 17:38                   ` Honnappa Nagarahalli
2023-03-22 18:06                     ` Tyler Retzlaff
2023-05-02  3:37                       ` Tyler Retzlaff
2023-05-02  4:31                         ` Honnappa Nagarahalli
2023-03-23 22:34 ` [PATCH v2 " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 1/7] ring: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 2/7] stack: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 3/7] dma/idxd: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 4/7] net/ice: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 5/7] net/ixgbe: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 6/7] net/null: " Tyler Retzlaff
2023-03-23 22:34   ` [PATCH v2 7/7] net/ring: " Tyler Retzlaff
2023-03-24  7:07   ` [PATCH v2 0/7] " Morten Brørup
2023-03-23 22:53 ` [PATCH v3 " Tyler Retzlaff
2023-03-23 22:53   ` [PATCH v3 1/7] ring: " Tyler Retzlaff
2023-03-23 22:53   ` [PATCH v3 2/7] stack: " Tyler Retzlaff
2023-05-24 20:08     ` David Marchand
2023-03-23 22:53   ` [PATCH v3 3/7] dma/idxd: " Tyler Retzlaff
2023-05-24 20:09     ` David Marchand
2023-05-25  8:41       ` Bruce Richardson
2023-05-25 13:59         ` Morten Brørup [this message]
2023-05-25 12:57     ` Kevin Laatz
2023-03-23 22:53   ` [PATCH v3 4/7] net/ice: " Tyler Retzlaff
2023-05-24 20:10     ` David Marchand
2023-03-23 22:53   ` [PATCH v3 5/7] net/ixgbe: " Tyler Retzlaff
2023-05-24 20:11     ` David Marchand
2023-03-23 22:53   ` [PATCH v3 6/7] net/null: " Tyler Retzlaff
2023-05-24 20:13     ` David Marchand
2023-03-23 22:53   ` [PATCH v3 7/7] net/ring: " Tyler Retzlaff
2023-05-24 20:12     ` David Marchand
2023-05-25  8:44       ` Bruce Richardson
2023-03-24  7:09   ` [PATCH v3 0/7] " Morten Brørup
2023-03-24 19:22     ` Tyler Retzlaff
2023-05-24 12:40   ` David Marchand
2023-05-24 15:47     ` Tyler Retzlaff
2023-05-24 20:06       ` David Marchand
2023-05-24 22:50         ` Tyler Retzlaff
2023-05-24 22:56           ` Honnappa Nagarahalli
2023-05-25  0:02             ` Tyler Retzlaff
2023-05-25  7:50               ` Morten Brørup
2023-06-02 19:45 ` [PATCH v4 0/6] " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 1/6] stack: " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 2/6] dma/idxd: " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 3/6] net/ice: " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 4/6] net/ixgbe: " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 5/6] net/null: " Tyler Retzlaff
2023-06-02 19:45   ` [PATCH v4 6/6] net/ring: " Tyler Retzlaff
2023-06-05  8:27     ` Olivier Matz
2023-06-06 21:45 ` [PATCH v5 0/6] " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 1/6] stack: " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 2/6] dma/idxd: " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 3/6] net/ice: " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 4/6] net/ixgbe: " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 5/6] net/null: " Tyler Retzlaff
2023-06-06 21:45   ` [PATCH v5 6/6] net/ring: " Tyler Retzlaff
2023-06-09 15:01   ` [PATCH v5 0/6] " David Marchand
2023-06-09 15:13     ` Tyler Retzlaff
2023-06-22 19:59       ` Patrick Robb
2023-06-23  8:53         ` David Marchand
2023-06-23 21:37           ` Tyler Retzlaff
2023-06-28 14:01             ` Patrick Robb
2023-06-28 14:49               ` David Marchand
2023-06-23 21:35         ` Tyler Retzlaff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98CBD80474FA8B44BF855DF32C47DC35D8794C@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=Ruifeng.Wang@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=kevin.laatz@intel.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).