[dpdk-dev] [PATCH 0/9] mbuf: structure reorganization
Morten Brørup
mb at smartsharesystems.com
Fri Mar 31 09:21:39 CEST 2017
> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ananyev,
> Konstantin
> Sent: Friday, March 31, 2017 3:01 AM
>
> After applying the patch below got nearly original numbers (though not
> quite) on my box.
> dpdk.org mainline: 50.8
> with Olivier patch: 47.8
> with patch below: 50.4
> What I tried to do in it - avoid unnecessary updates of mbuf inside
> rte_pktmbuf_prefree_seg().
> For one segment per packet it seems to help.
> Though so far I didn't try it on i40e and didn't do any testing for
> multi-seg scenario.
> Konstantin
>
> $ cat patch.mod4
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index d7af852..558233f 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -1283,12 +1283,28 @@ rte_pktmbuf_prefree_seg(struct rte_mbuf *m) {
> __rte_mbuf_sanity_check(m, 0);
>
> - if (likely(rte_mbuf_refcnt_update(m, -1) == 0)) {
> + if (likely(rte_mbuf_refcnt_read(m) == 1)) {
> +
> + if (m->next != NULL) {
> + m->next = NULL;
> + m->nb_segs = 1;
> + }
> +
> + if (RTE_MBUF_INDIRECT(m))
> + rte_pktmbuf_detach(m);
> +
> + return m;
> +
> + } else if (rte_atomic16_add_return(&m->refcnt_atomic, -1) == 0)
> + {
> +
> if (RTE_MBUF_INDIRECT(m))
> rte_pktmbuf_detach(m);
>
> - m->next = NULL;
> - m->nb_segs = 1;
> + if (m->next != NULL) {
> + m->next = NULL;
> + m->nb_segs = 1;
> + }
> +
> rte_mbuf_refcnt_set(m, 1);
>
> return m;
Maybe the access to the second cache line (for single-segment packets) can be avoided altogether in rte_pktmbuf_prefree_seg() by adding a multi-segment indication flag to the first cache line, and using this flag instead of the test for m->next != NULL.
Med venlig hilsen / kind regards
- Morten Brørup
More information about the dev
mailing list