DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] mbuf: rte_pktmbuf_alloc_bulk bugfix
@ 2017-05-05 13:29 Gregory Etelson
  2017-05-05 13:54 ` Olivier Matz
  0 siblings, 1 reply; 2+ messages in thread
From: Gregory Etelson @ 2017-05-05 13:29 UTC (permalink / raw)
  To: dev

bugfix in rte_pktmbuf_alloc_bulk

Signed-off-by: Gregory Etelson <gregory@weka.io>
---
 lib/librte_mbuf/rte_mbuf.h | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 466ec00..bebe94f 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -788,6 +788,12 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value)
 void
 rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header);
 
+#define MBUF_RAW_ALLOC_CHECK(m_)				\
+	RTE_ASSERT(rte_mbuf_refcnt_read(m_) == 1);	\
+	RTE_ASSERT(m_->next == NULL);				\
+	RTE_ASSERT(m_->nb_segs == 1);				\
+	__rte_mbuf_sanity_check(m_, 0);
+
 /**
  * Allocate an unitialized mbuf from mempool *mp*.
  *
@@ -815,11 +821,7 @@ static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp)
 	if (rte_mempool_get(mp, &mb) < 0)
 		return NULL;
 	m = (struct rte_mbuf *)mb;
-	RTE_ASSERT(rte_mbuf_refcnt_read(m) == 1);
-	RTE_ASSERT(m->next == NULL);
-	RTE_ASSERT(m->nb_segs == 1);
-	__rte_mbuf_sanity_check(m, 0);
-
+	MBUF_RAW_ALLOC_CHECK(m);
 	return m;
 }
 
@@ -1152,23 +1154,19 @@ static inline int rte_pktmbuf_alloc_bulk(struct rte_mempool *pool,
 	switch (count % 4) {
 	case 0:
 		while (idx != count) {
-			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
-			rte_mbuf_refcnt_set(mbufs[idx], 1);
+			MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
 			rte_pktmbuf_reset(mbufs[idx]);
 			idx++;
 	case 3:
-			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
-			rte_mbuf_refcnt_set(mbufs[idx], 1);
+			MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
 			rte_pktmbuf_reset(mbufs[idx]);
 			idx++;
 	case 2:
-			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
-			rte_mbuf_refcnt_set(mbufs[idx], 1);
+			MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
 			rte_pktmbuf_reset(mbufs[idx]);
 			idx++;
 	case 1:
-			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
-			rte_mbuf_refcnt_set(mbufs[idx], 1);
+			MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
 			rte_pktmbuf_reset(mbufs[idx]);
 			idx++;
 		}
-- 
2.9.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] mbuf: rte_pktmbuf_alloc_bulk bugfix
  2017-05-05 13:29 [dpdk-dev] [PATCH] mbuf: rte_pktmbuf_alloc_bulk bugfix Gregory Etelson
@ 2017-05-05 13:54 ` Olivier Matz
  0 siblings, 0 replies; 2+ messages in thread
From: Olivier Matz @ 2017-05-05 13:54 UTC (permalink / raw)
  To: Gregory Etelson; +Cc: dev

Hi Gregory,

On Fri, 05 May 2017 16:29:59 +0300, Gregory Etelson <gregory@weka.io> wrote:
> bugfix in rte_pktmbuf_alloc_bulk
> 
> Signed-off-by: Gregory Etelson <gregory@weka.io>

Thank you for the fix. I suggest the following title instead:

mbuf: fix bulk allocation when debug enabled

Please refer to the guidelines:
http://dpdk.org/doc/guides/contributing/patches.html#commit-messages-subject-line

A description would have been welcome, for instance:

The debug assertions when allocating a raw mbuf are not correct since
commit 8f094a9ac5d7 ("mbuf: set mbuf fields while in pool"),
which triggers a panic when using this function in debug mode.

Change the expected number of segments to 1 instead of 0, and
factorize these sanity checks.


Fixes: 8f094a9ac5d7 ("mbuf: set mbuf fields while in pool")


Can you please submit a v2 with these changes? You can validate
your changes with checkpatches.sh and check-git-log.sh.

Thanks,
Olivier


> ---
>  lib/librte_mbuf/rte_mbuf.h | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
> index 466ec00..bebe94f 100644
> --- a/lib/librte_mbuf/rte_mbuf.h
> +++ b/lib/librte_mbuf/rte_mbuf.h
> @@ -788,6 +788,12 @@ rte_mbuf_refcnt_set(struct rte_mbuf *m, uint16_t new_value)
>  void
>  rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header);
>  
> +#define MBUF_RAW_ALLOC_CHECK(m_)				\
> +	RTE_ASSERT(rte_mbuf_refcnt_read(m_) == 1);	\
> +	RTE_ASSERT(m_->next == NULL);				\
> +	RTE_ASSERT(m_->nb_segs == 1);				\
> +	__rte_mbuf_sanity_check(m_, 0);
> +
>  /**
>   * Allocate an unitialized mbuf from mempool *mp*.
>   *
> @@ -815,11 +821,7 @@ static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp)
>  	if (rte_mempool_get(mp, &mb) < 0)
>  		return NULL;
>  	m = (struct rte_mbuf *)mb;
> -	RTE_ASSERT(rte_mbuf_refcnt_read(m) == 1);
> -	RTE_ASSERT(m->next == NULL);
> -	RTE_ASSERT(m->nb_segs == 1);
> -	__rte_mbuf_sanity_check(m, 0);
> -
> +	MBUF_RAW_ALLOC_CHECK(m);
>  	return m;
>  }
>  
> @@ -1152,23 +1154,19 @@ static inline int rte_pktmbuf_alloc_bulk(struct rte_mempool *pool,
>  	switch (count % 4) {
>  	case 0:
>  		while (idx != count) {
> -			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
> -			rte_mbuf_refcnt_set(mbufs[idx], 1);
> +			MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
>  			rte_pktmbuf_reset(mbufs[idx]);
>  			idx++;
>  	case 3:
> -			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
> -			rte_mbuf_refcnt_set(mbufs[idx], 1);
> +			MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
>  			rte_pktmbuf_reset(mbufs[idx]);
>  			idx++;
>  	case 2:
> -			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
> -			rte_mbuf_refcnt_set(mbufs[idx], 1);
> +			MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
>  			rte_pktmbuf_reset(mbufs[idx]);
>  			idx++;
>  	case 1:
> -			RTE_ASSERT(rte_mbuf_refcnt_read(mbufs[idx]) == 0);
> -			rte_mbuf_refcnt_set(mbufs[idx], 1);
> +			MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
>  			rte_pktmbuf_reset(mbufs[idx]);
>  			idx++;
>  		}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-05 13:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05 13:29 [dpdk-dev] [PATCH] mbuf: rte_pktmbuf_alloc_bulk bugfix Gregory Etelson
2017-05-05 13:54 ` Olivier Matz

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).