DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Hanoch Haim (hhaim)" <hhaim@cisco.com>
To: Olivier MATZ <olivier.matz@6wind.com>
Cc: Konstantin Ananyev <konstantin.ananyev@intel.com>,
	Ilya Matveychikov <matvejchikov@gmail.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v3] mbuf: cleanup rte_pktmbuf_lastseg(), fix atomic usage
Date: Thu, 16 Nov 2017 09:06:56 +0000	[thread overview]
Message-ID: <d36d343ac5594b0ca85f79902a917dd8@XCH-RTP-017.cisco.com> (raw)
In-Reply-To: <20171116084112.ockgmxnxews7coie@platinum>

Understood 

rte_mbuf_refcnt_update_blind() 

should be good., it will take care the RTE_MBUF_REFCNT_ATOMIC 

Hanoh


-----Original Message-----
From: Olivier MATZ [mailto:olivier.matz@6wind.com] 
Sent: Thursday, November 16, 2017 10:42 AM
To: Hanoch Haim (hhaim)
Cc: Konstantin Ananyev; Ilya Matveychikov; dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v3] mbuf: cleanup rte_pktmbuf_lastseg(), fix atomic usage

Hi Hanoh,

On Thu, Nov 16, 2017 at 07:16:31AM +0000, Hanoch Haim (hhaim) wrote:
> Hi Oliver,
> 
> It's hard for me to follow this thread. 

Yes, here are some few tips to make it easier to follow:
- avoid top-posting
- prefix quoted lines with "> "
- describe the problem and how you solve it in the commit log
- one problem = one patch

> 1)  It is not about clear/not-clear, it is error prone to *replicate* code that has the same logic.
> 
> "I'm not convinced that:
> 
>     __rte_pktmbuf_reset_nb_segs(m);
> 
> is clearer than:
> 
>    m->next = NULL;
>    m->nb_segs = 1;
> 
> Anyway, I agree this should not be part of this patch. We should only keep the fix.
> "

rte_mbuf_refcnt_update() was not used in rte_pktmbuf_prefree_seg() to avoid reading the refcount twice.

The problem of having clear or unclear is fundamental. I don't see the point of having a function __rte_pktmbuf_reset_nb_segs(). Keeping the two affectations makes things explicit.

> 2) This definitely does not look good. 
> All the point in my patch is to move the ref-cnt operations to set of 
> API that already taking care of RTE_MBUF_REFCNT_ATOMIC
> 
> +               /* We don't use rte_mbuf_refcnt_update() because we already
> +                * tested that refcnt != 1.
> +                */
> +#ifdef RTE_MBUF_REFCNT_ATOMIC
> +               ret = rte_atomic16_add_return(&m->refcnt_atomic, -1); 
> +#else
> +               ret = --m->refcnt;
> +#endif
> +               if (ret != 0)
> +                       return NULL;
> 

We cannot use the existing API taking care of atomic refcount
rte_mbuf_refcnt_update() because it would read the refcount twice.

We cannot change the behavior of rte_mbuf_refcnt_update() because it's a public API.

An option proposed by Konstantin is to introduce a new helper
rte_mbuf_refcnt_update_blind() that does the same than
rte_mbuf_refcnt_update() but without the first test.  It think it is a bit overkill to have this function for one caller.

That's why I end up with this patch. I don't see why it would be an issue to have a mbuf ifdef inside the mbuf code.

Olivier

  reply	other threads:[~2017-11-16  9:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15  9:14 Hanoh Haim
2017-11-15 11:13 ` Ilya Matveychikov
2017-11-15 12:46   ` Hanoch Haim (hhaim)
2017-11-15 17:30     ` Olivier MATZ
2017-11-16  7:16       ` Hanoch Haim (hhaim)
2017-11-16  8:07         ` Ilya Matveychikov
2017-11-16  8:42         ` Olivier MATZ
2017-11-16  9:06           ` Hanoch Haim (hhaim) [this message]
2017-11-16  9:32             ` Ilya Matveychikov
2017-11-16  9:37               ` Olivier MATZ
2017-11-16  9:44                 ` Ilya Matveychikov
2017-11-16 10:54       ` Ananyev, Konstantin
2017-12-08 15:46 ` [dpdk-dev] [PATCH v4] mbuf: fix mbuf free performance with non atomic refcnt Olivier Matz
2017-12-08 16:04   ` Ilya Matveychikov
2017-12-08 16:19     ` Olivier MATZ
2017-12-08 16:37   ` Stephen Hemminger
2017-12-10  8:37   ` Hanoch Haim (hhaim)
2017-12-11 10:28   ` Olivier MATZ
2018-01-18 23:23   ` Thomas Monjalon

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=d36d343ac5594b0ca85f79902a917dd8@XCH-RTP-017.cisco.com \
    --to=hhaim@cisco.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=matvejchikov@gmail.com \
    --cc=olivier.matz@6wind.com \
    /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).