diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h index 5e9b3b7..23168e7 100644 --- a/lib/librte_ring/rte_ring.h +++ b/lib/librte_ring/rte_ring.h @@ -517,6 +517,7 @@ __rte_ring_move_cons_head(struct rte_ring *r, int is_sc, n = max; *old_head = r->cons.head; + rte_smp_rmb(); const uint32_t prod_tail = r->prod.tail; /* The subtraction is done between two unsigned 32bits value * (the result is always modulo 32 bits even if we have diff --git a/test/test/test.c b/test/test/test.c index 9accbd1..6910b06 100644 --- a/test/test/test.c +++ b/test/test/test.c @@ -61,6 +61,7 @@ extern cmdline_parse_ctx_t main_ctx[]; #include "test.h" +extern int test_mbuf(void); #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1 const char *prgname; /* to be set to argv[0] */ @@ -135,6 +136,9 @@ main(int argc, char **argv) RTE_LOG(INFO, APP, "HPET is not enabled, using TSC as default timer\n"); + test_mbuf(); + printf("test_mbuf done\n"); + return 0; #ifdef RTE_LIBRTE_CMDLINE cl = cmdline_stdin_new(main_ctx, "RTE>>"); diff --git a/test/test/test_mbuf.c b/test/test/test_mbuf.c index 3396b4a..7277260 100644 --- a/test/test/test_mbuf.c +++ b/test/test/test_mbuf.c @@ -59,7 +59,6 @@ #include #include "test.h" - #define MBUF_DATA_SIZE 2048 #define NB_MBUF 128 #define MBUF_TEST_DATA_LEN 1464 @@ -85,7 +84,7 @@ static volatile uint32_t refcnt_stop_slaves; static unsigned refcnt_lcore[RTE_MAX_LCORE]; - +int test_mbuf(void); #endif /* @@ -718,7 +717,7 @@ test_refcnt_iter(unsigned int lcore, unsigned int iter, for (i = 0, n = rte_mempool_avail_count(refcnt_pool); i != n && (m = rte_pktmbuf_alloc(refcnt_pool)) != NULL; i++) { - ref = RTE_MAX(rte_rand() % REFCNT_MAX_REF, 1UL); + ref = REFCNT_MAX_REF; tref += ref; if ((ref & 1) != 0) { rte_pktmbuf_refcnt_update(m, ref); @@ -745,14 +744,17 @@ test_refcnt_iter(unsigned int lcore, unsigned int iter, for (wn = 0; wn != REFCNT_MAX_TIMEOUT; wn++) { if ((i = rte_mempool_avail_count(refcnt_pool)) == n) { refcnt_lcore[lcore] += tref; - printf("%s(lcore=%u, iter=%u) completed, " + /*printf("%s(lcore=%u, iter=%u) completed, " "%u references processed\n", - __func__, lcore, iter, tref); + __func__, lcore, iter, tref);*/ return; } rte_delay_ms(100); } + rte_mempool_dump(stdout, refcnt_pool); + rte_ring_dump(stdout, refcnt_pool->pool_data); + rte_ring_dump(stdout, refcnt_mbuf_ring); rte_panic("(lcore=%u, iter=%u): after %us only " "%u of %u mbufs left free\n", lcore, iter, wn, i, n); } @@ -766,7 +768,7 @@ test_refcnt_master(struct rte_mempool *refcnt_pool, lcore = rte_lcore_id(); printf("%s started at lcore %u\n", __func__, lcore); - for (i = 0; i != REFCNT_MAX_ITER; i++) + for (i = 0; i != 10*REFCNT_MAX_ITER; i++) test_refcnt_iter(lcore, i, refcnt_pool, refcnt_mbuf_ring); refcnt_stop_slaves = 1; @@ -1058,8 +1060,7 @@ test_mbuf_linearize_check(struct rte_mempool *pktmbuf_pool) return 0; } -static int -test_mbuf(void) +int test_mbuf(void) { int ret = -1; struct rte_mempool *pktmbuf_pool = NULL;