From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: Yongseok Koh <yskoh@mellanox.com>, Olivier Matz <olivier.matz@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] Accessing 2nd cacheline in rte_pktmbuf_prefree_seg()
Date: Wed, 14 Feb 2018 11:48:05 +0000 [thread overview]
Message-ID: <2601191342CEEE43887BDE71AB97725890572EA2@irsmsx105.ger.corp.intel.com> (raw)
In-Reply-To: <97910E4F-11F5-4BDB-A460-2656B88EA87D@mellanox.com>
Hi Yongseok,
> > On Feb 13, 2018, at 2:45 PM, Yongseok Koh <yskoh@mellanox.com> wrote:
> >
> > Hi Olivier
> >
> > I'm wondering why rte_pktmbuf_prefree_seg() checks m->next instead of
> > m->nb_segs? As 'next' is in the 2nd cacheline, checking nb_segs seems beneficial
> > to the cases where almost mbufs have single segment.
> >
> > A customer reported high rate of cache misses in the code and I thought the
> > following patch could be helpful. I haven't had them try it yet but just wanted
> > to hear from you.
> >
> > I'd appreciate if you can review this idea.
> >
> > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> > index 62740254d..96edbcb9e 100644
> > --- a/lib/librte_mbuf/rte_mbuf.h
> > +++ b/lib/librte_mbuf/rte_mbuf.h
> > @@ -1398,7 +1398,7 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)
> > if (RTE_MBUF_INDIRECT(m))
> > rte_pktmbuf_detach(m);
> >
> > - if (m->next != NULL) {
> > + if (m->nb_segs > 1) {
> > m->next = NULL;
> > m->nb_segs = 1;
> > }
> > @@ -1410,7 +1410,7 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m)
> > if (RTE_MBUF_INDIRECT(m))
> > rte_pktmbuf_detach(m);
> >
> > - if (m->next != NULL) {
> > + if (m->nb_segs > 1) {
> > m->next = NULL;
> > m->nb_segs = 1;
> > }
>
> Well, m->pool in the 2nd cacheline has to be accessed anyway in order to put it back to the mempool.
> It looks like the cache miss is unavoidable.
As a thought: in theory PMD can store pool pointer together with each mbuf it has to free,
then it could be something like:
if (rte_pktmbuf_prefree_seg(m[x] != NULL)
rte_mempool_put(pool[x], m[x]);
Then what you suggested above might help.
Konstantin
next prev parent reply other threads:[~2018-02-14 11:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 22:45 Yongseok Koh
2018-02-14 3:16 ` Yongseok Koh
2018-02-14 11:48 ` Ananyev, Konstantin [this message]
2018-02-14 12:03 ` Ananyev, Konstantin
2018-02-14 12:11 ` Bruce Richardson
2018-02-14 12:35 ` Ananyev, Konstantin
2018-02-14 14:16 ` Ananyev, Konstantin
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=2601191342CEEE43887BDE71AB97725890572EA2@irsmsx105.ger.corp.intel.com \
--to=konstantin.ananyev@intel.com \
--cc=dev@dpdk.org \
--cc=olivier.matz@6wind.com \
--cc=yskoh@mellanox.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).