DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Stephen Hemminger" <stephen@networkplumber.org>, <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 2/5] mbuf: delinline rte_pktmbuf_linearize
Date: Mon, 30 Sep 2019 11:00:51 +0200	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35C60B24@smartserver.smartshare.dk> (raw)
In-Reply-To: <20190928003758.18489-3-stephen@networkplumber.org>

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger
> Sent: Saturday, September 28, 2019 2:38 AM
> 
> This function is too big to be put inline. The places it
> is used are only in special exception paths where a highly fragmented
> mbuf arrives at a device that can't handle it.

This assumption only true for the actual linearization. The application may not know if a device can handle it or not. So from an application perspective, calling rte_pktmbuf_linearize() may not be a special exception, e.g. in DPI applications.

I suggest keeping the rte_pktmbuf_is_contiguous(mbuf) test in an inlined part of rte_pktmbuf_linearize(), and only deinline the actual linearization.

> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/librte_mbuf/rte_mbuf.c           | 40 ++++++++++++++++++++++++++++
>  lib/librte_mbuf/rte_mbuf.h           | 40 ++--------------------------
>  lib/librte_mbuf/rte_mbuf_version.map |  6 +++++
>  3 files changed, 48 insertions(+), 38 deletions(-)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> index 37718d49c148..922bce6f0f93 100644
> --- a/lib/librte_mbuf/rte_mbuf.c
> +++ b/lib/librte_mbuf/rte_mbuf.c
> @@ -245,6 +245,46 @@ int rte_mbuf_check(const struct rte_mbuf *m, int
> is_header,
>  	return 0;
>  }
> 
> +/* convert multi-segment mbuf to single mbuf */
> +int
> +rte_pktmbuf_linearize(struct rte_mbuf *mbuf)
> +{
> +	size_t seg_len, copy_len;
> +	struct rte_mbuf *m;
> +	struct rte_mbuf *m_next;
> +	char *buffer;
> +
> +	if (rte_pktmbuf_is_contiguous(mbuf))
> +		return 0;
> +
> +	/* Extend first segment to the total packet length */
> +	copy_len = rte_pktmbuf_pkt_len(mbuf) -
> rte_pktmbuf_data_len(mbuf);
> +
> +	if (unlikely(copy_len > rte_pktmbuf_tailroom(mbuf)))
> +		return -1;
> +
> +	buffer = rte_pktmbuf_mtod_offset(mbuf, char *, mbuf->data_len);
> +	mbuf->data_len = (uint16_t)(mbuf->pkt_len);
> +
> +	/* Append data from next segments to the first one */
> +	m = mbuf->next;
> +	while (m != NULL) {
> +		m_next = m->next;
> +
> +		seg_len = rte_pktmbuf_data_len(m);
> +		rte_memcpy(buffer, rte_pktmbuf_mtod(m, char *), seg_len);
> +		buffer += seg_len;
> +
> +		rte_pktmbuf_free_seg(m);
> +		m = m_next;
> +	}
> +
> +	mbuf->next = NULL;
> +	mbuf->nb_segs = 1;
> +
> +	return 0;
> +}
> +
>  /* dump a mbuf on console */
>  void
>  rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index 98225ec80bf1..d25356b58cba 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -2412,44 +2412,8 @@ rte_validate_tx_offload(const struct rte_mbuf
> *m)
>   *   - 0, on success
>   *   - -1, on error
>   */
> -static inline int
> -rte_pktmbuf_linearize(struct rte_mbuf *mbuf)
> -{
> -	size_t seg_len, copy_len;
> -	struct rte_mbuf *m;
> -	struct rte_mbuf *m_next;
> -	char *buffer;
> -
> -	if (rte_pktmbuf_is_contiguous(mbuf))
> -		return 0;
> -
> -	/* Extend first segment to the total packet length */
> -	copy_len = rte_pktmbuf_pkt_len(mbuf) -
> rte_pktmbuf_data_len(mbuf);
> -
> -	if (unlikely(copy_len > rte_pktmbuf_tailroom(mbuf)))
> -		return -1;
> -
> -	buffer = rte_pktmbuf_mtod_offset(mbuf, char *, mbuf->data_len);
> -	mbuf->data_len = (uint16_t)(mbuf->pkt_len);
> -
> -	/* Append data from next segments to the first one */
> -	m = mbuf->next;
> -	while (m != NULL) {
> -		m_next = m->next;
> -
> -		seg_len = rte_pktmbuf_data_len(m);
> -		rte_memcpy(buffer, rte_pktmbuf_mtod(m, char *), seg_len);
> -		buffer += seg_len;
> -
> -		rte_pktmbuf_free_seg(m);
> -		m = m_next;
> -	}
> -
> -	mbuf->next = NULL;
> -	mbuf->nb_segs = 1;
> -
> -	return 0;
> -}
> +int
> +rte_pktmbuf_linearize(struct rte_mbuf *mbuf);
> 
>  /**
>   * Dump an mbuf structure to a file.
> diff --git a/lib/librte_mbuf/rte_mbuf_version.map
> b/lib/librte_mbuf/rte_mbuf_version.map
> index 2662a37bf674..7af410a4f687 100644
> --- a/lib/librte_mbuf/rte_mbuf_version.map
> +++ b/lib/librte_mbuf/rte_mbuf_version.map
> @@ -46,6 +46,12 @@ DPDK_18.08 {
>  	rte_pktmbuf_pool_create_by_ops;
>  } DPDK_16.11;
> 
> +DPDK_18.11 {
> +	global:
> +
> +	rte_pktmbuf_linearize;
> +} DPDK_18.08;
> +
>  EXPERIMENTAL {
>  	global:
> 
> --
> 2.20.1
> 


  parent reply	other threads:[~2019-09-30  9:00 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-28  0:37 [dpdk-dev] [PATCH 0/5] mbuf related patches Stephen Hemminger
2019-09-28  0:37 ` [dpdk-dev] [PATCH 1/5] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-09-28  0:37 ` [dpdk-dev] [PATCH 2/5] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-09-28 15:38   ` Stephen Hemminger
2019-09-30  9:00   ` Morten Brørup [this message]
2019-09-28  0:37 ` [dpdk-dev] [PATCH 3/5] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-09-28  0:37 ` [dpdk-dev] [PATCH 4/5] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-09-30 13:26   ` Morten Brørup
2019-09-28  0:37 ` [dpdk-dev] [PATCH 5/5] mbuf: add pktmbuf copy test Stephen Hemminger
2019-09-30 15:27 ` [dpdk-dev] [PATCH v2 0/6] mbuf copy related enhancements Stephen Hemminger
2019-09-30 15:27   ` [dpdk-dev] [PATCH v2 1/6] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-09-30 15:27   ` [dpdk-dev] [PATCH v2 2/6] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-09-30 15:27   ` [dpdk-dev] [PATCH v2 3/6] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-09-30 15:27   ` [dpdk-dev] [PATCH v2 4/6] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-09-30 15:27   ` [dpdk-dev] [PATCH v2 5/6] mbuf: add pktmbuf copy test Stephen Hemminger
2019-09-30 15:27   ` [dpdk-dev] [PATCH v2 6/6] pdump: use new pktmbuf copy function Stephen Hemminger
2019-09-30 19:20 ` [dpdk-dev] [PATCH v3 0/6] mbuf copy/cloning enhancements Stephen Hemminger
2019-09-30 19:20   ` [dpdk-dev] [PATCH v3 1/6] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-09-30 19:20   ` [dpdk-dev] [PATCH v3 2/6] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-10-01 13:41     ` Andrew Rybchenko
2019-09-30 19:20   ` [dpdk-dev] [PATCH v3 3/6] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-10-01 13:42     ` Andrew Rybchenko
2019-09-30 19:20   ` [dpdk-dev] [PATCH v3 4/6] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-10-01 14:03     ` Andrew Rybchenko
2019-10-01 17:36     ` Slava Ovsiienko
2019-10-01 23:29       ` Stephen Hemminger
2019-09-30 19:20   ` [dpdk-dev] [PATCH v3 5/6] mbuf: add pktmbuf copy test Stephen Hemminger
2019-09-30 19:20   ` [dpdk-dev] [PATCH v3 6/6] pdump: use new pktmbuf copy function Stephen Hemminger
2019-10-04 21:47 ` [dpdk-dev] [PATCH v4 0/4] mbuf copy/cloning enhancements Stephen Hemminger
2019-10-04 21:47   ` [dpdk-dev] [PATCH v4 1/4] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-10-04 21:47   ` [dpdk-dev] [PATCH v4 2/4] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-10-04 21:47   ` [dpdk-dev] [PATCH v4 3/4] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-10-04 21:47   ` [dpdk-dev] [PATCH v4 4/4] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-10-07 15:43 ` [dpdk-dev] [PATCH v5 0/5] mbuf copy/cloning enhancements Stephen Hemminger
2019-10-07 15:43   ` [dpdk-dev] [PATCH v5 1/5] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-10-08  8:13     ` Olivier Matz
2019-10-07 15:43   ` [dpdk-dev] [PATCH v5 2/5] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-10-08  8:14     ` Olivier Matz
2019-10-07 15:43   ` [dpdk-dev] [PATCH v5 3/5] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-10-08  8:15     ` Olivier Matz
2019-10-07 15:43   ` [dpdk-dev] [PATCH v5 4/5] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-10-08  9:03     ` Olivier Matz
2019-10-08 15:27       ` Stephen Hemminger
2019-10-07 15:43   ` [dpdk-dev] [PATCH v5 5/5] mbuf: add pktmbuf copy test Stephen Hemminger
2019-10-08  9:04     ` Olivier Matz
2019-10-08 16:33 ` [dpdk-dev] [PATCH v6 0/5] mbuf: copy/cloning enhancements Stephen Hemminger
2019-10-08 16:33   ` [dpdk-dev] [PATCH v6 1/5] mbuf: don't generate invalid mbuf in clone test Stephen Hemminger
2019-10-17  5:01     ` David Marchand
2019-10-08 16:33   ` [dpdk-dev] [PATCH v6 2/5] mbuf: delinline rte_pktmbuf_linearize Stephen Hemminger
2019-10-17  5:01     ` David Marchand
2019-10-08 16:33   ` [dpdk-dev] [PATCH v6 3/5] mbuf: deinline rte_pktmbuf_clone Stephen Hemminger
2019-10-17  5:01     ` David Marchand
2019-10-08 16:33   ` [dpdk-dev] [PATCH v6 4/5] mbuf: add a pktmbuf copy routine Stephen Hemminger
2019-10-16  6:58     ` Olivier Matz
2019-10-17  5:01       ` David Marchand
2019-10-08 16:33   ` [dpdk-dev] [PATCH v6 5/5] mbuf: add pktmbuf copy test Stephen Hemminger

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=98CBD80474FA8B44BF855DF32C47DC35C60B24@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /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).