DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Olivier MATZ <olivier.matz@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 2/2] Remove RTE_MBUF_REFCNT references
Date: Wed, 18 Feb 2015 10:37:03 +0000	[thread overview]
Message-ID: <20150218103703.GB6804@bricha3-MOBL3> (raw)
In-Reply-To: <54E46A8C.9010105@6wind.com>

On Wed, Feb 18, 2015 at 11:33:48AM +0100, Olivier MATZ wrote:
> Hi,
> 
> On 02/18/2015 11:22 AM, Bruce Richardson wrote:
> >On Wed, Feb 18, 2015 at 11:14:42AM +0100, Olivier MATZ wrote:
> >>On 02/18/2015 11:00 AM, Bruce Richardson wrote:
> >>>On Wed, Feb 18, 2015 at 09:48:58AM +0000, Ananyev, Konstantin wrote:
> >>>>Hi lads,
> >>>>
> >>>>>-----Original Message-----
> >>>>>From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson
> >>>>>Sent: Wednesday, February 18, 2015 9:36 AM
> >>>>>To: Olivier MATZ
> >>>>>Cc: dev@dpdk.org
> >>>>>Subject: Re: [dpdk-dev] [PATCH 2/2] Remove RTE_MBUF_REFCNT references
> >>>>>
> >>>>>On Wed, Feb 18, 2015 at 10:16:56AM +0100, Olivier MATZ wrote:
> >>>>>>Hi Sergio,
> >>>>>>
> >>>>>>On 02/16/2015 05:08 PM, Sergio Gonzalez Monroy wrote:
> >>>>>>>This patch removes all references to RTE_MBUF_REFCNT, setting the refcnt
> >>>>>>>field in the mbuf struct permanently.
> >>>>>>>
> >>>>>>>Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
> >>>>>>
> >>>>>>I think removing the refcount compile option goes in the right
> >>>>>>direction. However, activating the refcount will break the applications
> >>>>>>that reserve a private zone in mbufs. This is due to the macros
> >>>>>>RTE_MBUF_TO_BADDR() and RTE_MBUF_FROM_BADDR() that suppose that
> >>>>>>the beginning of the mbuf is 128 bytes (sizeof mbuf) before the
> >>>>>>data buffer.
> >>>>>>
> >>>>>
> >>>>>While I understand how the macros make certain assumptions, how does activating
> >>>>>the refcnt specifically lead to the problems you describe? Could you explain
> >>>>>that part in a bit more detail?
> >>>>>
> >>>>>Thanks,
> >>>>>/Bruce
> >>>>>
> >>>>
> >>>>Olivier, I also don't understand your concern here.
> >>>>As I can see, that patch has nothing to do with RTE_MBUF_FROM_BADDR/ RTE_MBUF_FROM_BADDR macros.
> >>>>They are still there, for example rte_pktmbuf_detach() still uses it to restore mbuf's buf_addr.
> >>>>The only principal change here, is that we don't rely more  on RTE_MBUF_FROM_BADDR to determine,
> >>>>Is that indirect mbuf or not.
> >>>>Instead we use a special falg for that purpose:
> >>>>
> >>>>-#define RTE_MBUF_INDIRECT(mb)   (RTE_MBUF_FROM_BADDR((mb)->buf_addr) != (mb))
> >>>>+#define RTE_MBUF_INDIRECT(mb)   (mb->ol_flags & IND_ATTACHED_MBUF)
> >>>>
> >>>>BTW, Sergio as I said before, I think it should be:
> >>>>#define RTE_MBUF_INDIRECT(mb)   ((mb)->ol_flags & IND_ATTACHED_MBUF)
> >>>>
> >>>>Konstantin
> >>>>
> >>>>
> >>>>>>For RTE_MBUF_TO_BADDR(), it's relatively easy to replace it. The
> >>>>>>mbuf pool could store the size of the private size like it's done
> >>>>>>for mbp_priv->mbuf_data_room_size. Using rte_mempool_from_obj(m)
> >>>>>>or m->pool, we can retrieve the mbuf pool and this value, then
> >>>>>>compute the buffer address.
> >>>
> >>>Agreed, that makes sense.
> >>>
> >>>>>>
> >>>>>>For RTE_MBUF_FROM_BADDR(), it's more complex. We could ensure that
> >>>>>>a backpointer to the mbuf is always located before the data buffer,
> >>>>>>but it looks difficult to do.
> >>>
> >>>On the other hand, with the proposed refcnt change Sergio proposes, we no
> >>>longer use this macro in any of the built-in mbuf handling for freeing mbufs.
> >>>Does this need to be solved at anything other than the application level?
> >>
> >>It's still used in __rte_pktmbuf_prefree_seg() to retrieve the
> >>parent mbuf (direct) from the indirect mbuf beeing freed.
> >>
> >Yes, my bad.
> >How was this managed before, since refcnt field seems to be necessary in order
> >to effectively manage indirect mbufs? Is this just the case that this is something
> >that never worked and that needs to be solved, or is it something that was
> >working that this patch will now break?
> 
> This is something that never worked before: refcounts are not compatible
> with reserving private data in mbufs. This patch does not change the
> issue, it is still there.
> 
> Before the patch, an application that wanted to reserve a private
> data could disable refcounts at compile-time.
> After the patch, the solution is just to avoid using refcounts.
> 
> Regards,
> Olivier
> 
Thanks for clarifying.
So, you ok with this patch as a step in the right direction?

  reply	other threads:[~2015-02-18 10:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-16 16:08 [dpdk-dev] [PATCH 0/2] Removal of RTE_MBUF_REFCNT Sergio Gonzalez Monroy
2015-02-16 16:08 ` [dpdk-dev] [PATCH 1/2] mbuf: Introduce IND_ATTACHED_MBUF flag Sergio Gonzalez Monroy
2015-02-16 16:08 ` [dpdk-dev] [PATCH 2/2] Remove RTE_MBUF_REFCNT references Sergio Gonzalez Monroy
2015-02-18  9:16   ` Olivier MATZ
2015-02-18  9:35     ` Bruce Richardson
2015-02-18  9:48       ` Ananyev, Konstantin
2015-02-18 10:00         ` Bruce Richardson
2015-02-18 10:14           ` Olivier MATZ
2015-02-18 10:22             ` Ananyev, Konstantin
2015-02-18 10:22             ` Bruce Richardson
2015-02-18 10:33               ` Olivier MATZ
2015-02-18 10:37                 ` Bruce Richardson [this message]
2015-02-18 10:47                   ` Olivier MATZ
2015-02-18 10:47                 ` Ananyev, Konstantin
2015-02-18 11:01                   ` Olivier MATZ
2015-02-18  9:52       ` Olivier MATZ
2015-02-16 20:47 ` [dpdk-dev] [PATCH 0/2] Removal of RTE_MBUF_REFCNT Stephen Hemminger
2015-02-17  8:43   ` Gonzalez Monroy, Sergio
2015-02-18 11:03 ` [dpdk-dev] [PATCH v2 " Sergio Gonzalez Monroy
2015-02-18 11:03   ` [dpdk-dev] [PATCH v2 1/2] mbuf: Introduce IND_ATTACHED_MBUF flag Sergio Gonzalez Monroy
2015-02-18 11:03   ` [dpdk-dev] [PATCH v2 2/2] Remove RTE_MBUF_REFCNT references Sergio Gonzalez Monroy
2015-02-18 12:05   ` [dpdk-dev] [PATCH v2 0/2] Removal of RTE_MBUF_REFCNT Ananyev, Konstantin
2015-02-23 18:36     ` 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=20150218103703.GB6804@bricha3-MOBL3 \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --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).