[v2] mbuf: display more fields in dump

Message ID 20191121183055.8096-1-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] mbuf: display more fields in dump |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/travis-robot success Travis build: passed

Commit Message

Stephen Hemminger Nov. 21, 2019, 6:30 p.m. UTC
  The rte_pktmbuf_dump should display offset, refcount, and vlan
info since these are often useful during debugging.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - remove casts, change in_port to port
     the refcount and offset are property of per-segment

 lib/librte_mbuf/rte_mbuf.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
  

Comments

Andrew Rybchenko Nov. 22, 2019, 12:31 p.m. UTC | #1
On 11/21/19 9:30 PM, Stephen Hemminger wrote:
> The rte_pktmbuf_dump should display offset, refcount, and vlan
> info since these are often useful during debugging.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

May be it would be a bit better to split cosmetic changes into
separate patch(es), but anyway

Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
  
Olivier Matz Dec. 26, 2019, 4:15 p.m. UTC | #2
Hi,

On Thu, Nov 21, 2019 at 10:30:55AM -0800, Stephen Hemminger wrote:
> The rte_pktmbuf_dump should display offset, refcount, and vlan
> info since these are often useful during debugging.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> v2 - remove casts, change in_port to port
>      the refcount and offset are property of per-segment
> 
>  lib/librte_mbuf/rte_mbuf.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> index 35df1c4c38a5..4894d46628e3 100644
> --- a/lib/librte_mbuf/rte_mbuf.c
> +++ b/lib/librte_mbuf/rte_mbuf.c
> @@ -473,18 +473,21 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)
>  
>  	__rte_mbuf_sanity_check(m, 1);
>  
> -	fprintf(f, "dump mbuf at %p, iova=%"PRIx64", buf_len=%u\n",
> -	       m, (uint64_t)m->buf_iova, (unsigned)m->buf_len);
> -	fprintf(f, "  pkt_len=%"PRIu32", ol_flags=%"PRIx64", nb_segs=%u, "
> -	       "in_port=%u\n", m->pkt_len, m->ol_flags,
> -	       (unsigned)m->nb_segs, (unsigned)m->port);
> +	fprintf(f, "dump mbuf at %p, iova=%#"PRIx64", buf_len=%u\n",
> +		m, m->buf_iova, m->buf_len);
> +	fprintf(f,
> +		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u, vlan_tci=%#x\n",
> +		m->pkt_len, m->ol_flags, m->nb_segs, m->port, m->vlan_tci);
> +
>  	nb_segs = m->nb_segs;
>  
>  	while (m && nb_segs != 0) {
>  		__rte_mbuf_sanity_check(m, 0);
>  
> -		fprintf(f, "  segment at %p, data=%p, data_len=%u\n",
> -			m, rte_pktmbuf_mtod(m, void *), (unsigned)m->data_len);
> +		fprintf(f, "  segment at %p, data=%p, len=%u, off=%u, refcnt=%u\n",
> +			m, rte_pktmbuf_mtod(m, void *),
> +			m->data_len, m->data_off, rte_mbuf_refcnt_read(m));
> +
>  		len = dump_len;
>  		if (len > m->data_len)
>  			len = m->data_len;
> -- 
> 2.20.1
> 

Thanks for this enhancement.

One comment however: I don't see why vlan_tci would be important than
packet type or rss tag. It is also a bit confusing to display a field
which can have a random value (if the vlan flag is not set in ol_flags).

I'd prefer to dump vlan_tci only if the flag is present. Later we could
add more fields with the same logic. What do you think?

Olivier
  
Stephen Hemminger Dec. 26, 2019, 4:58 p.m. UTC | #3
On Thu, 26 Dec 2019 17:15:39 +0100
Olivier Matz <olivier.matz@6wind.com> wrote:

> Hi,
> 
> On Thu, Nov 21, 2019 at 10:30:55AM -0800, Stephen Hemminger wrote:
> > The rte_pktmbuf_dump should display offset, refcount, and vlan
> > info since these are often useful during debugging.
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> > v2 - remove casts, change in_port to port
> >      the refcount and offset are property of per-segment
> > 
> >  lib/librte_mbuf/rte_mbuf.c | 17 ++++++++++-------
> >  1 file changed, 10 insertions(+), 7 deletions(-)
> > 
> > diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> > index 35df1c4c38a5..4894d46628e3 100644
> > --- a/lib/librte_mbuf/rte_mbuf.c
> > +++ b/lib/librte_mbuf/rte_mbuf.c
> > @@ -473,18 +473,21 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)
> >  
> >  	__rte_mbuf_sanity_check(m, 1);
> >  
> > -	fprintf(f, "dump mbuf at %p, iova=%"PRIx64", buf_len=%u\n",
> > -	       m, (uint64_t)m->buf_iova, (unsigned)m->buf_len);
> > -	fprintf(f, "  pkt_len=%"PRIu32", ol_flags=%"PRIx64", nb_segs=%u, "
> > -	       "in_port=%u\n", m->pkt_len, m->ol_flags,
> > -	       (unsigned)m->nb_segs, (unsigned)m->port);
> > +	fprintf(f, "dump mbuf at %p, iova=%#"PRIx64", buf_len=%u\n",
> > +		m, m->buf_iova, m->buf_len);
> > +	fprintf(f,
> > +		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u, vlan_tci=%#x\n",
> > +		m->pkt_len, m->ol_flags, m->nb_segs, m->port, m->vlan_tci);
> > +
> >  	nb_segs = m->nb_segs;
> >  
> >  	while (m && nb_segs != 0) {
> >  		__rte_mbuf_sanity_check(m, 0);
> >  
> > -		fprintf(f, "  segment at %p, data=%p, data_len=%u\n",
> > -			m, rte_pktmbuf_mtod(m, void *), (unsigned)m->data_len);
> > +		fprintf(f, "  segment at %p, data=%p, len=%u, off=%u, refcnt=%u\n",
> > +			m, rte_pktmbuf_mtod(m, void *),
> > +			m->data_len, m->data_off, rte_mbuf_refcnt_read(m));
> > +
> >  		len = dump_len;
> >  		if (len > m->data_len)
> >  			len = m->data_len;
> > -- 
> > 2.20.1
> >   
> 
> Thanks for this enhancement.
> 
> One comment however: I don't see why vlan_tci would be important than
> packet type or rss tag. It is also a bit confusing to display a field
> which can have a random value (if the vlan flag is not set in ol_flags).
> 
> I'd prefer to dump vlan_tci only if the flag is present. Later we could
> add more fields with the same logic. What do you think?

Because this is a debugging hook and easier to always display the value.
Thats all.
  
Olivier Matz Dec. 27, 2019, 9:10 a.m. UTC | #4
Hi,

On Thu, Dec 26, 2019 at 08:58:51AM -0800, Stephen Hemminger wrote:
> On Thu, 26 Dec 2019 17:15:39 +0100
> Olivier Matz <olivier.matz@6wind.com> wrote:
> 
> > Hi,
> > 
> > On Thu, Nov 21, 2019 at 10:30:55AM -0800, Stephen Hemminger wrote:
> > > The rte_pktmbuf_dump should display offset, refcount, and vlan
> > > info since these are often useful during debugging.
> > > 
> > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > > ---
> > > v2 - remove casts, change in_port to port
> > >      the refcount and offset are property of per-segment
> > > 
> > >  lib/librte_mbuf/rte_mbuf.c | 17 ++++++++++-------
> > >  1 file changed, 10 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> > > index 35df1c4c38a5..4894d46628e3 100644
> > > --- a/lib/librte_mbuf/rte_mbuf.c
> > > +++ b/lib/librte_mbuf/rte_mbuf.c
> > > @@ -473,18 +473,21 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)
> > >  
> > >  	__rte_mbuf_sanity_check(m, 1);
> > >  
> > > -	fprintf(f, "dump mbuf at %p, iova=%"PRIx64", buf_len=%u\n",
> > > -	       m, (uint64_t)m->buf_iova, (unsigned)m->buf_len);
> > > -	fprintf(f, "  pkt_len=%"PRIu32", ol_flags=%"PRIx64", nb_segs=%u, "
> > > -	       "in_port=%u\n", m->pkt_len, m->ol_flags,
> > > -	       (unsigned)m->nb_segs, (unsigned)m->port);
> > > +	fprintf(f, "dump mbuf at %p, iova=%#"PRIx64", buf_len=%u\n",
> > > +		m, m->buf_iova, m->buf_len);
> > > +	fprintf(f,
> > > +		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u, vlan_tci=%#x\n",
> > > +		m->pkt_len, m->ol_flags, m->nb_segs, m->port, m->vlan_tci);
> > > +
> > >  	nb_segs = m->nb_segs;
> > >  
> > >  	while (m && nb_segs != 0) {
> > >  		__rte_mbuf_sanity_check(m, 0);
> > >  
> > > -		fprintf(f, "  segment at %p, data=%p, data_len=%u\n",
> > > -			m, rte_pktmbuf_mtod(m, void *), (unsigned)m->data_len);
> > > +		fprintf(f, "  segment at %p, data=%p, len=%u, off=%u, refcnt=%u\n",
> > > +			m, rte_pktmbuf_mtod(m, void *),
> > > +			m->data_len, m->data_off, rte_mbuf_refcnt_read(m));
> > > +
> > >  		len = dump_len;
> > >  		if (len > m->data_len)
> > >  			len = m->data_len;
> > > -- 
> > > 2.20.1
> > >   
> > 
> > Thanks for this enhancement.
> > 
> > One comment however: I don't see why vlan_tci would be important than
> > packet type or rss tag. It is also a bit confusing to display a field
> > which can have a random value (if the vlan flag is not set in ol_flags).
> > 
> > I'd prefer to dump vlan_tci only if the flag is present. Later we could
> > add more fields with the same logic. What do you think?
> 
> Because this is a debugging hook and easier to always display the value.
> Thats all.

This is precisely because it is a debug hook that I find dangerous to
display a wrong value. As the mbuf are recycled, a mbuf that does not
have a vlan_tci can display its previous value, which may look valid.

What about simply doing this?

	fprintf(f,
		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u",
		m->pkt_len, m->ol_flags, m->nb_segs, m->port);
	if (m->ol_flags & PKT_RX_VLAN)
		fprintf(f, ", vlan_tci=%#x", m->vlan_tci);
	fprintf(f, "\n");

If you want I can submit an updated version of your patch.
  
Stephen Hemminger Dec. 27, 2019, 5:05 p.m. UTC | #5
On Fri, 27 Dec 2019 10:10:18 +0100
Olivier Matz <olivier.matz@6wind.com> wrote:

> Hi,
> 
> On Thu, Dec 26, 2019 at 08:58:51AM -0800, Stephen Hemminger wrote:
> > On Thu, 26 Dec 2019 17:15:39 +0100
> > Olivier Matz <olivier.matz@6wind.com> wrote:
> >   
> > > Hi,
> > > 
> > > On Thu, Nov 21, 2019 at 10:30:55AM -0800, Stephen Hemminger wrote:  
> > > > The rte_pktmbuf_dump should display offset, refcount, and vlan
> > > > info since these are often useful during debugging.
> > > > 
> > > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > > > ---
> > > > v2 - remove casts, change in_port to port
> > > >      the refcount and offset are property of per-segment
> > > > 
> > > >  lib/librte_mbuf/rte_mbuf.c | 17 ++++++++++-------
> > > >  1 file changed, 10 insertions(+), 7 deletions(-)
> > > > 
> > > > diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> > > > index 35df1c4c38a5..4894d46628e3 100644
> > > > --- a/lib/librte_mbuf/rte_mbuf.c
> > > > +++ b/lib/librte_mbuf/rte_mbuf.c
> > > > @@ -473,18 +473,21 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)
> > > >  
> > > >  	__rte_mbuf_sanity_check(m, 1);
> > > >  
> > > > -	fprintf(f, "dump mbuf at %p, iova=%"PRIx64", buf_len=%u\n",
> > > > -	       m, (uint64_t)m->buf_iova, (unsigned)m->buf_len);
> > > > -	fprintf(f, "  pkt_len=%"PRIu32", ol_flags=%"PRIx64", nb_segs=%u, "
> > > > -	       "in_port=%u\n", m->pkt_len, m->ol_flags,
> > > > -	       (unsigned)m->nb_segs, (unsigned)m->port);
> > > > +	fprintf(f, "dump mbuf at %p, iova=%#"PRIx64", buf_len=%u\n",
> > > > +		m, m->buf_iova, m->buf_len);
> > > > +	fprintf(f,
> > > > +		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u, vlan_tci=%#x\n",
> > > > +		m->pkt_len, m->ol_flags, m->nb_segs, m->port, m->vlan_tci);
> > > > +
> > > >  	nb_segs = m->nb_segs;
> > > >  
> > > >  	while (m && nb_segs != 0) {
> > > >  		__rte_mbuf_sanity_check(m, 0);
> > > >  
> > > > -		fprintf(f, "  segment at %p, data=%p, data_len=%u\n",
> > > > -			m, rte_pktmbuf_mtod(m, void *), (unsigned)m->data_len);
> > > > +		fprintf(f, "  segment at %p, data=%p, len=%u, off=%u, refcnt=%u\n",
> > > > +			m, rte_pktmbuf_mtod(m, void *),
> > > > +			m->data_len, m->data_off, rte_mbuf_refcnt_read(m));
> > > > +
> > > >  		len = dump_len;
> > > >  		if (len > m->data_len)
> > > >  			len = m->data_len;
> > > > -- 
> > > > 2.20.1
> > > >     
> > > 
> > > Thanks for this enhancement.
> > > 
> > > One comment however: I don't see why vlan_tci would be important than
> > > packet type or rss tag. It is also a bit confusing to display a field
> > > which can have a random value (if the vlan flag is not set in ol_flags).
> > > 
> > > I'd prefer to dump vlan_tci only if the flag is present. Later we could
> > > add more fields with the same logic. What do you think?  
> > 
> > Because this is a debugging hook and easier to always display the value.
> > Thats all.  
> 
> This is precisely because it is a debug hook that I find dangerous to
> display a wrong value. As the mbuf are recycled, a mbuf that does not
> have a vlan_tci can display its previous value, which may look valid.
> 
> What about simply doing this?
> 
> 	fprintf(f,
> 		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u",
> 		m->pkt_len, m->ol_flags, m->nb_segs, m->port);
> 	if (m->ol_flags & PKT_RX_VLAN)
> 		fprintf(f, ", vlan_tci=%#x", m->vlan_tci);
> 	fprintf(f, "\n");
> 
> If you want I can submit an updated version of your patch

The right flags are more complex, you need to deal with TX vlan.
And PKT_RX_VLAN means "this is a vlan packet" it doesn't mean
vlan tag is stripped into TCI.  That is PKT_RX_VLAN_STRIPPED
  
Olivier Matz Dec. 30, 2019, 8:11 a.m. UTC | #6
On Fri, Dec 27, 2019 at 09:05:07AM -0800, Stephen Hemminger wrote:
> On Fri, 27 Dec 2019 10:10:18 +0100
> Olivier Matz <olivier.matz@6wind.com> wrote:
> 
> > Hi,
> > 
> > On Thu, Dec 26, 2019 at 08:58:51AM -0800, Stephen Hemminger wrote:
> > > On Thu, 26 Dec 2019 17:15:39 +0100
> > > Olivier Matz <olivier.matz@6wind.com> wrote:
> > >   
> > > > Hi,
> > > > 
> > > > On Thu, Nov 21, 2019 at 10:30:55AM -0800, Stephen Hemminger wrote:  
> > > > > The rte_pktmbuf_dump should display offset, refcount, and vlan
> > > > > info since these are often useful during debugging.
> > > > > 
> > > > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > > > > ---
> > > > > v2 - remove casts, change in_port to port
> > > > >      the refcount and offset are property of per-segment
> > > > > 
> > > > >  lib/librte_mbuf/rte_mbuf.c | 17 ++++++++++-------
> > > > >  1 file changed, 10 insertions(+), 7 deletions(-)
> > > > > 
> > > > > diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
> > > > > index 35df1c4c38a5..4894d46628e3 100644
> > > > > --- a/lib/librte_mbuf/rte_mbuf.c
> > > > > +++ b/lib/librte_mbuf/rte_mbuf.c
> > > > > @@ -473,18 +473,21 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)
> > > > >  
> > > > >  	__rte_mbuf_sanity_check(m, 1);
> > > > >  
> > > > > -	fprintf(f, "dump mbuf at %p, iova=%"PRIx64", buf_len=%u\n",
> > > > > -	       m, (uint64_t)m->buf_iova, (unsigned)m->buf_len);
> > > > > -	fprintf(f, "  pkt_len=%"PRIu32", ol_flags=%"PRIx64", nb_segs=%u, "
> > > > > -	       "in_port=%u\n", m->pkt_len, m->ol_flags,
> > > > > -	       (unsigned)m->nb_segs, (unsigned)m->port);
> > > > > +	fprintf(f, "dump mbuf at %p, iova=%#"PRIx64", buf_len=%u\n",
> > > > > +		m, m->buf_iova, m->buf_len);
> > > > > +	fprintf(f,
> > > > > +		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u, vlan_tci=%#x\n",
> > > > > +		m->pkt_len, m->ol_flags, m->nb_segs, m->port, m->vlan_tci);
> > > > > +
> > > > >  	nb_segs = m->nb_segs;
> > > > >  
> > > > >  	while (m && nb_segs != 0) {
> > > > >  		__rte_mbuf_sanity_check(m, 0);
> > > > >  
> > > > > -		fprintf(f, "  segment at %p, data=%p, data_len=%u\n",
> > > > > -			m, rte_pktmbuf_mtod(m, void *), (unsigned)m->data_len);
> > > > > +		fprintf(f, "  segment at %p, data=%p, len=%u, off=%u, refcnt=%u\n",
> > > > > +			m, rte_pktmbuf_mtod(m, void *),
> > > > > +			m->data_len, m->data_off, rte_mbuf_refcnt_read(m));
> > > > > +
> > > > >  		len = dump_len;
> > > > >  		if (len > m->data_len)
> > > > >  			len = m->data_len;
> > > > > -- 
> > > > > 2.20.1
> > > > >     
> > > > 
> > > > Thanks for this enhancement.
> > > > 
> > > > One comment however: I don't see why vlan_tci would be important than
> > > > packet type or rss tag. It is also a bit confusing to display a field
> > > > which can have a random value (if the vlan flag is not set in ol_flags).
> > > > 
> > > > I'd prefer to dump vlan_tci only if the flag is present. Later we could
> > > > add more fields with the same logic. What do you think?  
> > > 
> > > Because this is a debugging hook and easier to always display the value.
> > > Thats all.  
> > 
> > This is precisely because it is a debug hook that I find dangerous to
> > display a wrong value. As the mbuf are recycled, a mbuf that does not
> > have a vlan_tci can display its previous value, which may look valid.
> > 
> > What about simply doing this?
> > 
> > 	fprintf(f,
> > 		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u",
> > 		m->pkt_len, m->ol_flags, m->nb_segs, m->port);
> > 	if (m->ol_flags & PKT_RX_VLAN)
> > 		fprintf(f, ", vlan_tci=%#x", m->vlan_tci);
> > 	fprintf(f, "\n");
> > 
> > If you want I can submit an updated version of your patch
> 
> The right flags are more complex, you need to deal with TX vlan.
> And PKT_RX_VLAN means "this is a vlan packet" it doesn't mean
> vlan tag is stripped into TCI.  That is PKT_RX_VLAN_STRIPPED

PKT_RX_VLAN means that m->vlan_tci is valid, and this is what we
want here.
  

Patch

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 35df1c4c38a5..4894d46628e3 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -473,18 +473,21 @@  rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)
 
 	__rte_mbuf_sanity_check(m, 1);
 
-	fprintf(f, "dump mbuf at %p, iova=%"PRIx64", buf_len=%u\n",
-	       m, (uint64_t)m->buf_iova, (unsigned)m->buf_len);
-	fprintf(f, "  pkt_len=%"PRIu32", ol_flags=%"PRIx64", nb_segs=%u, "
-	       "in_port=%u\n", m->pkt_len, m->ol_flags,
-	       (unsigned)m->nb_segs, (unsigned)m->port);
+	fprintf(f, "dump mbuf at %p, iova=%#"PRIx64", buf_len=%u\n",
+		m, m->buf_iova, m->buf_len);
+	fprintf(f,
+		"  pkt_len=%u, ol_flags=%#"PRIx64", nb_segs=%u, port=%u, vlan_tci=%#x\n",
+		m->pkt_len, m->ol_flags, m->nb_segs, m->port, m->vlan_tci);
+
 	nb_segs = m->nb_segs;
 
 	while (m && nb_segs != 0) {
 		__rte_mbuf_sanity_check(m, 0);
 
-		fprintf(f, "  segment at %p, data=%p, data_len=%u\n",
-			m, rte_pktmbuf_mtod(m, void *), (unsigned)m->data_len);
+		fprintf(f, "  segment at %p, data=%p, len=%u, off=%u, refcnt=%u\n",
+			m, rte_pktmbuf_mtod(m, void *),
+			m->data_len, m->data_off, rte_mbuf_refcnt_read(m));
+
 		len = dump_len;
 		if (len > m->data_len)
 			len = m->data_len;