refactor and cleanup of rte_ring
Subsystems (3)
PATCH 1/14 ring: remove split cacheline build setting
In reply to Bruce RichardsonUsers compiling DPDK should not need to know or care about the arrangement of cachelines in the rte_ring structure. Therefore just remove the build option and set the structures to be always split. For improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.
--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 6 ++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 8 ++------ 4 files changed, 8 insertions(+), 9 deletions(-)
config/common_base +0 -1
@@ -448,7 +448,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #
doc/guides/rel_notes/release_17_05.rst +6 -0
@@ -110,6 +110,12 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` ABI Changes -----------
lib/librte_ring/rte_ring.c +0 -2
@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG
lib/librte_ring/rte_ring.h +2 -6
@@ -168,7 +168,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + } prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2);/** Ring consumer status. */ struct cons {
@@ -177,11 +177,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Consumer head. */ volatile uint32_t tail;/**< Consumer tail. */ -#ifdef RTE_RING_SPLIT_PROD_CONS - }cons __rte_cache_aligned; -#else - } cons; -#endif + } cons __rte_aligned(RTE_CACHE_LINE_SIZE * 2);#ifdef RTE_LIBRTE_RING_DEBUG struct rte_ring_debug_stats stats[RTE_MAX_LCORE ];
Signature · 1 line
2.9.3
PATCH 2/14 ring: create common structure for prod and cons metadata
In reply to Bruce Richardsoncreate a common structure to hold the metadata for the producer and the consumer, since both need essentially the same information - the head and tail values, the ring size and mask.
--- lib/librte_ring/rte_ring.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
lib/librte_ring/rte_ring.h +16 -16
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -139,6 +139,19 @@ struct rte_ring_debug_stats {struct rte_memzone ;/* forward declaration, so as not to require memzone.h */ +/* structure to hold a pair of head/tail values and other metadata */ +struct rte_ring_ht_ptr { +volatile uint32_t head;/**< Prod/consumer head. */ +volatile uint32_t tail;/**< Prod/consumer tail. */ +uint32_t size;/**< Size of ring. */ +uint32_t mask;/**< Mask (size-1) of ring. */ +union { +uint32_t sp_enqueue;/**< True, if single producer. */ +uint32_t sc_dequeue;/**< True, if single consumer. */ + }; +uint32_t watermark;/**< Max items before EDQUOT in producer. */ +}; +/** * An RTE ring structure. *
@@ -161,23 +174,10 @@ struct rte_ring {/**< Memzone, if any, containing the rte_ring */ /** Ring producer status. */ -struct prod { -uint32_t watermark;/**< Maximum items before EDQUOT. */ -uint32_t sp_enqueue;/**< True, if single producer. */ -uint32_t size;/**< Size of ring. */ -uint32_t mask;/**< Mask (size-1) of ring. */ -volatile uint32_t head;/**< Producer head. */ -volatile uint32_t tail;/**< Producer tail. */ - } prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2); + struct rte_ring_ht_ptr prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2);/** Ring consumer status. */ -struct cons { -uint32_t sc_dequeue;/**< True, if single consumer. */ -uint32_t size;/**< Size of the ring. */ -uint32_t mask;/**< Mask (size-1) of ring. */ -volatile uint32_t head;/**< Consumer head. */ -volatile uint32_t tail;/**< Consumer tail. */ - } cons __rte_aligned(RTE_CACHE_LINE_SIZE * 2); + struct rte_ring_ht_ptr cons __rte_aligned(RTE_CACHE_LINE_SIZE * 2);#ifdef RTE_LIBRTE_RING_DEBUG struct rte_ring_debug_stats stats[RTE_MAX_LCORE ];
Signature · 1 line
2.9.3
cover refactor and cleanup of rte_ring
NOTE: this set depends on the v2 cleanup set sent previously.
http://dpdk.org/ml/archives/dev/2017-February/thread.html#58200
This patchset make a set of, sometimes non-backward compatible, cleanup changes to the rte_ring code in order to improve it. The resulting code is shorter, since the existing functions are restructured to reduce code duplication, as well as being more consistent in behaviour. The specific changes made are explained in each patch which makes that change.
This patchset is largely the same as that posted previously on-list as an RFC:
http://dpdk.org/ml/archives/dev/2017-February/thread.html#56982
Changes in V1 from RFC:
* Included release notes updates as changes are made in each patch
* Fixed some missed comment updates when changing the code
* Separated some initial fixup patches from this set to send separately
* Dropped the final two patches for an rte_event_ring, as not relevant for this set. That can be done as a separate set later.
* The macros for copying the pointers have an extra parameter added, indicating the start of the ring buffer itself. This allows more flexibility for reusing them in other ring implementations.
Bruce Richardson (14):
ring: remove split cacheline build setting
ring: create common structure for prod and cons metadata
ring: eliminate duplication of size and mask fields
ring: remove debug setting
ring: remove the yield when waiting for tail update
ring: remove watermark support
ring: make bulk and burst fn return vals consistent
ring: allow enqueue fns to return free space value
ring: allow dequeue fns to return remaining entry count examples/quota_watermark: use ring space for watermarks
ring: reduce scope of local variables
ring: separate out head index manipulation for enq/deq
ring: create common function for updating tail idx
ring: make rte_ring struct and enq/deq macros type agnostic
app/pdump/main.c | 2 +- app/test-pipeline/pipeline_hash.c | 5 +- app/test-pipeline/runtime.c | 19 +- app/test/commands.c | 52 -- app/test/test_link_bonding_mode4.c | 6 +- app/test/test_pmd_ring_perf.c | 12 +- app/test/test_ring.c | 704 +++---------------- app/test/test_ring_perf.c | 36 +- app/test/test_table_acl.c | 2 +- app/test/test_table_pipeline.c | 2 +- app/test/test_table_ports.c | 12 +- app/test/virtual_pmd.c | 8 +- config/common_base | 3 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 - doc/guides/prog_guide/ring_lib.rst | 7 - doc/guides/rel_notes/release_17_05.rst | 32 + doc/guides/sample_app_ug/server_node_efd.rst | 2 +- drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 4 +- examples/distributor/main.c | 5 +- examples/load_balancer/runtime.c | 34 +- .../client_server_mp/mp_client/client.c | 9 +- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 13 +- examples/qos_sched/app_thread.c | 14 +- examples/quota_watermark/qw/init.c | 5 +- examples/quota_watermark/qw/main.c | 21 +- examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 +- examples/quota_watermark/qwctl/qwctl.c | 2 + examples/quota_watermark/qwctl/qwctl.h | 1 + examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 5 +- lib/librte_mempool/rte_mempool_ring.c | 12 +- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 34 +- lib/librte_ring/rte_ring.c | 76 +-- lib/librte_ring/rte_ring.h | 754 ++++++++------------- 42 files changed, 547 insertions(+), 1374 deletions(-)
Signature · 1 line
2.9.3
PATCH 3/14 ring: eliminate duplication of size and mask fields
The size and mask fields are duplicated in both the producer and consumer data structures. Move them out of that into the top level structure so they are not duplicated.
--- app/test/test_ring.c | 6 +++--- lib/librte_ring/rte_ring.c | 20 ++++++++++---------- lib/librte_ring/rte_ring.h | 32 ++++++++++++++++---------------- 3 files changed, 29 insertions(+), 29 deletions(-)
app/test/test_ring.c +3 -3
@@ -148,7 +148,7 @@ check_live_watermark_change(__attribute__((unused)) void *dummy) }/* read watermark, the only change allowed is from 16 to 32 */ - watermark = r->prod.watermark; + watermark = r->watermark;if (watermark != watermark_old && (watermark_old !=16 || watermark !=32 )) { printf("Bad watermark change %u -> %u\n", watermark_old,
@@ -213,7 +213,7 @@ test_set_watermark( void ){printf (" ring lookup failed\n" ); goto error; } - count = r->prod.size*2 ; + count = r->size *2 ; setwm =rte_ring_set_water_mark (r, count);if (setwm != -EINVAL ){printf ("Test failed to detect invalid watermark count value\n" );
@@ -222,7 +222,7 @@ test_set_watermark( void ){ count =0 ;rte_ring_set_water_mark (r, count); -if (r->prod.watermark != r->prod.size) { +if (r->watermark != r->size) {printf ("Test failed to detect invalid watermark count value\n" ); goto error; }
lib/librte_ring/rte_ring.c +10 -10
@@ -144,11 +144,11 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->prod.watermark = count; + r->watermark = count; r->prod.sp_enqueue = !!(flags &RING_F_SP_ENQ ); r->cons.sc_dequeue = !!(flags &RING_F_SC_DEQ ); - r->prod.size = r->cons.size = count; - r->prod.mask = r->cons.mask = count-1 ; + r->size = count; + r->mask = count -1 ; r->prod.head = r->cons.head =0 ; r->prod.tail = r->cons.tail =0 ;
@@ -269,14 +269,14 @@ rte_ring_free(struct rte_ring *r)int rte_ring_set_water_mark (struct rte_ring *r,unsigned count) { -if (count >= r->prod.size) +if (count >= r->size)return -EINVAL ;/* if count is 0, disable the watermarking */ if (count ==0 ) - count = r->prod.size; + count = r->size; - r->prod.watermark = count; + r->watermark = count;return 0 ; }
@@ -291,17 +291,17 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)fprintf (f,"ring <%s>@%p\n" , r->name, r);fprintf (f," flags=%x\n" , r->flags); -fprintf (f," size=%" PRIu32"\n" , r->prod.size); +fprintf (f," size=%" PRIu32"\n" , r->size);fprintf (f," ct=%" PRIu32"\n" , r->cons.tail);fprintf (f," ch=%" PRIu32"\n" , r->cons.head);fprintf (f," pt=%" PRIu32"\n" , r->prod.tail);fprintf (f," ph=%" PRIu32"\n" , r->prod.head);fprintf (f," used=%u\n" ,rte_ring_count (r));fprintf (f," avail=%u\n" ,rte_ring_free_count (r)); -if (r->prod.watermark == r->prod.size) +if (r->watermark == r->size)fprintf (f," watermark=0\n" );else -fprintf (f," watermark=%" PRIu32"\n" , r->prod.watermark); +fprintf (f," watermark=%" PRIu32"\n" , r->watermark);/* sum and dump statistics */ #ifdef RTE_LIBRTE_RING_DEBUG
@@ -318,7 +318,7 @@ rte_ring_dump(FILE *f, const struct rte_ring *r) sum.deq_fail_bulk += r->stats[lcore_id].deq_fail_bulk; sum.deq_fail_objs += r->stats[lcore_id].deq_fail_objs; } -fprintf (f," size=%" PRIu32"\n" , r->prod.size); +fprintf (f," size=%" PRIu32"\n" , r->size);fprintf (f," enq_success_bulk=%" PRIu64"\n" , sum.enq_success_bulk);fprintf (f," enq_success_objs=%" PRIu64"\n" , sum.enq_success_objs);fprintf (f," enq_quota_bulk=%" PRIu64"\n" , sum.enq_quota_bulk);
lib/librte_ring/rte_ring.h +16 -16
@@ -143,13 +143,10 @@ struct rte_memzone; /* forward declaration, so as not to require memzone.h */struct rte_ring_ht_ptr {volatile uint32_t head;/**< Prod/consumer head. */ volatile uint32_t tail;/**< Prod/consumer tail. */ -uint32_t size;/**< Size of ring. */ -uint32_t mask;/**< Mask (size-1) of ring. */ union {uint32_t sp_enqueue;/**< True, if single producer. */ uint32_t sc_dequeue;/**< True, if single consumer. */ }; -uint32_t watermark;/**< Max items before EDQUOT in producer. */ };/**
@@ -169,9 +166,12 @@ struct rte_ring {* next time the ABI changes */ char name[RTE_MEMZONE_NAMESIZE ];/**< Name of the ring. */ -int flags;/**< Flags supplied at creation. */ +int flags;/**< Flags supplied at creation. */ const struct rte_memzone *memzone;/**< Memzone, if any, containing the rte_ring */ +uint32_t size;/**< Size of ring. */ +uint32_t mask;/**< Mask (size-1) of ring. */ +uint32_t watermark;/**< Max items before EDQUOT in producer. */ /** Ring producer status. */ struct rte_ring_ht_ptr prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2);
@@ -350,7 +350,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi producer enqueue functions */ #define ENQUEUE_PTRS () do { \ - const uint32_t size = r->prod.size; \ + const uint32_t size = r->size; \ uint32_t idx = prod_head & mask; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
@@ -377,7 +377,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* single and multi consumer dequeue functions */ #define DEQUEUE_PTRS () do { \ uint32_t idx = cons_head & mask; \ - const uint32_t size = r->cons.size; \ + const uint32_t size = r->size; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\ obj_table[i] = r->ring[idx]; \
@@ -432,7 +432,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,const unsigned max = n;int success;unsigned i, rep =0 ; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;int ret;/* Avoid the unnecessary cmpset operation below, which is also
@@ -480,7 +480,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb ();/* if we exceed the watermark */ -if (unlikely (((mask +1 ) - free_entries + n) > r->prod.watermark)) { +if (unlikely (((mask +1 ) - free_entries + n) > r->watermark)) { ret = (behavior ==RTE_RING_QUEUE_FIXED ) ? -EDQUOT : (int )(n |RTE_RING_QUOT_EXCEED );__RING_STAT_ADD (r, enq_quota, n);
@@ -539,7 +539,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries;unsigned i; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;int ret; prod_head = r->prod.head;
@@ -575,7 +575,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb ();/* if we exceed the watermark */ -if (unlikely (((mask +1 ) - free_entries + n) > r->prod.watermark)) { +if (unlikely (((mask +1 ) - free_entries + n) > r->watermark)) { ret = (behavior ==RTE_RING_QUEUE_FIXED ) ? -EDQUOT : (int )(n |RTE_RING_QUOT_EXCEED );__RING_STAT_ADD (r, enq_quota, n);
@@ -625,7 +625,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,const unsigned max = n;int success;unsigned i, rep =0 ; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;/* Avoid the unnecessary cmpset operation below, which is also * potentially harmful when n equals 0. */
@@ -722,7 +722,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_head, prod_tail;uint32_t cons_next, entries;unsigned i; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask; cons_head = r->cons.head; prod_tail = r->prod.tail;
@@ -1051,7 +1051,7 @@ rte_ring_full(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return ((cons_tail - prod_tail -1 ) & r->prod.mask) ==0 ; +return ((cons_tail - prod_tail -1 ) & r->mask) ==0 ; }/**
@@ -1084,7 +1084,7 @@ rte_ring_count(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return (prod_tail - cons_tail) & r->prod.mask; +return (prod_tail - cons_tail) & r->mask; }/**
@@ -1100,7 +1100,7 @@ rte_ring_free_count(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return (cons_tail - prod_tail -1 ) & r->prod.mask; +return (cons_tail - prod_tail -1 ) & r->mask; }/**
@@ -1114,7 +1114,7 @@ rte_ring_free_count(const struct rte_ring *r)static inline unsigned int rte_ring_get_size (const struct rte_ring *r) { -return r->prod.size; +return r->size; }/**
Signature · 1 line
2.9.3
PATCH 4/14 ring: remove debug setting
In reply to Bruce RichardsonThe debug option only provided statistics to the user, most of which could be tracked by the application itself. Remove this as a compile time option, and feature, simplifying the code.
--- app/test/test_ring.c | 410 --------------------------------- config/common_base | 1 - doc/guides/prog_guide/ring_lib.rst | 7 - doc/guides/rel_notes/release_17_05.rst | 1 + lib/librte_ring/rte_ring.c | 41 ---- lib/librte_ring/rte_ring.h | 97 +------- 6 files changed, 13 insertions(+), 544 deletions(-)
app/test/test_ring.c +0 -410
@@ -763,412 +763,6 @@ test_ring_burst_basic(void)return -1 ; } -static int -test_ring_stats (void ) -{ - -#ifndef RTE_LIBRTE_RING_DEBUG -printf ("Enable RTE_LIBRTE_RING_DEBUG to test ring stats.\n" ); -return 0 ; -#else -void **src =NULL , **cur_src =NULL , **dst =NULL , **cur_dst =NULL ; -int ret; -unsigned i; -unsigned num_items =0 ; -unsigned failed_enqueue_ops =0 ; -unsigned failed_enqueue_items =0 ; -unsigned failed_dequeue_ops =0 ; -unsigned failed_dequeue_items =0 ; -unsigned last_enqueue_ops =0 ; -unsigned last_enqueue_items =0 ; -unsigned last_quota_ops =0 ; -unsigned last_quota_items =0 ; -unsigned lcore_id =rte_lcore_id (); -struct rte_ring_debug_stats *ring_stats = &r->stats[lcore_id]; - -printf ("Test the ring stats.\n" ); - -/* Reset the watermark in case it was set in another test. */ -rte_ring_set_water_mark (r,0 ); - -/* Reset the ring stats. */ -memset (&r->stats[lcore_id],0 ,sizeof (r->stats[lcore_id])); - -/* Allocate some dummy object pointers. */ - src =malloc (RING_SIZE *2 *sizeof (void *)); -if (src ==NULL ) - goto fail; - -for (i =0 ; i <RING_SIZE *2 ; i++) { - src[i] = (void *)(unsigned long )i; - } - -/* Allocate some memory for copied objects. */ - dst =malloc (RING_SIZE *2 *sizeof (void *)); -if (dst ==NULL ) - goto fail; - -memset (dst,0 ,RING_SIZE *2 *sizeof (void *)); - -/* Set the head and tail pointers. */ - cur_src = src; - cur_dst = dst; - -/* Do Enqueue tests. */ -printf ("Test the dequeue stats.\n" ); - -/* Fill the ring up to RING_SIZE -1. */ -printf ("Fill the ring.\n" ); -for (i =0 ; i< (RING_SIZE /MAX_BULK ); i++) { -rte_ring_sp_enqueue_burst (r, cur_src,MAX_BULK ); - cur_src +=MAX_BULK ; - } - -/* Adjust for final enqueue = MAX_BULK -1. */ - cur_src--; - -printf ("Verify that the ring is full.\n" ); -if (rte_ring_full (r) !=1 ) - goto fail; - - -printf ("Verify the enqueue success stats.\n" ); -/* Stats should match above enqueue operations to fill the ring. */ -if (ring_stats->enq_success_bulk != (RING_SIZE /MAX_BULK )) - goto fail; - -/* Current max objects is RING_SIZE -1. */ -if (ring_stats->enq_success_objs !=RING_SIZE -1 ) - goto fail; - -/* Shouldn't have any failures yet. */ -if (ring_stats->enq_fail_bulk !=0 ) - goto fail; -if (ring_stats->enq_fail_objs !=0 ) - goto fail; - - -printf ("Test stats for SP burst enqueue to a full ring.\n" ); - num_items =2 ; - ret =rte_ring_sp_enqueue_burst (r, cur_src, num_items); -if ((ret &RTE_RING_SZ_MASK ) !=0 ) - goto fail; - - failed_enqueue_ops +=1 ; - failed_enqueue_items += num_items; - -/* The enqueue should have failed. */ -if (ring_stats->enq_fail_bulk != failed_enqueue_ops) - goto fail; -if (ring_stats->enq_fail_objs != failed_enqueue_items) - goto fail; - - -printf ("Test stats for SP bulk enqueue to a full ring.\n" ); - num_items =4 ; - ret =rte_ring_sp_enqueue_bulk (r, cur_src, num_items); -if (ret != -ENOBUFS ) - goto fail; - - failed_enqueue_ops +=1 ; - failed_enqueue_items += num_items; - -/* The enqueue should have failed. */ -if (ring_stats->enq_fail_bulk != failed_enqueue_ops) - goto fail; -if (ring_stats->enq_fail_objs != failed_enqueue_items) - goto fail; - - -printf ("Test stats for MP burst enqueue to a full ring.\n" ); - num_items =8 ; - ret =rte_ring_mp_enqueue_burst (r, cur_src, num_items); -if ((ret &RTE_RING_SZ_MASK ) !=0 ) - goto fail; - - failed_enqueue_ops +=1 ; - failed_enqueue_items += num_items; - -/* The enqueue should have failed. */ -if (ring_stats->enq_fail_bulk != failed_enqueue_ops) - goto fail; -if (ring_stats->enq_fail_objs != failed_enqueue_items) - goto fail; - - -printf ("Test stats for MP bulk enqueue to a full ring.\n" ); - num_items =16 ; - ret =rte_ring_mp_enqueue_bulk (r, cur_src, num_items); -if (ret != -ENOBUFS ) - goto fail; - - failed_enqueue_ops +=1 ; - failed_enqueue_items += num_items; - -/* The enqueue should have failed. */ -if (ring_stats->enq_fail_bulk != failed_enqueue_ops) - goto fail; -if (ring_stats->enq_fail_objs != failed_enqueue_items) - goto fail; - - -/* Do Dequeue tests. */ -printf ("Test the dequeue stats.\n" ); - -printf ("Empty the ring.\n" ); -for (i =0 ; i<RING_SIZE /MAX_BULK ; i++) { -rte_ring_sc_dequeue_burst (r, cur_dst,MAX_BULK ); - cur_dst +=MAX_BULK ; - } - -/* There was only RING_SIZE -1 objects to dequeue. */ - cur_dst++; - -printf ("Verify ring is empty.\n" ); -if (1 !=rte_ring_empty (r)) - goto fail; - -printf ("Verify the dequeue success stats.\n" ); -/* Stats should match above dequeue operations. */ -if (ring_stats->deq_success_bulk != (RING_SIZE /MAX_BULK )) - goto fail; - -/* Objects dequeued is RING_SIZE -1. */ -if (ring_stats->deq_success_objs !=RING_SIZE -1 ) - goto fail; - -/* Shouldn't have any dequeue failure stats yet. */ -if (ring_stats->deq_fail_bulk !=0 ) - goto fail; - -printf ("Test stats for SC burst dequeue with an empty ring.\n" ); - num_items =2 ; - ret =rte_ring_sc_dequeue_burst (r, cur_dst, num_items); -if ((ret &RTE_RING_SZ_MASK ) !=0 ) - goto fail; - - failed_dequeue_ops +=1 ; - failed_dequeue_items += num_items; - -/* The dequeue should have failed. */ -if (ring_stats->deq_fail_bulk != failed_dequeue_ops) - goto fail; -if (ring_stats->deq_fail_objs != failed_dequeue_items) - goto fail; - - -printf ("Test stats for SC bulk dequeue with an empty ring.\n" ); - num_items =4 ; - ret =rte_ring_sc_dequeue_bulk (r, cur_dst, num_items); -if (ret != -ENOENT ) - goto fail; - - failed_dequeue_ops +=1 ; - failed_dequeue_items += num_items; - -/* The dequeue should have failed. */ -if (ring_stats->deq_fail_bulk != failed_dequeue_ops) - goto fail; -if (ring_stats->deq_fail_objs != failed_dequeue_items) - goto fail; - - -printf ("Test stats for MC burst dequeue with an empty ring.\n" ); - num_items =8 ; - ret =rte_ring_mc_dequeue_burst (r, cur_dst, num_items); -if ((ret &RTE_RING_SZ_MASK ) !=0 ) - goto fail; - failed_dequeue_ops +=1 ; - failed_dequeue_items += num_items; - -/* The dequeue should have failed. */ -if (ring_stats->deq_fail_bulk != failed_dequeue_ops) - goto fail; -if (ring_stats->deq_fail_objs != failed_dequeue_items) - goto fail; - - -printf ("Test stats for MC bulk dequeue with an empty ring.\n" ); - num_items =16 ; - ret =rte_ring_mc_dequeue_bulk (r, cur_dst, num_items); -if (ret != -ENOENT ) - goto fail; - - failed_dequeue_ops +=1 ; - failed_dequeue_items += num_items; - -/* The dequeue should have failed. */ -if (ring_stats->deq_fail_bulk != failed_dequeue_ops) - goto fail; -if (ring_stats->deq_fail_objs != failed_dequeue_items) - goto fail; - - -printf ("Test total enqueue/dequeue stats.\n" ); -/* At this point the enqueue and dequeue stats should be the same. */ -if (ring_stats->enq_success_bulk != ring_stats->deq_success_bulk) - goto fail; -if (ring_stats->enq_success_objs != ring_stats->deq_success_objs) - goto fail; -if (ring_stats->enq_fail_bulk != ring_stats->deq_fail_bulk) - goto fail; -if (ring_stats->enq_fail_objs != ring_stats->deq_fail_objs) - goto fail; - - -/* Watermark Tests. */ -printf ("Test the watermark/quota stats.\n" ); - -printf ("Verify the initial watermark stats.\n" ); -/* Watermark stats should be 0 since there is no watermark. */ -if (ring_stats->enq_quota_bulk !=0 ) - goto fail; -if (ring_stats->enq_quota_objs !=0 ) - goto fail; - -/* Set a watermark. */ -rte_ring_set_water_mark (r,16 ); - -/* Reset pointers. */ - cur_src = src; - cur_dst = dst; - - last_enqueue_ops = ring_stats->enq_success_bulk; - last_enqueue_items = ring_stats->enq_success_objs; - - -printf ("Test stats for SP burst enqueue below watermark.\n" ); - num_items =8 ; - ret =rte_ring_sp_enqueue_burst (r, cur_src, num_items); -if ((ret &RTE_RING_SZ_MASK ) != num_items) - goto fail; - -/* Watermark stats should still be 0. */ -if (ring_stats->enq_quota_bulk !=0 ) - goto fail; -if (ring_stats->enq_quota_objs !=0 ) - goto fail; - -/* Success stats should have increased. */ -if (ring_stats->enq_success_bulk != last_enqueue_ops +1 ) - goto fail; -if (ring_stats->enq_success_objs != last_enqueue_items + num_items) - goto fail; - - last_enqueue_ops = ring_stats->enq_success_bulk; - last_enqueue_items = ring_stats->enq_success_objs; - - -printf ("Test stats for SP burst enqueue at watermark.\n" ); - num_items =8 ; - ret =rte_ring_sp_enqueue_burst (r, cur_src, num_items); -if ((ret &RTE_RING_SZ_MASK ) != num_items) - goto fail; - -/* Watermark stats should have changed. */ -if (ring_stats->enq_quota_bulk !=1 ) - goto fail; -if (ring_stats->enq_quota_objs != num_items) - goto fail; - - last_quota_ops = ring_stats->enq_quota_bulk; - last_quota_items = ring_stats->enq_quota_objs; - - -printf ("Test stats for SP burst enqueue above watermark.\n" ); - num_items =1 ; - ret =rte_ring_sp_enqueue_burst (r, cur_src, num_items); -if ((ret &RTE_RING_SZ_MASK ) != num_items) - goto fail; - -/* Watermark stats should have changed. */ -if (ring_stats->enq_quota_bulk != last_quota_ops +1 ) - goto fail; -if (ring_stats->enq_quota_objs != last_quota_items + num_items) - goto fail; - - last_quota_ops = ring_stats->enq_quota_bulk; - last_quota_items = ring_stats->enq_quota_objs; - - -printf ("Test stats for MP burst enqueue above watermark.\n" ); - num_items =2 ; - ret =rte_ring_mp_enqueue_burst (r, cur_src, num_items); -if ((ret &RTE_RING_SZ_MASK ) != num_items) - goto fail; - -/* Watermark stats should have changed. */ -if (ring_stats->enq_quota_bulk != last_quota_ops +1 ) - goto fail; -if (ring_stats->enq_quota_objs != last_quota_items + num_items) - goto fail; - - last_quota_ops = ring_stats->enq_quota_bulk; - last_quota_items = ring_stats->enq_quota_objs; - - -printf ("Test stats for SP bulk enqueue above watermark.\n" ); - num_items =4 ; - ret =rte_ring_sp_enqueue_bulk (r, cur_src, num_items); -if (ret != -EDQUOT ) - goto fail; - -/* Watermark stats should have changed. */ -if (ring_stats->enq_quota_bulk != last_quota_ops +1 ) - goto fail; -if (ring_stats->enq_quota_objs != last_quota_items + num_items) - goto fail; - - last_quota_ops = ring_stats->enq_quota_bulk; - last_quota_items = ring_stats->enq_quota_objs; - - -printf ("Test stats for MP bulk enqueue above watermark.\n" ); - num_items =8 ; - ret =rte_ring_mp_enqueue_bulk (r, cur_src, num_items); -if (ret != -EDQUOT ) - goto fail; - -/* Watermark stats should have changed. */ -if (ring_stats->enq_quota_bulk != last_quota_ops +1 ) - goto fail; -if (ring_stats->enq_quota_objs != last_quota_items + num_items) - goto fail; - -printf ("Test watermark success stats.\n" ); -/* Success stats should be same as last non-watermarked enqueue. */ -if (ring_stats->enq_success_bulk != last_enqueue_ops) - goto fail; -if (ring_stats->enq_success_objs != last_enqueue_items) - goto fail; - - -/* Cleanup. */ - -/* Empty the ring. */ -for (i =0 ; i<RING_SIZE /MAX_BULK ; i++) { -rte_ring_sc_dequeue_burst (r, cur_dst,MAX_BULK ); - cur_dst +=MAX_BULK ; - } - -/* Reset the watermark. */ -rte_ring_set_water_mark (r,0 ); - -/* Reset the ring stats. */ -memset (&r->stats[lcore_id],0 ,sizeof (r->stats[lcore_id])); - -/* Free memory before test completed */ -free (src); -free (dst); -return 0 ; - -fail: -free (src); -free (dst); -return -1 ; -#endif -} -/* * it will always fail to create ring with a wrong ring size number in this function */
@@ -1335,10 +929,6 @@ test_ring(void)if (test_ring_basic () <0 )return -1 ; -/* ring stats */ -if (test_ring_stats () <0 ) -return -1 ; -/* basic operations */ if (test_live_watermark_change () <0 )return -1 ;
config/common_base +0 -1
@@ -447,7 +447,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # Compile librte_ring # CONFIG_RTE_LIBRTE_RING=y -CONFIG_RTE_LIBRTE_RING_DEBUG=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #
doc/guides/prog_guide/ring_lib.rst +0 -7
@@ -110,13 +110,6 @@ Once an enqueue operation reaches the high water mark, the producer is notified, This mechanism can be used, for example, to exert a back pressure on I/O to inform the LAN to PAUSE. -Debug -~~~~~ - -When debug is enabled (CONFIG_RTE_LIBRTE_RING_DEBUG is set), -the library stores some per-ring statistic counters about the number of enqueues/dequeues. -These statistics are per-core to avoid concurrent accesses or atomic operations. - Use Cases ---------
doc/guides/rel_notes/release_17_05.rst +1 -0
@@ -116,6 +116,7 @@ API Changes have been made to it: * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` + * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` ABI Changes -----------
lib/librte_ring/rte_ring.c +0 -41
59 lines not on this page · raw message
lib/librte_ring/rte_ring.h +12 -85
183 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 5/14 ring: remove the yield when waiting for tail update
In reply to Bruce RichardsonThere was a compile time setting to enable a ring to yield when it entered a loop in mp or mc rings waiting for the tail pointer update. Build time settings are not recommended for enabling/disabling features, and since this was off by default, remove it completely. If needed, a runtime enabled equivalent can be used.
--- config/common_base | 1 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 ---- doc/guides/rel_notes/release_17_05.rst | 1 + lib/librte_ring/rte_ring.h | 35 +++++-------------------- 4 files changed, 7 insertions(+), 35 deletions(-)
config/common_base +0 -1
@@ -447,7 +447,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # Compile librte_ring # CONFIG_RTE_LIBRTE_RING=y -CONFIG_RTE_RING_PAUSE_REP_COUNT=0 # # Compile librte_mempool
doc/guides/prog_guide/env_abstraction_layer.rst +0 -5
@@ -352,11 +352,6 @@ Known Issues 3. It MUST not be used by multi-producer/consumer pthreads, whose scheduling policies are SCHED_FIFO or SCHED_RR. - ``RTE_RING_PAUSE_REP_COUNT`` is defined for rte_ring to reduce contention. It's mainly for case 2, a yield is issued after number of times pause repeat. - - It adds a sched_yield() syscall if the thread spins for too long while waiting on the other thread to finish its operations on the ring. - This gives the preempted thread a chance to proceed and finish with the ring enqueue/dequeue operation. - + rte_timer Running ``rte_timer_manager()`` on a non-EAL pthread is not allowed. However, resetting/stopping the timer from a non-EAL pthread is allowed.
doc/guides/rel_notes/release_17_05.rst +1 -0
@@ -117,6 +117,7 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` + * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` ABI Changes -----------
lib/librte_ring/rte_ring.h +6 -29
@@ -114,11 +114,6 @@ enum rte_ring_queue_behavior {#define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \ sizeof(RTE_RING_MZ_PREFIX) + 1) -#ifndef RTE_RING_PAUSE_REP_COUNT -#define RTE_RING_PAUSE_REP_COUNT 0/**< Yield after pause num of times, no yield -* if RTE_RING_PAUSE_REP not defined. */ -#endif -struct rte_memzone ;/* forward declaration, so as not to require memzone.h */ /* structure to hold a pair of head/tail values and other metadata */
@@ -388,7 +383,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t cons_tail, free_entries;const unsigned max = n;int success; -unsigned i, rep =0 ; +unsigned int i;uint32_t mask = r->mask;int ret;
@@ -442,18 +437,9 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,* If there are other enqueues in progress that preceded us, * we need to wait for them to complete */ -while (unlikely (r->prod.tail != prod_head)) { +while (unlikely (r->prod.tail != prod_head))rte_pause (); -/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting -* for other thread finish. It gives pre-empted thread a chance -* to proceed and finish with ring dequeue operation. */ -if (RTE_RING_PAUSE_REP_COUNT && - ++rep ==RTE_RING_PAUSE_REP_COUNT ) { - rep =0 ; -sched_yield (); - } - } r->prod.tail = prod_next;return ret; }
@@ -486,7 +472,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, {uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries; -unsigned i; +unsigned int i;uint32_t mask = r->mask;int ret;
@@ -563,7 +549,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_next, entries;const unsigned max = n;int success; -unsigned i, rep =0 ; +unsigned int i;uint32_t mask = r->mask;/* Avoid the unnecessary cmpset operation below, which is also
@@ -608,18 +594,9 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,* If there are other dequeues in progress that preceded us, * we need to wait for them to complete */ -while (unlikely (r->cons.tail != cons_head)) { +while (unlikely (r->cons.tail != cons_head))rte_pause (); -/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting -* for other thread finish. It gives pre-empted thread a chance -* to proceed and finish with ring dequeue operation. */ -if (RTE_RING_PAUSE_REP_COUNT && - ++rep ==RTE_RING_PAUSE_REP_COUNT ) { - rep =0 ; -sched_yield (); - } - } r->cons.tail = cons_next;return behavior ==RTE_RING_QUEUE_FIXED ?0 : n;
@@ -654,7 +631,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, {uint32_t cons_head, prod_tail;uint32_t cons_next, entries; -unsigned i; +unsigned int i;uint32_t mask = r->mask; cons_head = r->cons.head;
Signature · 1 line
2.9.3
PATCH 6/14 ring: remove watermark support
In reply to Bruce RichardsonRemove the watermark support. A future commit will add support for having enqueue functions return the amount of free space in the ring, which will allow applications to implement their own watermark checks, while also being more useful to the app.
--- app/test/commands.c | 52 ------------ app/test/test_ring.c | 149 +-------------------------------- doc/guides/rel_notes/release_17_05.rst | 2 + examples/Makefile | 2 +- lib/librte_ring/rte_ring.c | 23 ----- lib/librte_ring/rte_ring.h | 58 +------------ 6 files changed, 8 insertions(+), 278 deletions(-)
app/test/commands.c +0 -52
@@ -228,57 +228,6 @@ cmdline_parse_inst_t cmd_dump_one = {/****************/ -struct cmd_set_ring_result { -cmdline_fixed_string_t set; -cmdline_fixed_string_t name; -uint32_t value; -}; - -static void cmd_set_ring_parsed (void *parsed_result,struct cmdline *cl, - __attribute__((unused))void *data) -{ -struct cmd_set_ring_result *res = parsed_result; -struct rte_ring *r; -int ret; - - r =rte_ring_lookup (res->name); -if (r ==NULL ) { -cmdline_printf (cl,"Cannot find ring\n" ); -return ; - } - -if (!strcmp (res->set,"set_watermark" )) { - ret =rte_ring_set_water_mark (r, res->value); -if (ret !=0 ) -cmdline_printf (cl,"Cannot set water mark\n" ); - } -} - -cmdline_parse_token_string_t cmd_set_ring_set = - TOKEN_STRING_INITIALIZER(struct cmd_set_ring_result, set, -"set_watermark" ); - -cmdline_parse_token_string_t cmd_set_ring_name = - TOKEN_STRING_INITIALIZER(struct cmd_set_ring_result, name, NULL); - -cmdline_parse_token_num_t cmd_set_ring_value = - TOKEN_NUM_INITIALIZER(struct cmd_set_ring_result, value, UINT32); - -cmdline_parse_inst_t cmd_set_ring = { - .f = cmd_set_ring_parsed,/* function to call */ - .data =NULL ,/* 2nd arg of func */ - .help_str ="set watermark: " -"set_watermark <ring_name> <value>" , - .tokens = {/* token list, NULL terminated */ - (void *)&cmd_set_ring_set, - (void *)&cmd_set_ring_name, - (void *)&cmd_set_ring_value, -NULL , - }, -}; - -/****************/ -struct cmd_quit_result {cmdline_fixed_string_t quit; };
@@ -419,7 +368,6 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_autotest, (cmdline_parse_inst_t *)&cmd_dump, (cmdline_parse_inst_t *)&cmd_dump_one, - (cmdline_parse_inst_t *)&cmd_set_ring, (cmdline_parse_inst_t *)&cmd_quit, (cmdline_parse_inst_t *)&cmd_set_rxtx, (cmdline_parse_inst_t *)&cmd_set_rxtx_anchor,
app/test/test_ring.c +3 -146
179 lines not on this page · raw message
doc/guides/rel_notes/release_17_05.rst +2 -0
@@ -118,6 +118,8 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` + * removed the function ``rte_ring_set_water_mark`` as part of a general + removal of watermarks support in the library. ABI Changes -----------
examples/Makefile +1 -1
@@ -81,7 +81,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering DIRS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ptpclient DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched -DIRS-y += quota_watermark +#DIRS-y += quota_watermark DIRS-$(CONFIG_RTE_ETHDEV_RXTX_CALLBACKS) += rxtx_callbacks DIRS-y += skeleton ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
lib/librte_ring/rte_ring.c +0 -23
@@ -138,7 +138,6 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->watermark = count; r->prod.sp_enqueue = !!(flags &RING_F_SP_ENQ ); r->cons.sc_dequeue = !!(flags &RING_F_SC_DEQ ); r->size = count;
@@ -256,24 +255,6 @@ rte_ring_free(struct rte_ring *r)rte_free (te); } -/* -* change the high water mark. If *count* is 0, water marking is -* disabled -*/ -int -rte_ring_set_water_mark (struct rte_ring *r,unsigned count) -{ -if (count >= r->size) -return -EINVAL ; - -/* if count is 0, disable the watermarking */ -if (count ==0 ) - count = r->size; - - r->watermark = count; -return 0 ; -} -/* dump the status of the ring on the console */ void rte_ring_dump (FILE *f,const struct rte_ring *r)
@@ -287,10 +268,6 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)fprintf (f," ph=%" PRIu32"\n" , r->prod.head);fprintf (f," used=%u\n" ,rte_ring_count (r));fprintf (f," avail=%u\n" ,rte_ring_free_count (r)); -if (r->watermark == r->size) -fprintf (f," watermark=0\n" ); -else -fprintf (f," watermark=%" PRIu32"\n" , r->watermark); }/* dump the status of all rings on the console */
lib/librte_ring/rte_ring.h +2 -56
155 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 7/14 ring: make bulk and burst fn return vals consistent
In reply to Bruce RichardsonThe bulk fns for rings returns 0 for all elements enqueued and negative for no space. Change that to make them consistent with the burst functions in returning the number of elements enqueued/dequeued, i.e. 0 or N. This change also allows the return value from enq/deq to be used directly without a branch for error checking.
--- app/test-pipeline/pipeline_hash.c | 2 +- app/test-pipeline/runtime.c | 8 +- app/test/test_ring.c | 46 +++++---- app/test/test_ring_perf.c | 8 +- doc/guides/rel_notes/release_17_05.rst | 11 +++ doc/guides/sample_app_ug/server_node_efd.rst | 2 +- examples/load_balancer/runtime.c | 16 ++- .../client_server_mp/mp_client/client.c | 8 +- .../client_server_mp/mp_server/main.c | 2 +- examples/qos_sched/app_thread.c | 8 +- examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 12 ++- lib/librte_ring/rte_ring.h | 109 +++++++-------------- 14 files changed, 106 insertions(+), 130 deletions(-)
app/test-pipeline/pipeline_hash.c +1 -1
@@ -547,6 +547,6 @@ app_main_loop_rx_metadata(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }
app/test-pipeline/runtime.c +4 -4
@@ -98,7 +98,7 @@ app_main_loop_rx(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }
@@ -123,7 +123,7 @@ app_main_loop_worker(void) { (void **) worker_mbuf->array, app.burst_size_worker_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; do {
@@ -131,7 +131,7 @@ app_main_loop_worker(void) { app.rings_tx[i ^1 ], (void **) worker_mbuf->array, app.burst_size_worker_write); - }while (ret <0 ); + }while (ret ==0 ); } }
@@ -152,7 +152,7 @@ app_main_loop_tx(void) { (void **) &app.mbuf_tx[i].array[n_mbufs], app.burst_size_tx_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; n_mbufs += app.burst_size_tx_read;
app/test/test_ring.c +22 -24
152 lines not on this page · raw message
app/test/test_ring_perf.c +4 -4
@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();
@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc ();
doc/guides/rel_notes/release_17_05.rst +11 -0
@@ -120,6 +120,17 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` * removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library. + * changed the return value of the enqueue and dequeue bulk functions to + match that of the burst equivalents. In all cases, ring functions which + operate on multiple packets now return the number of elements enqueued + or dequeued, as appropriate. The updated functions are: + + - ``rte_ring_mp_enqueue_bulk`` + - ``rte_ring_sp_enqueue_bulk`` + - ``rte_ring_enqueue_bulk`` + - ``rte_ring_mc_dequeue_bulk`` + - ``rte_ring_sc_dequeue_bulk`` + - ``rte_ring_dequeue_bulk`` ABI Changes -----------
doc/guides/sample_app_ug/server_node_efd.rst +1 -1
@@ -286,7 +286,7 @@ repeated infinitely. cl = &nodes[node]; if (rte_ring_enqueue_bulk(cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != 0){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){ for (j = 0; j < cl_rx_buf[node].count; j++) rte_pktmbuf_free(cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
examples/load_balancer/runtime.c +7 -9
@@ -146,7 +146,7 @@ app_lcore_io_rx_buffer_to_send ( (void **) lp->rx.mbuf_out[worker].array, bsz); -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz; k ++) {struct rte_mbuf *m = lp->rx.mbuf_out[worker].array[k];
@@ -312,7 +312,7 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) (void **) lp->rx.mbuf_out[worker].array, lp->rx.mbuf_out[worker].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->rx.mbuf_out[worker].n_mbufs; k ++) {struct rte_mbuf *pkt_to_free = lp->rx.mbuf_out[worker].array[k];
@@ -349,9 +349,8 @@ app_lcore_io_tx( (void **) &lp->tx.mbuf_out[port].array[n_mbufs], bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - } n_mbufs += bsz_rd;
@@ -505,9 +504,8 @@ app_lcore_worker( (void **) lp->mbuf_in.array, bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - }#if APP_WORKER_DROP_ALL_PACKETS for (j =0 ; j < bsz_rd; j ++) {
@@ -559,7 +557,7 @@ app_lcore_worker(#if APP_STATS lp->rings_out_iters[port] ++; -if (ret ==0 ) { +if (ret >0 ) { lp->rings_out_count[port] +=1 ; }if (lp->rings_out_iters[port] ==APP_STATS ){
@@ -572,7 +570,7 @@ app_lcore_worker( }#endif -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz_wr; k ++) {struct rte_mbuf *pkt_to_free = lp->mbuf_out[port].array[k];
@@ -609,7 +607,7 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) (void **) lp->mbuf_out[port].array, lp->mbuf_out[port].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->mbuf_out[port].n_mbufs; k ++) {struct rte_mbuf *pkt_to_free = lp->mbuf_out[port].array[k];
examples/multi_process/client_server_mp/mp_client/client.c +2 -6
@@ -276,14 +276,10 @@ main(int argc, char *argv[])printf ("[Press Ctrl-C to quit ...]\n" );for (;;) { -uint16_t i, rx_pkts =PKT_READ_SIZE ; +uint16_t i, rx_pkts;uint8_t port; -/* try dequeuing max possible packets first, if that fails, get the -* most we can. Loop body should only execute once, maximum */ -while (rx_pkts >0 && -unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, rx_pkts) !=0 )) - rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE ); + rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts,PKT_READ_SIZE );if (unlikely (rx_pkts ==0 )){if (need_flush)
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) !=0 ){ + cl_rx_buf[client].count) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]); cl->stats.rx_drop += cl_rx_buf[client].count;
examples/qos_sched/app_thread.c +5 -3
@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) !=0 )) { + (void **)rx_mbufs, nb_rx) ==0 )) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);
@@ -180,7 +180,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, burst_conf.qos_dequeue); -if (likely (retval ==0 )) { +if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue); conf->counter =0 ;/* reset empty read loop counter */
@@ -230,7 +230,9 @@ app_worker_thread(struct thread_conf **confs) nb_pkt =rte_sched_port_dequeue (conf->sched_port, mbufs, burst_conf.qos_dequeue);if (likely (nb_pkt >0 )) -while (rte_ring_sp_enqueue_bulk (conf->tx_ring, (void **)mbufs, nb_pkt) !=0 ); +while (rte_ring_sp_enqueue_bulk (conf->tx_ring, + (void **)mbufs, nb_pkt) ==0 ) + ;/* empty body */ conf_idx++;if (confs[conf_idx] ==NULL )
examples/server_node_efd/node/node.c +1 -1
@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) !=0 )) + rx_pkts) ==0 )) rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE );
examples/server_node_efd/server/main.c +1 -1
@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) !=0 ){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
lib/librte_mempool/rte_mempool_ring.c +8 -4
@@ -42,26 +42,30 @@ static int common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { - return rte_ring_mp_enqueue_bulk(mp->pool_data, obj_table, n); + return rte_ring_mp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { -return rte_ring_sp_enqueue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_mc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_mc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_sc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static unsigned
lib/librte_ring/rte_ring.h +38 -71
264 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 8/14 ring: allow enqueue fns to return free space value
In reply to Bruce RichardsonAdd an extra parameter to the ring enqueue burst/bulk functions so that those functions can optionally return the amount of free space in the ring. This information can be used by applications in a number of ways, for instance, with single-producer queues, it provides a max enqueue size which is guaranteed to work. It can also be used to implement watermark functionality in apps, replacing the older functionality with a more flexible version, which enables apps to implement multiple watermark thresholds, rather than just one.
--- app/test-pipeline/pipeline_hash.c | 3 +- app/test-pipeline/runtime.c | 5 +- app/test/test_link_bonding_mode4.c | 3 +- app/test/test_pmd_ring_perf.c | 5 +- app/test/test_ring.c | 55 ++++++------- app/test/test_ring_perf.c | 16 ++-- app/test/test_table_ports.c | 4 +- app/test/virtual_pmd.c | 4 +- doc/guides/rel_notes/release_17_05.rst | 3 + drivers/net/ring/rte_eth_ring.c | 2 +- examples/distributor/main.c | 3 +- examples/load_balancer/runtime.c | 12 ++- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 7 +- examples/qos_sched/app_thread.c | 4 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 4 +- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 28 ++++--- lib/librte_ring/rte_ring.h | 89 +++++++++++----------- 22 files changed, 139 insertions(+), 118 deletions(-)
app/test-pipeline/pipeline_hash.c +2 -1
@@ -546,7 +546,8 @@ app_main_loop_rx_metadata(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_rx[i], (void **) app.mbuf_rx.array, - n_mbufs); + n_mbufs, +NULL ); }while (ret ==0 ); } }
app/test-pipeline/runtime.c +3 -2
@@ -97,7 +97,7 @@ app_main_loop_rx(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_rx[i], (void **) app.mbuf_rx.array, - n_mbufs); + n_mbufs,NULL ); }while (ret ==0 ); } }
@@ -130,7 +130,8 @@ app_main_loop_worker(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_tx[i ^1 ], (void **) worker_mbuf->array, - app.burst_size_worker_write); + app.burst_size_worker_write, +NULL ); }while (ret ==0 ); } }
app/test/test_link_bonding_mode4.c +2 -1
@@ -206,7 +206,8 @@ slave_get_pkts(struct slave_conf *slave, struct rte_mbuf **buf, uint16_t size)static int slave_put_pkts (struct slave_conf *slave,struct rte_mbuf **buf,uint16_t size) { -return rte_ring_enqueue_burst (slave->rx_queue, (void **)buf, size); +return rte_ring_enqueue_burst (slave->rx_queue, (void **)buf, + size,NULL ); } static uint16_t
app/test/test_pmd_ring_perf.c +3 -2
@@ -98,7 +98,7 @@ test_single_enqueue_dequeue(void)const uint64_t sc_start =rte_rdtsc_precise ();rte_compiler_barrier ();for (i =0 ; i < iterations; i++) { -rte_ring_enqueue_bulk (r, &burst,1 ); +rte_ring_enqueue_bulk (r, &burst,1 ,NULL );rte_ring_dequeue_bulk (r, &burst,1 ); }const uint64_t sc_end =rte_rdtsc_precise ();
@@ -131,7 +131,8 @@ test_bulk_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_bulk (r, (void *)burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_bulk (r, (void *)burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_bulk (r, (void *)burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();
app/test/test_ring.c +28 -27
203 lines not on this page · raw message
app/test/test_ring_perf.c +10 -6
@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();
@@ -323,14 +323,16 @@ test_burst_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_burst (r, burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_burst (r, burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_burst (r, burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_mp_enqueue_burst (r, burst, bulk_sizes[sz]); +rte_ring_mp_enqueue_burst (r, burst, + bulk_sizes[sz],NULL );rte_ring_mc_dequeue_burst (r, burst, bulk_sizes[sz]); }const uint64_t mc_end =rte_rdtsc ();
@@ -357,14 +359,16 @@ test_bulk_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_bulk (r, burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_mp_enqueue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_mp_enqueue_bulk (r, burst, + bulk_sizes[sz],NULL );rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[sz]); }const uint64_t mc_end =rte_rdtsc ();
app/test/test_table_ports.c +2 -2
@@ -80,7 +80,7 @@ test_port_ring_reader(void) mbuf[0 ] = (void *)rte_pktmbuf_alloc (pool); expected_pkts =rte_ring_sp_enqueue_burst (port_ring_reader_params.ring, - mbuf,1 ); + mbuf,1 ,NULL ); received_pkts = rte_port_ring_reader_ops.f_rx (port, res_mbuf,1 );if (received_pkts < expected_pkts)
@@ -93,7 +93,7 @@ test_port_ring_reader(void) mbuf[i] =rte_pktmbuf_alloc (pool); expected_pkts =rte_ring_sp_enqueue_burst (port_ring_reader_params.ring, - (void *const *) mbuf,RTE_PORT_IN_BURST_SIZE_MAX ); + (void *const *) mbuf,RTE_PORT_IN_BURST_SIZE_MAX ,NULL ); received_pkts = rte_port_ring_reader_ops.f_rx (port, res_mbuf,RTE_PORT_IN_BURST_SIZE_MAX );
app/test/virtual_pmd.c +2 -2
@@ -380,7 +380,7 @@ virtual_ethdev_tx_burst_success(void *queue, struct rte_mbuf **bufs, nb_pkts =0 ; else nb_pkts =rte_ring_enqueue_burst (dev_private->tx_queue, (void **)bufs, - nb_pkts); + nb_pkts,NULL );/* increment opacket count */ dev_private->eth_stats.opackets += nb_pkts;
@@ -496,7 +496,7 @@ virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, vrtl_eth_dev->data->dev_private;return rte_ring_enqueue_burst (dev_private->rx_queue, (void **)pkt_burst, - burst_length); + burst_length,NULL ); }int
doc/guides/rel_notes/release_17_05.rst +3 -0
@@ -120,6 +120,9 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` * removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library. + * added an extra parameter to the burst/bulk enqueue functions to + return the number of free spaces in the ring after enqueue. This can + be used by an application to implement its own watermark functionality. * changed the return value of the enqueue and dequeue bulk functions to match that of the burst equivalents. In all cases, ring functions which operate on multiple packets now return the number of elements enqueued
drivers/net/ring/rte_eth_ring.c +1 -1
@@ -102,7 +102,7 @@ eth_ring_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)void **ptrs = (void *)&bufs[0 ];struct ring_queue *r = q;const uint16_t nb_tx = (uint16_t )rte_ring_enqueue_burst (r->rng, - ptrs, nb_bufs); + ptrs, nb_bufs,NULL );if (r->rng->flags &RING_F_SP_ENQ ) { r->tx_pkts.cnt += nb_tx; r->err_pkts.cnt += nb_bufs - nb_tx;
examples/distributor/main.c +2 -1
@@ -238,7 +238,8 @@ lcore_rx(struct lcore_params *p)continue ; } -uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, nb_ret); +uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, + nb_ret,NULL ); app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { RTE_LOG_DP(DEBUG, DISTRAPP,
examples/load_balancer/runtime.c +8 -4
@@ -144,7 +144,8 @@ app_lcore_io_rx_buffer_to_send ( ret =rte_ring_sp_enqueue_bulk ( lp->rx.rings[worker], (void **) lp->rx.mbuf_out[worker].array, - bsz); + bsz, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
@@ -310,7 +311,8 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) ret =rte_ring_sp_enqueue_bulk ( lp->rx.rings[worker], (void **) lp->rx.mbuf_out[worker].array, - lp->rx.mbuf_out[worker].n_mbufs); + lp->rx.mbuf_out[worker].n_mbufs, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
@@ -553,7 +555,8 @@ app_lcore_worker( ret =rte_ring_sp_enqueue_bulk ( lp->rings_out[port], (void **) lp->mbuf_out[port].array, - bsz_wr); + bsz_wr, +NULL );#if APP_STATS lp->rings_out_iters[port] ++;
@@ -605,7 +608,8 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) ret =rte_ring_sp_enqueue_bulk ( lp->rings_out[port], (void **) lp->mbuf_out[port].array, - lp->mbuf_out[port].n_mbufs); + lp->mbuf_out[port].n_mbufs, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) ==0 ){ + cl_rx_buf[client].count,NULL ) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]); cl->stats.rx_drop += cl_rx_buf[client].count;
examples/packet_ordering/main.c +4 -3
@@ -421,8 +421,8 @@ rx_thread(struct rte_ring *ring_out) pkts[i++]->seqn = seqn++;/* enqueue to rx_to_workers ring */ - ret =rte_ring_enqueue_burst (ring_out, (void *) pkts, - nb_rx_pkts); + ret =rte_ring_enqueue_burst (ring_out, + (void *)pkts, nb_rx_pkts,NULL ); app_stats.rx.enqueue_pkts += ret;if (unlikely (ret < nb_rx_pkts)) { app_stats.rx.enqueue_failed_pkts +=
@@ -473,7 +473,8 @@ worker_thread(void *args_ptr) burst_buffer[i++]->port ^= xor_val;/* enqueue the modified mbufs to workers_to_tx ring */ - ret =rte_ring_enqueue_burst (ring_out, (void *)burst_buffer, burst_size); + ret =rte_ring_enqueue_burst (ring_out, (void *)burst_buffer, + burst_size,NULL );__sync_fetch_and_add (&app_stats.wkr.enqueue_pkts, ret);if (unlikely (ret < burst_size)) {/* Return the mbufs to their respective pool, dropping packets */
examples/qos_sched/app_thread.c +2 -2
@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) ==0 )) { + (void **)rx_mbufs, nb_rx,NULL ) ==0 )) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);
@@ -231,7 +231,7 @@ app_worker_thread(struct thread_conf **confs) burst_conf.qos_dequeue);if (likely (nb_pkt >0 ))while (rte_ring_sp_enqueue_bulk (conf->tx_ring, - (void **)mbufs, nb_pkt) ==0 ) + (void **)mbufs, nb_pkt,NULL ) ==0 ) ;/* empty body */ conf_idx++;
examples/server_node_efd/server/main.c +1 -1
@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != cl_rx_buf[node].count){ + cl_rx_buf[node].count,NULL ) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
lib/librte_hash/rte_cuckoo_hash.c +1 -1
@@ -808,7 +808,7 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, unsigned i)/* Need to enqueue the free slots in global ring. */ n_slots =rte_ring_mp_enqueue_burst (h->free_slots, cached_free_slots->objs, -LCORE_CACHE_SIZE ); +LCORE_CACHE_SIZE ,NULL ); cached_free_slots->len -= n_slots; }/* Put index of new free slot in cache. */
lib/librte_mempool/rte_mempool_ring.c +2 -2
@@ -43,7 +43,7 @@ common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) {return rte_ring_mp_enqueue_bulk (mp->pool_data, - obj_table, n) ==0 ? -ENOBUFS :0 ; + obj_table, n,NULL ) ==0 ? -ENOBUFS :0 ; } static int
@@ -51,7 +51,7 @@ common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) {return rte_ring_sp_enqueue_bulk (mp->pool_data, - obj_table, n) ==0 ? -ENOBUFS :0 ; + obj_table, n,NULL ) ==0 ? -ENOBUFS :0 ; } static int
lib/librte_pdump/rte_pdump.c +1 -1
@@ -197,7 +197,7 @@ pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) dup_bufs[d_pkts++] = p; } - ring_enq =rte_ring_enqueue_burst (ring, (void *)dup_bufs, d_pkts); + ring_enq =rte_ring_enqueue_burst (ring, (void *)dup_bufs, d_pkts,NULL );if (unlikely (ring_enq < d_pkts)) {RTE_LOG (DEBUG ,PDUMP ,"only %d of packets enqueued to ring\n" , ring_enq);
lib/librte_port/rte_port_ras.c +1 -1
@@ -167,7 +167,7 @@ send_burst(struct rte_port_ring_writer_ras *p)uint32_t nb_tx; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
lib/librte_port/rte_port_ring.c +16 -12
@@ -241,7 +241,7 @@ send_burst(struct rte_port_ring_writer *p)uint32_t nb_tx; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
@@ -256,7 +256,7 @@ send_burst_mp(struct rte_port_ring_writer *p)uint32_t nb_tx; nb_tx =rte_ring_mp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
@@ -318,11 +318,11 @@ rte_port_ring_writer_tx_bulk_internal(void *port,RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD (p, n_pkts);if (is_multi) - n_pkts_ok =rte_ring_mp_enqueue_burst (p->ring, (void **)pkts, - n_pkts); + n_pkts_ok =rte_ring_mp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );else - n_pkts_ok =rte_ring_sp_enqueue_burst (p->ring, (void **)pkts, - n_pkts); + n_pkts_ok =rte_ring_sp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, n_pkts - n_pkts_ok);for ( ; n_pkts_ok < n_pkts; n_pkts_ok++) {
@@ -517,7 +517,7 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)uint32_t nb_tx =0 , i; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );/* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) {
@@ -527,7 +527,8 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)for (i =0 ; i < p->n_retries; i++) { nb_tx +=rte_ring_sp_enqueue_burst (p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx,NULL );/* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) {
@@ -550,7 +551,7 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p)uint32_t nb_tx =0 , i; nb_tx =rte_ring_mp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );/* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) {
@@ -560,7 +561,8 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p)for (i =0 ; i < p->n_retries; i++) { nb_tx +=rte_ring_mp_enqueue_burst (p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx,NULL );/* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) {
@@ -633,10 +635,12 @@ rte_port_ring_writer_nodrop_tx_bulk_internal(void *port,RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD (p, n_pkts);if (is_multi) n_pkts_ok = -rte_ring_mp_enqueue_burst (p->ring, (void **)pkts, n_pkts); +rte_ring_mp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );else n_pkts_ok = -rte_ring_sp_enqueue_burst (p->ring, (void **)pkts, n_pkts); +rte_ring_sp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );if (n_pkts_ok >= n_pkts)return 0 ;
lib/librte_ring/rte_ring.h +44 -45
196 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 9/14 ring: allow dequeue fns to return remaining entry count
In reply to Bruce RichardsonAdd an extra parameter to the ring dequeue burst/bulk functions so that those functions can optionally return the amount of remaining objs in the ring. This information can be used by applications in a number of ways, for instance, with single-consumer queues, it provides a max dequeue size which is guaranteed to work.
--- app/pdump/main.c | 2 +- app/test-pipeline/runtime.c | 6 +- app/test/test_link_bonding_mode4.c | 3 +- app/test/test_pmd_ring_perf.c | 7 +- app/test/test_ring.c | 54 ++++++------- app/test/test_ring_perf.c | 20 +++-- app/test/test_table_acl.c | 2 +- app/test/test_table_pipeline.c | 2 +- app/test/test_table_ports.c | 8 +- app/test/virtual_pmd.c | 4 +- doc/guides/rel_notes/release_17_05.rst | 8 ++ drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 2 +- examples/distributor/main.c | 2 +- examples/load_balancer/runtime.c | 6 +- .../client_server_mp/mp_client/client.c | 3 +- examples/packet_ordering/main.c | 6 +- examples/qos_sched/app_thread.c | 6 +- examples/quota_watermark/qw/main.c | 5 +- examples/server_node_efd/node/node.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 3 +- lib/librte_mempool/rte_mempool_ring.c | 4 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ring.c | 6 +- lib/librte_ring/rte_ring.h | 90 +++++++++++----------- 26 files changed, 145 insertions(+), 114 deletions(-)
app/pdump/main.c +1 -1
@@ -496,7 +496,7 @@ pdump_rxtx(struct rte_ring *ring, uint8_t vdev_id, struct pdump_stats *stats)/* first dequeue packets from ring of primary process */ const uint16_t nb_in_deq =rte_ring_dequeue_burst (ring, - (void *)rxtx_bufs,BURST_SIZE ); + (void *)rxtx_bufs,BURST_SIZE ,NULL ); stats->dequeue_pkts += nb_in_deq;if (nb_in_deq) {
app/test-pipeline/runtime.c +4 -2
@@ -121,7 +121,8 @@ app_main_loop_worker(void) { ret =rte_ring_sc_dequeue_bulk ( app.rings_rx[i], (void **) worker_mbuf->array, - app.burst_size_worker_read); + app.burst_size_worker_read, +NULL );if (ret ==0 )continue ;
@@ -151,7 +152,8 @@ app_main_loop_tx(void) { ret =rte_ring_sc_dequeue_bulk ( app.rings_tx[i], (void **) &app.mbuf_tx[i].array[n_mbufs], - app.burst_size_tx_read); + app.burst_size_tx_read, +NULL );if (ret ==0 )continue ;
app/test/test_link_bonding_mode4.c +2 -1
@@ -193,7 +193,8 @@ static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };static int slave_get_pkts (struct slave_conf *slave,struct rte_mbuf **buf,uint16_t size) { -return rte_ring_dequeue_burst (slave->tx_queue, (void **)buf, size); +return rte_ring_dequeue_burst (slave->tx_queue, (void **)buf, + size,NULL ); }/*
app/test/test_pmd_ring_perf.c +4 -3
@@ -67,7 +67,7 @@ test_empty_dequeue(void)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t sc_end =rte_rdtsc ();const uint64_t eth_start =rte_rdtsc ();
@@ -99,7 +99,7 @@ test_single_enqueue_dequeue(void)rte_compiler_barrier ();for (i =0 ; i < iterations; i++) {rte_ring_enqueue_bulk (r, &burst,1 ,NULL ); -rte_ring_dequeue_bulk (r, &burst,1 ); +rte_ring_dequeue_bulk (r, &burst,1 ,NULL ); }const uint64_t sc_end =rte_rdtsc_precise ();rte_compiler_barrier ();
@@ -133,7 +133,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_bulk (r, (void *)burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_bulk (r, (void *)burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_bulk (r, (void *)burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
app/test/test_ring.c +28 -26
197 lines not on this page · raw message
app/test/test_ring_perf.c +12 -8
@@ -152,12 +152,12 @@ test_empty_dequeue(void)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t mc_end =rte_rdtsc (); printf("SC empty dequeue: %.2F\n",
@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc ();
@@ -325,7 +325,8 @@ test_burst_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_burst (r, burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_burst (r, burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_burst (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
@@ -333,7 +334,8 @@ test_burst_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_mp_enqueue_burst (r, burst, bulk_sizes[sz],NULL ); -rte_ring_mc_dequeue_burst (r, burst, bulk_sizes[sz]); +rte_ring_mc_dequeue_burst (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t mc_end =rte_rdtsc ();
@@ -361,7 +363,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_bulk (r, burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_bulk (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
@@ -369,7 +372,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_mp_enqueue_bulk (r, burst, bulk_sizes[sz],NULL ); -rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_mc_dequeue_bulk (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t mc_end =rte_rdtsc ();
app/test/test_table_acl.c +1 -1
@@ -713,7 +713,7 @@ test_pipeline_single_filter(int expected_count)void *objs[RING_TX_SIZE ];struct rte_mbuf *mbuf; - ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ); + ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ,NULL );if (ret <=0 ) {printf ("Got no objects from ring %d - error code %d\n" , i, ret);
app/test/test_table_pipeline.c +1 -1
@@ -494,7 +494,7 @@ test_pipeline_single_filter(int test_type, int expected_count)void *objs[RING_TX_SIZE ];struct rte_mbuf *mbuf; - ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ); + ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ,NULL );if (ret <=0 )printf ("Got no objects from ring %d - error code %d\n" , i, ret);
app/test/test_table_ports.c +4 -4
@@ -163,7 +163,7 @@ test_port_ring_writer(void) rte_port_ring_writer_ops.f_flush (port); expected_pkts =1 ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -7 ;
@@ -178,7 +178,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -8 ;
@@ -193,7 +193,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -8 ;
@@ -208,7 +208,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -9 ;
app/test/virtual_pmd.c +2 -2
@@ -342,7 +342,7 @@ virtual_ethdev_rx_burst_success(void *queue __rte_unused, dev_private = vrtl_eth_dev->data->dev_private; rx_count =rte_ring_dequeue_burst (dev_private->rx_queue, (void **) bufs, - nb_pkts); + nb_pkts,NULL );/* increments ipackets count */ dev_private->eth_stats.ipackets += rx_count;
@@ -508,7 +508,7 @@ virtual_ethdev_get_mbufs_from_tx_queue(uint8_t port_id, dev_private = vrtl_eth_dev->data->dev_private;return rte_ring_dequeue_burst (dev_private->tx_queue, (void **)pkt_burst, - burst_length); + burst_length,NULL ); } static uint8_t
doc/guides/rel_notes/release_17_05.rst +8 -0
@@ -123,6 +123,8 @@ API Changes * added an extra parameter to the burst/bulk enqueue functions to return the number of free spaces in the ring after enqueue. This can be used by an application to implement its own watermark functionality. + * added an extra parameter to the burst/bulk dequeue functions to return + the number elements remaining in the ring after dequeue. * changed the return value of the enqueue and dequeue bulk functions to match that of the burst equivalents. In all cases, ring functions which operate on multiple packets now return the number of elements enqueued
@@ -135,6 +137,12 @@ API Changes - ``rte_ring_sc_dequeue_bulk`` - ``rte_ring_dequeue_bulk`` + NOTE: the above functions all have different parameters as well as + different return values, due to the other listed changes above. This + means that all instances of the functions in existing code will be + flagged by the compiler. The return value usage should be checked + while fixing the compiler error due to the extra parameter. + ABI Changes -----------
drivers/crypto/null/null_crypto_pmd.c +1 -1
@@ -155,7 +155,7 @@ null_crypto_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_pkts, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/net/bonding/rte_eth_bond_pmd.c +2 -1
@@ -1008,7 +1008,8 @@ bond_ethdev_tx_burst_8023ad(void *queue, struct rte_mbuf **bufs,struct port *port = &mode_8023ad_ports[slaves[i]]; slave_slow_nb_pkts[i] =rte_ring_dequeue_burst (port->tx_ring, - slow_pkts,BOND_MODE_8023AX_SLAVE_TX_PKTS ); + slow_pkts,BOND_MODE_8023AX_SLAVE_TX_PKTS , +NULL ); slave_nb_pkts[i] = slave_slow_nb_pkts[i];for (j =0 ; j < slave_slow_nb_pkts[i]; j++)
drivers/net/ring/rte_eth_ring.c +1 -1
@@ -88,7 +88,7 @@ eth_ring_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)void **ptrs = (void *)&bufs[0 ];struct ring_queue *r = q;const uint16_t nb_rx = (uint16_t )rte_ring_dequeue_burst (r->rng, - ptrs, nb_bufs); + ptrs, nb_bufs,NULL );if (r->rng->flags &RING_F_SC_DEQ ) r->rx_pkts.cnt += nb_rx;else
examples/distributor/main.c +1 -1
@@ -330,7 +330,7 @@ lcore_tx(struct rte_ring *in_r)struct rte_mbuf *bufs[BURST_SIZE ];const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, - (void *)bufs,BURST_SIZE ); + (void *)bufs,BURST_SIZE ,NULL ); app_stats.tx.dequeue_pkts += nb_rx;/* if we get no traffic, flush anything we have */
examples/load_balancer/runtime.c +4 -2
@@ -349,7 +349,8 @@ app_lcore_io_tx( ret =rte_ring_sc_dequeue_bulk ( ring, (void **) &lp->tx.mbuf_out[port].array[n_mbufs], - bsz_rd); + bsz_rd, +NULL );if (unlikely (ret ==0 ))continue ;
@@ -504,7 +505,8 @@ app_lcore_worker( ret =rte_ring_sc_dequeue_bulk ( ring_in, (void **) lp->mbuf_in.array, - bsz_rd); + bsz_rd, +NULL );if (unlikely (ret ==0 ))continue ;
examples/multi_process/client_server_mp/mp_client/client.c +2 -1
@@ -279,7 +279,8 @@ main(int argc, char *argv[])uint16_t i, rx_pkts;uint8_t port; - rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts,PKT_READ_SIZE ); + rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts, +PKT_READ_SIZE ,NULL );if (unlikely (rx_pkts ==0 )){if (need_flush)
examples/packet_ordering/main.c +3 -3
@@ -462,7 +462,7 @@ worker_thread(void *args_ptr)/* dequeue the mbufs from rx_to_workers ring */ burst_size =rte_ring_dequeue_burst (ring_in, - (void *)burst_buffer,MAX_PKTS_BURST ); + (void *)burst_buffer,MAX_PKTS_BURST ,NULL );if (unlikely (burst_size ==0 ))continue ;
@@ -510,7 +510,7 @@ send_thread(struct send_thread_args *args)/* deque the mbufs from workers_to_tx ring */ nb_dq_mbufs =rte_ring_dequeue_burst (args->ring_in, - (void *)mbufs,MAX_PKTS_BURST ); + (void *)mbufs,MAX_PKTS_BURST ,NULL );if (unlikely (nb_dq_mbufs ==0 ))continue ;
@@ -595,7 +595,7 @@ tx_thread(struct rte_ring *ring_in)/* deque the mbufs from workers_to_tx ring */ dqnum =rte_ring_dequeue_burst (ring_in, - (void *)mbufs,MAX_PKTS_BURST ); + (void *)mbufs,MAX_PKTS_BURST ,NULL );if (unlikely (dqnum ==0 ))continue ;
examples/qos_sched/app_thread.c +3 -3
@@ -179,7 +179,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, - burst_conf.qos_dequeue); + burst_conf.qos_dequeue,NULL );if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue);
@@ -218,7 +218,7 @@ app_worker_thread(struct thread_conf **confs)/* Read packet from the ring */ nb_pkt =rte_ring_sc_dequeue_burst (conf->rx_ring, (void **)mbufs, - burst_conf.ring_burst); + burst_conf.ring_burst,NULL );if (likely (nb_pkt)) {int nb_sent =rte_sched_port_enqueue (conf->sched_port, mbufs, nb_pkt);
@@ -254,7 +254,7 @@ app_mixed_thread(struct thread_conf **confs)/* Read packet from the ring */ nb_pkt =rte_ring_sc_dequeue_burst (conf->rx_ring, (void **)mbufs, - burst_conf.ring_burst); + burst_conf.ring_burst,NULL );if (likely (nb_pkt)) {int nb_sent =rte_sched_port_enqueue (conf->sched_port, mbufs, nb_pkt);
examples/quota_watermark/qw/main.c +3 -2
@@ -247,7 +247,8 @@ pipeline_stage(__attribute__((unused)) void *args) }/* Dequeue up to quota mbuf from rx */ - nb_dq_pkts =rte_ring_dequeue_burst (rx, pkts, *quota); + nb_dq_pkts =rte_ring_dequeue_burst (rx, pkts, + *quota,NULL );if (unlikely (nb_dq_pkts <0 ))continue ;
@@ -305,7 +306,7 @@ send_stage(__attribute__((unused)) void *args)/* Dequeue packets from tx and send them */ nb_dq_pkts = (uint16_t )rte_ring_dequeue_burst (tx, - (void *) tx_pkts, *quota); + (void *) tx_pkts, *quota,NULL );rte_eth_tx_burst (dest_port_id,0 , tx_pkts, nb_dq_pkts);/* TODO: Check if nb_dq_pkts == nb_tx_pkts? */
examples/server_node_efd/node/node.c +1 -1
@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) ==0 )) + rx_pkts,NULL ) ==0 )) rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE );
lib/librte_hash/rte_cuckoo_hash.c +2 -1
@@ -536,7 +536,8 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key,if (cached_free_slots->len ==0 ) {/* Need to get another burst of free slots from global ring */ n_slots =rte_ring_mc_dequeue_burst (h->free_slots, - cached_free_slots->objs,LCORE_CACHE_SIZE ); + cached_free_slots->objs, +LCORE_CACHE_SIZE ,NULL );if (n_slots ==0 )return -ENOSPC ;
lib/librte_mempool/rte_mempool_ring.c +2 -2
@@ -58,14 +58,14 @@ static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { return rte_ring_mc_dequeue_bulk(mp->pool_data, - obj_table, n) == 0 ? -ENOBUFS : 0; + obj_table, n, NULL) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { return rte_ring_sc_dequeue_bulk(mp->pool_data, - obj_table, n) == 0 ? -ENOBUFS : 0; + obj_table, n, NULL) == 0 ? -ENOBUFS : 0; } static unsigned
lib/librte_port/rte_port_frag.c +2 -1
@@ -186,7 +186,8 @@ rte_port_ring_reader_frag_rx(void *port,/* If "pkts" buffer is empty, read packet burst from ring */ if (p->n_pkts ==0 ) { p->n_pkts =rte_ring_sc_dequeue_burst (p->ring, - (void **) p->pkts,RTE_PORT_IN_BURST_SIZE_MAX ); + (void **) p->pkts,RTE_PORT_IN_BURST_SIZE_MAX , +NULL );RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD (p, p->n_pkts);if (p->n_pkts ==0 )return n_pkts_out;
lib/librte_port/rte_port_ring.c +4 -2
@@ -111,7 +111,8 @@ rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;uint32_t nb_rx; - nb_rx =rte_ring_sc_dequeue_burst (p->ring, (void **) pkts, n_pkts); + nb_rx =rte_ring_sc_dequeue_burst (p->ring, (void **) pkts, + n_pkts,NULL );RTE_PORT_RING_READER_STATS_PKTS_IN_ADD (p, nb_rx);return nb_rx;
@@ -124,7 +125,8 @@ rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts,struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;uint32_t nb_rx; - nb_rx =rte_ring_mc_dequeue_burst (p->ring, (void **) pkts, n_pkts); + nb_rx =rte_ring_mc_dequeue_burst (p->ring, (void **) pkts, + n_pkts,NULL );RTE_PORT_RING_READER_STATS_PKTS_IN_ADD (p, nb_rx);return nb_rx;
lib/librte_ring/rte_ring.h +47 -43
196 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 10/14 examples/quota_watermark: use ring space for watermarks
In reply to Bruce RichardsonNow that the enqueue function returns the amount of space in the ring, we can use that to replace the old watermark functionality. Update the example app to do so, and re-enable it in the examples Makefile.
--- examples/Makefile | 2 +- examples/quota_watermark/qw/init.c | 5 +++-- examples/quota_watermark/qw/main.c | 16 ++++++++++------ examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 ++-- examples/quota_watermark/qwctl/qwctl.c | 2 ++ examples/quota_watermark/qwctl/qwctl.h | 1 + 7 files changed, 20 insertions(+), 11 deletions(-)
examples/Makefile +1 -1
@@ -81,7 +81,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering DIRS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ptpclient DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched -#DIRS-y += quota_watermark +DIRS-y += quota_watermark DIRS-$(CONFIG_RTE_ETHDEV_RXTX_CALLBACKS) += rxtx_callbacks DIRS-y += skeleton ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
examples/quota_watermark/qw/init.c +3 -2
@@ -140,7 +140,7 @@ void init_ring(int lcore_id, uint8_t port_id)if (ring ==NULL )rte_exit (EXIT_FAILURE ,"%s\n" ,rte_strerror (rte_errno)); -rte_ring_set_water_mark (ring,80 *RING_SIZE /100 ); + *high_watermark =80 *RING_SIZE /100 ; rings[lcore_id][port_id] = ring; }
@@ -168,10 +168,11 @@ setup_shared_variables(void)const struct rte_memzone *qw_memzone; qw_memzone =rte_memzone_reserve (QUOTA_WATERMARK_MEMZONE_NAME , -2 *sizeof (int ),rte_socket_id (),0 ); +3 *sizeof (int ),rte_socket_id (),0 );if (qw_memzone ==NULL )rte_exit (EXIT_FAILURE ,"%s\n" ,rte_strerror (rte_errno)); quota = qw_memzone->addr; low_watermark = (unsigned int *) qw_memzone->addr +1 ; + high_watermark = (unsigned int *) qw_memzone->addr +2 ; }
examples/quota_watermark/qw/main.c +10 -6
@@ -67,6 +67,7 @@ struct ether_fc_frame {int *quota;unsigned int *low_watermark; +unsigned int *high_watermark;uint8_t port_pairs[RTE_MAX_ETHPORTS ];
@@ -158,6 +159,7 @@ receive_stage(__attribute__((unused)) void *args)uint16_t nb_rx_pkts;unsigned int lcore_id; +unsigned int free;struct rte_mbuf *pkts[MAX_PKT_QUOTA ];struct rte_ring *ring;
@@ -189,13 +191,13 @@ receive_stage(__attribute__((unused)) void *args) nb_rx_pkts =rte_eth_rx_burst (port_id,0 , pkts, (uint16_t ) *quota); ret =rte_ring_enqueue_bulk (ring, (void *) pkts, - nb_rx_pkts); -if (ret == -EDQUOT ) { + nb_rx_pkts, &free); +if (RING_SIZE - free > *high_watermark) { ring_state[port_id] =RING_OVERLOADED ;send_pause_frame (port_id,1337 ); } -else if (ret == -ENOBUFS ) { +if (ret ==0 ) {/* * Return mbufs to the pool,
@@ -217,6 +219,7 @@ pipeline_stage(__attribute__((unused)) void *args)uint8_t port_id;unsigned int lcore_id, previous_lcore_id; +unsigned int free;void *pkts[MAX_PKT_QUOTA ];struct rte_ring *rx, *tx;
@@ -253,11 +256,12 @@ pipeline_stage(__attribute__((unused)) void *args)continue ;/* Enqueue them on tx */ - ret =rte_ring_enqueue_bulk (tx, pkts, nb_dq_pkts); -if (ret == -EDQUOT ) + ret =rte_ring_enqueue_bulk (tx, pkts, + nb_dq_pkts, &free); +if (RING_SIZE - free > *high_watermark) ring_state[port_id] =RING_OVERLOADED ; -else if (ret == -ENOBUFS ) { +if (ret ==0 ) {/* * Return mbufs to the pool,
examples/quota_watermark/qw/main.h +1 -0
@@ -43,6 +43,7 @@ enum ring_state {extern int *quota;extern unsigned int *low_watermark; +extern unsigned int *high_watermark;extern uint8_t port_pairs[RTE_MAX_ETHPORTS ];
examples/quota_watermark/qwctl/commands.c +2 -2
@@ -140,8 +140,8 @@ cmd_set_handler(__attribute__((unused)) void *parsed_result,else if (tokens->value >= *low_watermark *100 /RING_SIZE && tokens->value <=100 ) -rte_ring_set_water_mark (ring, - tokens->value *RING_SIZE /100 ); + *high_watermark = tokens->value * +RING_SIZE /100 ;else cmdline_printf(cl, "ring high watermark must be between %u%% and 100%%\n",
examples/quota_watermark/qwctl/qwctl.c +2 -0
@@ -55,6 +55,7 @@int *quota;unsigned int *low_watermark; +unsigned int *high_watermark; static void
@@ -68,6 +69,7 @@ setup_shared_variables(void) quota = qw_memzone->addr; low_watermark = (unsigned int *) qw_memzone->addr +1 ; + high_watermark = (unsigned int *) qw_memzone->addr +2 ; }int main (int argc,char **argv)
examples/quota_watermark/qwctl/qwctl.h +1 -0
@@ -36,5 +36,6 @@extern int *quota;extern unsigned int *low_watermark; +extern unsigned int *high_watermark;#endif /* _MAIN_H_ */
Signature · 1 line
2.9.3
PATCH 11/14 ring: reduce scope of local variables
In reply to Bruce RichardsonThe local variable i is only used for loop control so define it in the enqueue and dequeue blocks directly, rather than at the function level.
--- lib/librte_ring/rte_ring.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/librte_ring/rte_ring.h +2 -4
@@ -280,6 +280,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi producer enqueue functions */ #define ENQUEUE_PTRS () do { \ + unsigned int i; \ const uint32_t size = r->size; \ uint32_t idx = prod_head & mask; \ if (likely(idx + n < size)) { \
@@ -306,6 +307,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi consumer dequeue functions */ #define DEQUEUE_PTRS () do { \ + unsigned int i; \ uint32_t idx = cons_head & mask; \ const uint32_t size = r->size; \ if (likely(idx + n < size)) { \
@@ -356,7 +358,6 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t cons_tail, free_entries;const unsigned int max = n;int success; -unsigned int i;uint32_t mask = r->mask;/* move prod.head atomically */
@@ -426,7 +427,6 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, {uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries; -unsigned int i;uint32_t mask = r->mask; prod_head = r->prod.head;
@@ -490,7 +490,6 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_next, entries;const unsigned max = n;int success; -unsigned int i;uint32_t mask = r->mask;/* move cons.head atomically */
@@ -561,7 +560,6 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, {uint32_t cons_head, prod_tail;uint32_t cons_next, entries; -unsigned int i;uint32_t mask = r->mask; cons_head = r->cons.head;
Signature · 1 line
2.9.3
PATCH 12/14 ring: separate out head index manipulation for enq/deq
In reply to Bruce RichardsonWe can write a single common function for head manipulation for enq and a common one for deq, allowing us to have a single worker function for enq and deq, rather than two of each. Update all other inline functions to use the new functions.
--- lib/librte_ring/rte_ring.c | 4 +- lib/librte_ring/rte_ring.h | 328 ++++++++++++++++++++------------------------- 2 files changed, 149 insertions(+), 183 deletions(-)
lib/librte_ring/rte_ring.c +2 -2
@@ -138,8 +138,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->prod.sp_enqueue = !!(flags &RING_F_SP_ENQ ); - r->cons.sc_dequeue = !!(flags &RING_F_SC_DEQ ); + r->prod.sp_enqueue = (flags &RING_F_SP_ENQ ) ? __IS_SP : __IS_MP; + r->cons.sc_dequeue = (flags &RING_F_SC_DEQ ) ? __IS_SC : __IS_MC; r->size = count; r->mask = count -1 ; r->prod.head = r->cons.head =0 ;
lib/librte_ring/rte_ring.h +147 -181
528 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 13/14 ring: create common function for updating tail idx
In reply to Bruce RichardsonBoth producer and consumer use the same logic for updating the tail index so merge into a single function.
--- lib/librte_ring/rte_ring.h | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
lib/librte_ring/rte_ring.h +15 -17
@@ -336,6 +336,19 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r); } \ }while (0 ) +static inline __attribute__((always_inline)) void +update_tail (struct rte_ring_ht_ptr *ht_ptr,uint32_t old_val,uint32_t new_val) +{ +/* +* If there are other enqueues/dequeues in progress that preceded us, +* we need to wait for them to complete +*/ +while (unlikely (ht_ptr->tail != old_val)) +rte_pause (); + + ht_ptr->tail = new_val; +} +/** * @internal This function updates the producer head for enqueue *
@@ -435,15 +448,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,ENQUEUE_PTRS ();rte_smp_wmb (); -/* -* If there are other enqueues in progress that preceded us, -* we need to wait for them to complete -*/ -while (unlikely (r->prod.tail != prod_head)) -rte_pause (); - - r->prod.tail = prod_next; - +update_tail (&r->prod, prod_head, prod_next); end:if (free_space !=NULL ) *free_space = free_entries - n;
@@ -548,14 +553,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,DEQUEUE_PTRS ();rte_smp_rmb (); -/* -* If there are other enqueues in progress that preceded us, -* we need to wait for them to complete -*/ -while (unlikely (r->cons.tail != cons_head)) -rte_pause (); - - r->cons.tail = cons_next; +update_tail (&r->cons, cons_head, cons_next); end:if (available !=NULL )
Signature · 1 line
2.9.3
PATCH 14/14 ring: make ring struct and enq/deq macros type agnostic
In reply to Bruce RichardsonModify the enqueue and dequeue macros to support copying any type of object by passing in the exact object type. Rather than using the "ring" structure member of rte_ring, which is of type "array of void *", instead have the macros take the start of the ring a a pointer value, thereby leaving the rte_ring structure as purely a header value. This allows it to be reused by other future ring types which can add on extra fields if they want, or even to have the actual ring elements, of whatever type stored separate from the ring header.
--- lib/librte_ring/rte_ring.h | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-)
lib/librte_ring/rte_ring.h +36 -32
@@ -154,11 +154,7 @@ struct rte_ring {/** Ring consumer status. */ struct rte_ring_ht_ptr cons __rte_aligned(RTE_CACHE_LINE_SIZE * 2); - - void *ring[] __rte_cache_aligned; /**< Memory space of ring starts here. -* not volatile so need to be careful -* about compiler re-ordering */ -}; +} __rte_cache_aligned;#define RING_F_SP_ENQ 0x0001/**< The default enqueue is "single-producer". */ #define RING_F_SC_DEQ 0x0002/**< The default dequeue is "single-consumer". */
@@ -285,54 +281,62 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);/* the actual enqueue of pointers on the ring. * Placed here since identical code needed in both * single and multi producer enqueue functions */ -#define ENQUEUE_PTRS () do { \ +#define ENQUEUE_PTRS (r, ring_start, prod_head, obj_table, n, obj_type) do { \ unsigned int i; \ - const uint32_t size = r->size; \ - uint32_t idx = prod_head & r->mask; \ + const uint32_t size = (r)->size; \ + uint32_t idx = prod_head & (r)->mask; \ + obj_type *ring = (void *)ring_start; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \ - r->ring[idx] = obj_table[i]; \ - r->ring[idx+1] = obj_table[i+1]; \ - r->ring[idx+2] = obj_table[i+2]; \ - r->ring[idx+3] = obj_table[i+3]; \ + ring[idx] = obj_table[i]; \ + ring[idx+1] = obj_table[i+1]; \ + ring[idx+2] = obj_table[i+2]; \ + ring[idx+3] = obj_table[i+3]; \ } \ switch (n & 0x3) { \ - case 3: r->ring[idx++] = obj_table[i++]; \ - case 2: r->ring[idx++] = obj_table[i++]; \ - case 1: r->ring[idx++] = obj_table[i++]; \ + case 3: \ + ring[idx++] = obj_table[i++];/* fallthrough */ \ +case 2 : \ + ring[idx++] = obj_table[i++];/* fallthrough */ \ +case 1 : \ + ring[idx++] = obj_table[i++]; \ } \ } else { \for (i =0 ; idx < size; i++, idx++)\ - r->ring[idx] = obj_table[i]; \ + ring[idx] = obj_table[i]; \for (idx =0 ; i < n; i++, idx++) \ - r->ring[idx] = obj_table[i]; \ + ring[idx] = obj_table[i]; \ } \ -} while(0) +} while (0)/* the actual copy of pointers on the ring to obj_table. * Placed here since identical code needed in both * single and multi consumer dequeue functions */ -#define DEQUEUE_PTRS () do { \ +#define DEQUEUE_PTRS (r, ring_start, cons_head, obj_table, n, obj_type) do { \ unsigned int i; \ - uint32_t idx = cons_head & r->mask; \ - const uint32_t size = r->size; \ + uint32_t idx = cons_head & (r)->mask; \ + const uint32_t size = (r)->size; \ + obj_type *ring = (void *)ring_start; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\ - obj_table[i] = r->ring[idx]; \ - obj_table[i+1] = r->ring[idx+1]; \ - obj_table[i+2] = r->ring[idx+2]; \ - obj_table[i+3] = r->ring[idx+3]; \ + obj_table[i] = ring[idx]; \ + obj_table[i+1] = ring[idx+1]; \ + obj_table[i+2] = ring[idx+2]; \ + obj_table[i+3] = ring[idx+3]; \ } \ switch (n & 0x3) { \ - case 3: obj_table[i++] = r->ring[idx++]; \ - case 2: obj_table[i++] = r->ring[idx++]; \ - case 1: obj_table[i++] = r->ring[idx++]; \ + case 3: \ + obj_table[i++] = ring[idx++];/* fallthrough */ \ +case 2 : \ + obj_table[i++] = ring[idx++];/* fallthrough */ \ +case 1 : \ + obj_table[i++] = ring[idx++]; \ } \ } else { \for (i =0 ; idx < size; i++, idx++) \ - obj_table[i] = r->ring[idx]; \ + obj_table[i] = ring[idx]; \for (idx =0 ; i < n; i++, idx++) \ - obj_table[i] = r->ring[idx]; \ + obj_table[i] = ring[idx]; \ } \ } while (0)
@@ -445,7 +449,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,if (n ==0 ) goto end; -ENQUEUE_PTRS (); + ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);rte_smp_wmb ();update_tail (&r->prod, prod_head, prod_next);
@@ -550,7 +554,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,if (n ==0 ) goto end; -DEQUEUE_PTRS (); + DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n, void *);rte_smp_rmb ();update_tail (&r->cons, cons_head, cons_next);
Signature · 1 line
2.9.3
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
In reply to Bruce RichardsonQuoted 63 lines · Bruce Richardson
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the
rte_ringstructure. Therefore just remove the build option and set the structures to be always split. For improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.Signed-off-by Bruce Richardson <[email protected]>--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 6 ++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 8 ++------ 4 files changed, 8 insertions(+), 9 deletions(-)config/common_base +0
-1@@ -448,7 +448,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #doc/guides/rel_notes/release_17_05.rst +6
-0@@ -110,6 +110,12 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` ABI Changes -----------lib/librte_ring/rte_ring.c +0
-2@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG lib/librte_ring/rte_ring.h +0
-0
lib/librte_ring/rte_ring.h struct rte_ring { · line 171
Quoted 5 lines
lib/librte_ring/rte_ring.h +1
-1@@ -168,7 +168,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + } prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2);
I think we need to use RTE_CACHE_LINE_MIN_SIZE instead of RTE_CACHE_LINE_SIZE for alignment here. PPC and ThunderX1 targets are cache line size of 128B
Quoted 22 lines
lib/librte_ring/rte_ring.h +2
-5+ } prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2);/** Ring consumer status. */ struct cons {@@ -177,11 +177,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Consumer head. */ volatile uint32_t tail;/**< Consumer tail. */ -#ifdef RTE_RING_SPLIT_PROD_CONS - }cons __rte_cache_aligned; -#else - } cons; -#endif + } cons __rte_aligned(RTE_CACHE_LINE_SIZE * 2);#ifdef RTE_LIBRTE_RING_DEBUG struct rte_ring_debug_stats stats[RTE_MAX_LCORE ];Signature · 1 line
2.9.3
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
Quoted 65 lines · Jerin Jacob
Quoted 64 lines · Bruce Richardson
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the
rte_ringstructure. Therefore just remove the build option and set the structures to be always split. For improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.Signed-off-by Bruce Richardson <[email protected]>--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 6 ++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 8 ++------ 4 files changed, 8 insertions(+), 9 deletions(-)config/common_base +0
-1@@ -448,7 +448,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #doc/guides/rel_notes/release_17_05.rst +6
-0@@ -110,6 +110,12 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` ABI Changes -----------lib/librte_ring/rte_ring.c +0
-2@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG lib/librte_ring/rte_ring.h +0
-0@@ -168,7 +168,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */
Quoted 9 lines
lib/librte_ring/rte_ring.h struct rte_ring { · line 171
Quoted 4 lines
lib/librte_ring/rte_ring.h +1
-1volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + } prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2);I think we need to use
RTE_CACHE_LINE_MIN_SIZEinstead ofRTE_CACHE_LINE_SIZEfor alignment here. PPC and ThunderX1 targets are cache line size of 128B
Sure.
However, can you perhaps try a performance test and check to see if there is a performance difference between the two values before I change it? In my tests I see improved performance by having an extra blank cache-line between the producer and consumer data.
/Bruce
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
Quoted 75 lines · Bruce Richardson
Quoted 65 lines · Jerin Jacob
Quoted 64 lines · Bruce Richardson
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the
rte_ringstructure. Therefore just remove the build option and set the structures to be always split. For improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.Signed-off-by Bruce Richardson <[email protected]>--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 6 ++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 8 ++------ 4 files changed, 8 insertions(+), 9 deletions(-)config/common_base +0
-1@@ -448,7 +448,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #doc/guides/rel_notes/release_17_05.rst +6
-0@@ -110,6 +110,12 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` ABI Changes -----------lib/librte_ring/rte_ring.c +0
-2@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG lib/librte_ring/rte_ring.h +0
-0@@ -168,7 +168,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ Quoted 9 lines
lib/librte_ring/rte_ring.h struct rte_ring { · line 171
Quoted 4 lines
lib/librte_ring/rte_ring.h +1
-1volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + } prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2);I think we need to use
RTE_CACHE_LINE_MIN_SIZEinstead ofRTE_CACHE_LINE_SIZEfor alignment here. PPC and ThunderX1 targets are cache line size of 128B
Quoted 6 lines
Sure.
However, can you perhaps try a performance test and check to see if there is a performance difference between the two values before I change it? In my tests I see improved performance by having an extra blank cache-line between the producer and consumer data.
Sure. Which test are you running to measure the performance difference? Is it app/test/test_ring_perf.c?
Quoted 2 lines
/Bruce
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
Quoted 78 lines · Jerin Jacob
Quoted 77 lines · Bruce Richardson
Quoted 65 lines · Jerin Jacob
Quoted 64 lines · Bruce Richardson
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the
rte_ringstructure. Therefore just remove the build option and set the structures to be always split. For improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.Signed-off-by Bruce Richardson <[email protected]>--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 6 ++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 8 ++------ 4 files changed, 8 insertions(+), 9 deletions(-)config/common_base +0
-1@@ -448,7 +448,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #doc/guides/rel_notes/release_17_05.rst +6
-0@@ -110,6 +110,12 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` ABI Changes -----------lib/librte_ring/rte_ring.c +0
-2@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG lib/librte_ring/rte_ring.h +0
-0@@ -168,7 +168,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ Quoted 9 lines
lib/librte_ring/rte_ring.h struct rte_ring { · line 171
Quoted 4 lines
lib/librte_ring/rte_ring.h +1
-1volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + } prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2);I think we need to use
RTE_CACHE_LINE_MIN_SIZEinstead ofRTE_CACHE_LINE_SIZEfor alignment here. PPC and ThunderX1 targets are cache line size of 128BSure.
Quoted 9 lines
Quoted 4 lines
However, can you perhaps try a performance test and check to see if there is a performance difference between the two values before I change it? In my tests I see improved performance by having an extra blank cache-line between the producer and consumer data.
Sure. Which test are you running to measure the performance difference? Is it
app/test/test_ring_perf.c?Quoted 1 line
Yep, just the basic ring perf test. I look mostly at the core-to-core numbers, since hyperthread-to-hyperthread or NUMA socket to NUMA socket would be far less common use cases IMHO.
/Bruce
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
Quoted 84 lines · Bruce Richardson
Quoted 83 lines · Jerin Jacob
Quoted 81 lines · Bruce Richardson
Quoted 65 lines · Jerin Jacob
Quoted 64 lines · Bruce Richardson
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the
rte_ringstructure. Therefore just remove the build option and set the structures to be always split. For improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.Signed-off-by Bruce Richardson <[email protected]>--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 6 ++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 8 ++------ 4 files changed, 8 insertions(+), 9 deletions(-)config/common_base +0
-1@@ -448,7 +448,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #doc/guides/rel_notes/release_17_05.rst +6
-0@@ -110,6 +110,12 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` ABI Changes -----------lib/librte_ring/rte_ring.c +0
-2@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG lib/librte_ring/rte_ring.h +0
-0@@ -168,7 +168,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ Quoted 9 lines
lib/librte_ring/rte_ring.h struct rte_ring { · line 171
Quoted 4 lines
lib/librte_ring/rte_ring.h +1
-1volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + } prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2);I think we need to use
RTE_CACHE_LINE_MIN_SIZEinstead ofRTE_CACHE_LINE_SIZEfor alignment here. PPC and ThunderX1 targets are cache line size of 128BSure.
However, can you perhaps try a performance test and check to see if there is a performance difference between the two values before I change it? In my tests I see improved performance by having an extra blank cache-line between the producer and consumer data.
Quoted 7 lines
Quoted 4 lines
Sure. Which test are you running to measure the performance difference? Is it
app/test/test_ring_perf.c?Quoted 1 line
Yep, just the basic ring perf test. I look mostly at the core-to-core numbers, since hyperthread-to-hyperthread or NUMA socket to NUMA socket would be far less common use cases IMHO.
Performance test result shows regression with RTE_CACHE_LINE_MIN_SIZE scheme in some use case and some use case has higher performance(Testing using two physical cores)
# base code RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 84 MP/MC single enq/dequeue: 301 SP/SC burst enq/dequeue (size: 8): 20 MP/MC burst enq/dequeue (size: 8): 46 SP/SC burst enq/dequeue (size: 32): 12 MP/MC burst enq/dequeue (size: 32): 18
### Testing empty dequeue ###
SC empty dequeue: 7.11
MC empty dequeue: 12.15
### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 19.08 MP/MC bulk enq/dequeue (size: 8): 46.28 SP/SC bulk enq/dequeue (size: 32): 11.89 MP/MC bulk enq/dequeue (size: 32): 18.84
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 37.42 MP/MC bulk enq/dequeue (size: 8): 73.32 SP/SC bulk enq/dequeue (size: 32): 18.69 MP/MC bulk enq/dequeue (size: 32): 24.59 Test OK
# with ring rework patch RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 84 MP/MC single enq/dequeue: 301 SP/SC burst enq/dequeue (size: 8): 19 MP/MC burst enq/dequeue (size: 8): 45 SP/SC burst enq/dequeue (size: 32): 11 MP/MC burst enq/dequeue (size: 32): 18
### Testing empty dequeue ###
SC empty dequeue: 7.10
MC empty dequeue: 12.15
### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 18.59 MP/MC bulk enq/dequeue (size: 8): 45.49 SP/SC bulk enq/dequeue (size: 32): 11.67 MP/MC bulk enq/dequeue (size: 32): 18.65
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 37.41 MP/MC bulk enq/dequeue (size: 8): 72.98 SP/SC bulk enq/dequeue (size: 32): 18.69 MP/MC bulk enq/dequeue (size: 32): 24.59 Test OK
RTE>>
# with ring rework patch + cache-line size change to one on 128BCL target RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 90 MP/MC single enq/dequeue: 317 SP/SC burst enq/dequeue (size: 8): 20 MP/MC burst enq/dequeue (size: 8): 48 SP/SC burst enq/dequeue (size: 32): 11 MP/MC burst enq/dequeue (size: 32): 18
### Testing empty dequeue ###
SC empty dequeue: 8.10
MC empty dequeue: 11.15
### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 20.24 MP/MC bulk enq/dequeue (size: 8): 48.43 SP/SC bulk enq/dequeue (size: 32): 11.01 MP/MC bulk enq/dequeue (size: 32): 18.43
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 25.92 MP/MC bulk enq/dequeue (size: 8): 69.76 SP/SC bulk enq/dequeue (size: 32): 14.27 MP/MC bulk enq/dequeue (size: 32): 22.94 Test OK
RTE>>
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
Quoted 173 lines · Jerin Jacob
Quoted 84 lines · Bruce Richardson
Quoted 83 lines · Jerin Jacob
Quoted 81 lines · Bruce Richardson
Quoted 65 lines · Jerin Jacob
Quoted 64 lines · Bruce Richardson
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the
rte_ringstructure. Therefore just remove the build option and set the structures to be always split. For improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.Signed-off-by Bruce Richardson <[email protected]>--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 6 ++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 8 ++------ 4 files changed, 8 insertions(+), 9 deletions(-)config/common_base +0
-1@@ -448,7 +448,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #doc/guides/rel_notes/release_17_05.rst +6
-0@@ -110,6 +110,12 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` ABI Changes -----------lib/librte_ring/rte_ring.c +0
-2@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG lib/librte_ring/rte_ring.h +0
-0@@ -168,7 +168,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ Quoted 9 lines
lib/librte_ring/rte_ring.h struct rte_ring { · line 171
Quoted 4 lines
lib/librte_ring/rte_ring.h +1
-1volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + } prod __rte_aligned(RTE_CACHE_LINE_SIZE * 2);I think we need to use
RTE_CACHE_LINE_MIN_SIZEinstead ofRTE_CACHE_LINE_SIZEfor alignment here. PPC and ThunderX1 targets are cache line size of 128BSure.
However, can you perhaps try a performance test and check to see if there is a performance difference between the two values before I change it? In my tests I see improved performance by having an extra blank cache-line between the producer and consumer data.
Quoted 7 lines
Quoted 4 lines
Sure. Which test are you running to measure the performance difference? Is it
app/test/test_ring_perf.c?Quoted 1 line
Yep, just the basic ring perf test. I look mostly at the core-to-core numbers, since hyperthread-to-hyperthread or NUMA socket to NUMA socket would be far less common use cases IMHO.
Performance test result shows regression with
RTE_CACHE_LINE_MIN_SIZEscheme in some use case and some use case has higher performance(Testing using two physical cores)# base code RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 84 MP/MC single enq/dequeue: 301 SP/SC burst enq/dequeue (size: 8): 20 MP/MC burst enq/dequeue (size: 8): 46 SP/SC burst enq/dequeue (size: 32): 12 MP/MC burst enq/dequeue (size: 32): 18### Testing empty dequeue ###
SC empty dequeue: 7.11
MC empty dequeue: 12.15### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 19.08 MP/MC bulk enq/dequeue (size: 8): 46.28 SP/SC bulk enq/dequeue (size: 32): 11.89 MP/MC bulk enq/dequeue (size: 32): 18.84
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 37.42 MP/MC bulk enq/dequeue (size: 8): 73.32 SP/SC bulk enq/dequeue (size: 32): 18.69 MP/MC bulk enq/dequeue (size: 32): 24.59 Test OK
# with ring rework patch RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 84 MP/MC single enq/dequeue: 301 SP/SC burst enq/dequeue (size: 8): 19 MP/MC burst enq/dequeue (size: 8): 45 SP/SC burst enq/dequeue (size: 32): 11 MP/MC burst enq/dequeue (size: 32): 18### Testing empty dequeue ###
SC empty dequeue: 7.10
MC empty dequeue: 12.15### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 18.59 MP/MC bulk enq/dequeue (size: 8): 45.49 SP/SC bulk enq/dequeue (size: 32): 11.67 MP/MC bulk enq/dequeue (size: 32): 18.65
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 37.41 MP/MC bulk enq/dequeue (size: 8): 72.98 SP/SC bulk enq/dequeue (size: 32): 18.69 MP/MC bulk enq/dequeue (size: 32): 24.59 Test OK
RTE>># with ring rework patch + cache-line size change to one on 128BCL target RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 90 MP/MC single enq/dequeue: 317 SP/SC burst enq/dequeue (size: 8): 20 MP/MC burst enq/dequeue (size: 8): 48 SP/SC burst enq/dequeue (size: 32): 11 MP/MC burst enq/dequeue (size: 32): 18### Testing empty dequeue ###
SC empty dequeue: 8.10
MC empty dequeue: 11.15### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 20.24 MP/MC bulk enq/dequeue (size: 8): 48.43 SP/SC bulk enq/dequeue (size: 32): 11.01 MP/MC bulk enq/dequeue (size: 32): 18.43
Quoted 7 lines
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 25.92 MP/MC bulk enq/dequeue (size: 8): 69.76 SP/SC bulk enq/dequeue (size: 32): 14.27 MP/MC bulk enq/dequeue (size: 32): 22.94 Test OK
RTE>>
So given that there is not much difference here, is the MIN_SIZE i.e. forced 64B, your preference, rather than actual cacheline-size?
/Bruce
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
Hi Bruce,
Quoted 6 lines · Bruce Richardson
Quoted 5 lines · Jerin Jacob
Quoted 4 lines · Bruce Richardson
Quoted 3 lines · Jerin Jacob
Quoted 1 line · Bruce Richardson
On Tue, Feb 28, 2017 at 05:05:13PM +0530, Jerin Jacob wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines · Bruce Richardson
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the
rte_ringstructure. Therefore just remove the build option and set the structures to be always split. For improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent
You say you see an improved performance on Intel by having an extra blank cache-line between the producer and consumer data. Do you have an idea why it behaves like this? Do you think it is related to the hardware adjacent cache line prefetcher?
Quoted 85 lines
[...]
Quoted 76 lines
# base code RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 84 MP/MC single enq/dequeue: 301 SP/SC burst enq/dequeue (size: 8): 20 MP/MC burst enq/dequeue (size: 8): 46 SP/SC burst enq/dequeue (size: 32): 12 MP/MC burst enq/dequeue (size: 32): 18### Testing empty dequeue ###
SC empty dequeue: 7.11
MC empty dequeue: 12.15### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 19.08 MP/MC bulk enq/dequeue (size: 8): 46.28 SP/SC bulk enq/dequeue (size: 32): 11.89 MP/MC bulk enq/dequeue (size: 32): 18.84
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 37.42 MP/MC bulk enq/dequeue (size: 8): 73.32 SP/SC bulk enq/dequeue (size: 32): 18.69 MP/MC bulk enq/dequeue (size: 32): 24.59 Test OK
# with ring rework patch RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 84 MP/MC single enq/dequeue: 301 SP/SC burst enq/dequeue (size: 8): 19 MP/MC burst enq/dequeue (size: 8): 45 SP/SC burst enq/dequeue (size: 32): 11 MP/MC burst enq/dequeue (size: 32): 18### Testing empty dequeue ###
SC empty dequeue: 7.10
MC empty dequeue: 12.15### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 18.59 MP/MC bulk enq/dequeue (size: 8): 45.49 SP/SC bulk enq/dequeue (size: 32): 11.67 MP/MC bulk enq/dequeue (size: 32): 18.65
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 37.41 MP/MC bulk enq/dequeue (size: 8): 72.98 SP/SC bulk enq/dequeue (size: 32): 18.69 MP/MC bulk enq/dequeue (size: 32): 24.59 Test OK
RTE>># with ring rework patch + cache-line size change to one on 128BCL target RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 90 MP/MC single enq/dequeue: 317 SP/SC burst enq/dequeue (size: 8): 20 MP/MC burst enq/dequeue (size: 8): 48 SP/SC burst enq/dequeue (size: 32): 11 MP/MC burst enq/dequeue (size: 32): 18### Testing empty dequeue ###
SC empty dequeue: 8.10
MC empty dequeue: 11.15### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 20.24 MP/MC bulk enq/dequeue (size: 8): 48.43 SP/SC bulk enq/dequeue (size: 32): 11.01 MP/MC bulk enq/dequeue (size: 32): 18.43
Quoted 7 lines
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 25.92 MP/MC bulk enq/dequeue (size: 8): 69.76 SP/SC bulk enq/dequeue (size: 32): 14.27 MP/MC bulk enq/dequeue (size: 32): 22.94 Test OK
RTE>>
Quoted 3 lines
So given that there is not much difference here, is the
MIN_SIZEi.e. forced 64B, your preference, rather than actual cacheline-size?
I don't quite like this macro CACHE_LINE_MIN_SIZE. For me, it does not mean anything. The reasons for aligning on a cache line size are straightforward, but when should we need to align on the minimum cache line size supported by dpdk? For instance, in mbuf structure, aligning on 64 would make more sense to me.
So, I would prefer using (RTE_CACHE_LINE_SIZE * 2) here. If we don't want it on some architectures, or if this optimization is only for Intel (or all archs that need this optim), I think we could have something like:
/* bla bla */
#ifdef INTEL
#define __rte_ring_aligned __rte_aligned(RTE_CACHE_LINE_SIZE * 2) #else
#define __rte_ring_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) #endif
Olivier
Re: [PATCH v1 02/14] ring: create common structure for prod and cons metadata
In reply to Bruce RichardsonQuoted 26 lines · Bruce Richardson
create a common structure to hold the metadata for the producer and the consumer, since both need essentially the same information - the head and tail values, the ring size and mask.
Signed-off-by Bruce Richardson <[email protected]>--- lib/librte_ring/rte_ring.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)lib/librte_ring/rte_ring.h +1
-1@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -139,6 +139,19 @@ struct
rte_ring_debug_stats{struct
rte_memzone; /* forward declaration, so as not to requirememzone.h*/
lib/librte_ring/rte_ring.h struct rte_ring_debug_stats { · line 143
Quoted 2 lines
lib/librte_ring/rte_ring.h +2
-0+/* structure to hold a pair of head/tail values and other metadata */ +struct rte_ring_ht_ptr {
Just wondering if we can find a better name for this structure. I'm not sure '_ptr' is really relevant. What do you think of:
rte_ring_endpointrte_ring_htrte_ring_headtail
Olivier
Re: [PATCH v1 02/14] ring: create common structure for prod and cons metadata
Quoted 34 lines · Olivier Matz
Quoted 26 lines · Bruce Richardson
create a common structure to hold the metadata for the producer and the consumer, since both need essentially the same information - the head and tail values, the ring size and mask.
Signed-off-by Bruce Richardson <[email protected]>--- lib/librte_ring/rte_ring.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)lib/librte_ring/rte_ring.h +1
-1@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -139,6 +139,19 @@ struct
rte_ring_debug_stats{struct
rte_memzone; /* forward declaration, so as not to requirememzone.h*/lib/librte_ring/rte_ring.h struct rte_ring_debug_stats { · line 143
Quoted 2 lines
lib/librte_ring/rte_ring.h +2
-0+/* structure to hold a pair of head/tail values and other metadata */ +struct rte_ring_ht_ptr {Just wondering if we can find a better name for this structure. I'm not sure '
_ptr' is really relevant. What do you think of:
Quoted 4 lines
rte_ring_endpointrte_ring_htrte_ring_headtail
I'll use one of the latter two in next version.
/Bruce
Re: [PATCH v1 06/14] ring: remove watermark support
In reply to Bruce RichardsonQuoted 6 lines · Bruce Richardson
Remove the watermark support. A future commit will add support for having enqueue functions return the amount of free space in the ring, which will allow applications to implement their own watermark checks, while also being more useful to the app.
Signed-off-by Bruce Richardson <[email protected]>
Quoted 8 lines
--- app/test/commands.c | 52 ------------ app/test/test_ring.c | 149 +-------------------------------- doc/guides/rel_notes/release_17_05.rst | 2 + examples/Makefile | 2 +- lib/librte_ring/rte_ring.c | 23 ----- lib/librte_ring/rte_ring.h | 58 +------------ 6 files changed, 8 insertions(+), 278 deletions(-)
There are some other references to remove:
app/test/autotest_test_funcs.py: child.sendline("set_watermark test 100")
app/test/autotest_test_funcs.py: index = child.expect([" watermark=100",
app/test/autotest_test_funcs.py: return -1, "Fail [Bad watermark]"doc/guides/prog_guide/ring_lib.rst:Water Marking
doc/guides/prog_guide/ring_lib.rst:The ring can have a high water mark (threshold).
doc/guides/prog_guide/ring_lib.rst:Once an enqueue operation reaches the high water mark, the producer is notified, if the water mark is configured.
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
In reply to Olivier MatzQuoted 20 lines · Olivier Matz
Hi Bruce,
Quoted 6 lines · Bruce Richardson
Quoted 5 lines · Jerin Jacob
Quoted 4 lines · Bruce Richardson
Quoted 3 lines · Jerin Jacob
Quoted 1 line · Bruce Richardson
On Tue, Feb 28, 2017 at 05:05:13PM +0530, Jerin Jacob wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines · Bruce Richardson
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the
rte_ringstructure. Therefore just remove the build option and set the structures to be always split. For improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent
Quoted 5 lines
You say you see an improved performance on Intel by having an extra blank cache-line between the producer and consumer data. Do you have an idea why it behaves like this? Do you think it is related to the hardware adjacent cache line prefetcher?
That is a likely candidate, but I haven't done a full analysis on the details to know for sure what all the factors are. We see a similar effect with the packet distributor library, which uses similar padding.
Quoted 102 lines
Quoted 87 lines
[...]
Quoted 76 lines
# base code RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 84 MP/MC single enq/dequeue: 301 SP/SC burst enq/dequeue (size: 8): 20 MP/MC burst enq/dequeue (size: 8): 46 SP/SC burst enq/dequeue (size: 32): 12 MP/MC burst enq/dequeue (size: 32): 18### Testing empty dequeue ###
SC empty dequeue: 7.11
MC empty dequeue: 12.15### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 19.08 MP/MC bulk enq/dequeue (size: 8): 46.28 SP/SC bulk enq/dequeue (size: 32): 11.89 MP/MC bulk enq/dequeue (size: 32): 18.84
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 37.42 MP/MC bulk enq/dequeue (size: 8): 73.32 SP/SC bulk enq/dequeue (size: 32): 18.69 MP/MC bulk enq/dequeue (size: 32): 24.59 Test OK
# with ring rework patch RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 84 MP/MC single enq/dequeue: 301 SP/SC burst enq/dequeue (size: 8): 19 MP/MC burst enq/dequeue (size: 8): 45 SP/SC burst enq/dequeue (size: 32): 11 MP/MC burst enq/dequeue (size: 32): 18### Testing empty dequeue ###
SC empty dequeue: 7.10
MC empty dequeue: 12.15### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 18.59 MP/MC bulk enq/dequeue (size: 8): 45.49 SP/SC bulk enq/dequeue (size: 32): 11.67 MP/MC bulk enq/dequeue (size: 32): 18.65
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 37.41 MP/MC bulk enq/dequeue (size: 8): 72.98 SP/SC bulk enq/dequeue (size: 32): 18.69 MP/MC bulk enq/dequeue (size: 32): 24.59 Test OK
RTE>># with ring rework patch + cache-line size change to one on 128BCL target RTE>>ring_perf_autotest ### Testing single element and burst enq/deq ### SP/SC single enq/dequeue: 90 MP/MC single enq/dequeue: 317 SP/SC burst enq/dequeue (size: 8): 20 MP/MC burst enq/dequeue (size: 8): 48 SP/SC burst enq/dequeue (size: 32): 11 MP/MC burst enq/dequeue (size: 32): 18### Testing empty dequeue ###
SC empty dequeue: 8.10
MC empty dequeue: 11.15### Testing using a single lcore ### SP/SC bulk enq/dequeue (size: 8): 20.24 MP/MC bulk enq/dequeue (size: 8): 48.43 SP/SC bulk enq/dequeue (size: 32): 11.01 MP/MC bulk enq/dequeue (size: 32): 18.43
Quoted 7 lines
### Testing using two physical cores ### SP/SC bulk enq/dequeue (size: 8): 25.92 MP/MC bulk enq/dequeue (size: 8): 69.76 SP/SC bulk enq/dequeue (size: 32): 14.27 MP/MC bulk enq/dequeue (size: 32): 22.94 Test OK
RTE>>Quoted 3 lines
So given that there is not much difference here, is the
MIN_SIZEi.e. forced 64B, your preference, rather than actual cacheline-size?I don't quite like this macro
CACHE_LINE_MIN_SIZE. For me, it does not mean anything. The reasons for aligning on a cache line size are straightforward, but when should we need to align on the minimum cache line size supported by dpdk? For instance, in mbuf structure, aligning on 64 would make more sense to me.So, I would prefer using (
RTE_CACHE_LINE_SIZE* 2) here. If we don't want it on some architectures, or if this optimization is only for Intel (or all archs that need this optim), I think we could have something like:
Quoted 7 lines
/* bla bla */
#ifdef INTEL
#define__rte_ring_aligned__rte_aligned(RTE_CACHE_LINE_SIZE * 2)#else
#define__rte_ring_aligned__rte_aligned(RTE_CACHE_LINE_SIZE)#endif
I would agree that CACHE_LINE_MIN_SIZE probably doesn't make any sense here, but I'm happy to put in any suitable scheme that others are happy with. The options are:
* Keep as-is:
adv: simplest option, disadv: wastes 128B * 2 on some platforms
* Change to MIN_SIZE:
adv: no ifdefs, disadv: doesn't make much sense logically here
* Use ifdefs:
adv: each platform gets what's best for it, disadv: untidy code, may be harder to maintain
* Use hard-coded 128:
adv: short and simple, disadv: misses any logical reason why 128 is used, i.e. magic number
I'm ok with any option above.
/Bruce
Re: [PATCH v1 06/14] ring: remove watermark support
In reply to Olivier MatzQuoted 18 lines · Olivier Matz
Quoted 6 lines · Bruce Richardson
Remove the watermark support. A future commit will add support for having enqueue functions return the amount of free space in the ring, which will allow applications to implement their own watermark checks, while also being more useful to the app.
Signed-off-by Bruce Richardson <[email protected]>Quoted 8 lines
--- app/test/commands.c | 52 ------------ app/test/test_ring.c | 149 +-------------------------------- doc/guides/rel_notes/release_17_05.rst | 2 + examples/Makefile | 2 +- lib/librte_ring/rte_ring.c | 23 ----- lib/librte_ring/rte_ring.h | 58 +------------ 6 files changed, 8 insertions(+), 278 deletions(-)There are some other references to remove:
Quoted 8 lines
app/test/autotest_test_funcs.py: child.sendline("set_watermark test 100") app/test/autotest_test_funcs.py: index = child.expect([" watermark=100", app/test/autotest_test_funcs.py: return -1, "Fail [Bad watermark]"doc/guides/prog_guide/ring_lib.rst:Water Marking
doc/guides/prog_guide/ring_lib.rst:The ring can have a high water mark (threshold).
doc/guides/prog_guide/ring_lib.rst:Once an enqueue operation reaches the high water mark, the producer is notified, if the water mark is configured.
Yep, good catch. Will include in v2
/Bruce
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
In reply to Bruce RichardsonQuoted 41 lines · Bruce Richardson
Quoted 4 lines · Olivier Matz
Quoted 2 lines · Bruce Richardson
So given that there is not much difference here, is the
MIN_SIZEi.e. forced 64B, your preference, rather than actual cacheline-size?[...]
Quoted 11 lines
I don't quite like this macro
CACHE_LINE_MIN_SIZE. For me, it does not mean anything. The reasons for aligning on a cache line size are straightforward, but when should we need to align on the minimum cache line size supported by dpdk? For instance, in mbuf structure, aligning on 64 would make more sense to me.So, I would prefer using (
RTE_CACHE_LINE_SIZE* 2) here. If we don't want it on some architectures, or if this optimization is only for Intel (or all archs that need this optim), I think we could have something like:Quoted 7 lines
/* bla bla */
#ifdef INTEL
#define__rte_ring_aligned__rte_aligned(RTE_CACHE_LINE_SIZE * 2)#else
#define__rte_ring_aligned__rte_aligned(RTE_CACHE_LINE_SIZE)#endifI would agree that
CACHE_LINE_MIN_SIZEprobably doesn't make any sense here, but I'm happy to put in any suitable scheme that others are happy with. The options are:* Keep as-is:
adv: simplest option, disadv: wastes 128B * 2 on some platforms
* Change toMIN_SIZE:
adv: no ifdefs, disadv: doesn't make much sense logically here
* Use ifdefs:
adv: each platform gets what's best for it, disadv: untidy code, may be harder to maintain
* Use hard-coded 128:
adv: short and simple, disadv: misses any logical reason why 128 is used, i.e. magic number
Quoted 1 line
I'm ok with any option above.
I'd vote for "Keep as-is" or "Use ifdefs".
Olivier
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
Quoted 42 lines · Olivier Matz
Quoted 41 lines · Bruce Richardson
Quoted 4 lines · Olivier Matz
Quoted 2 lines · Bruce Richardson
So given that there is not much difference here, is the
MIN_SIZEi.e. forced 64B, your preference, rather than actual cacheline-size?[...]
Quoted 11 lines
I don't quite like this macro
CACHE_LINE_MIN_SIZE. For me, it does not mean anything. The reasons for aligning on a cache line size are straightforward, but when should we need to align on the minimum cache line size supported by dpdk? For instance, in mbuf structure, aligning on 64 would make more sense to me.So, I would prefer using (
RTE_CACHE_LINE_SIZE* 2) here. If we don't want it on some architectures, or if this optimization is only for Intel (or all archs that need this optim), I think we could have something like:Quoted 7 lines
/* bla bla */
#ifdef INTEL
#define__rte_ring_aligned__rte_aligned(RTE_CACHE_LINE_SIZE * 2)#else
#define__rte_ring_aligned__rte_aligned(RTE_CACHE_LINE_SIZE)#endifI would agree that
CACHE_LINE_MIN_SIZEprobably doesn't make any sense here, but I'm happy to put in any suitable scheme that others are happy with. The options are:* Keep as-is:
adv: simplest option, disadv: wastes 128B * 2 on some platforms
* Change toMIN_SIZE:
adv: no ifdefs, disadv: doesn't make much sense logically here
* Use ifdefs:
adv: each platform gets what's best for it, disadv: untidy code, may be harder to maintain
* Use hard-coded 128:
adv: short and simple, disadv: misses any logical reason why 128 is used, i.e. magic number
Quoted 3 lines
Quoted 1 line
I'm ok with any option above.
I'd vote for "Keep as-is" or "Use ifdefs".
I'd vote for "Use ifdefs", default configuration can be "RTE_CACHE_LINE_SIZE
* 2" but a target can override if required.
Quoted 2 lines
Olivier
Re: [PATCH v1 01/14] ring: remove split cacheline build setting
Quoted 43 lines · Jerin Jacob
Quoted 42 lines · Olivier Matz
Quoted 41 lines · Bruce Richardson
Quoted 4 lines · Olivier Matz
Quoted 2 lines · Bruce Richardson
So given that there is not much difference here, is the
MIN_SIZEi.e. forced 64B, your preference, rather than actual cacheline-size?[...]
Quoted 11 lines
I don't quite like this macro
CACHE_LINE_MIN_SIZE. For me, it does not mean anything. The reasons for aligning on a cache line size are straightforward, but when should we need to align on the minimum cache line size supported by dpdk? For instance, in mbuf structure, aligning on 64 would make more sense to me.So, I would prefer using (
RTE_CACHE_LINE_SIZE* 2) here. If we don't want it on some architectures, or if this optimization is only for Intel (or all archs that need this optim), I think we could have something like:Quoted 7 lines
/* bla bla */
#ifdef INTEL
#define__rte_ring_aligned__rte_aligned(RTE_CACHE_LINE_SIZE * 2)#else
#define__rte_ring_aligned__rte_aligned(RTE_CACHE_LINE_SIZE)#endifI would agree that
CACHE_LINE_MIN_SIZEprobably doesn't make any sense here, but I'm happy to put in any suitable scheme that others are happy with. The options are:* Keep as-is:
adv: simplest option, disadv: wastes 128B * 2 on some platforms
* Change toMIN_SIZE:
adv: no ifdefs, disadv: doesn't make much sense logically here
* Use ifdefs:
adv: each platform gets what's best for it, disadv: untidy code, may be harder to maintain
* Use hard-coded 128:
adv: short and simple, disadv: misses any logical reason why 128 is used, i.e. magic number
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
I'm ok with any option above.
I'd vote for "Keep as-is" or "Use ifdefs".
I'd vote for "Use ifdefs", default configuration can be "
RTE_CACHE_LINE_SIZE
* 2" but a target can override if required.Quoted 1 line
Ok. Will update with some #ifdefs in v2.
/Bruce
v2 cover refactor and cleanup of rte_ring
In reply to Bruce RichardsonNOTE: this set depends on the v2 cleanup set sent previously.
http://dpdk.org/ml/archives/dev/2017-February/thread.html#58200
This patchset make a set of, sometimes non-backward compatible, cleanup changes to the rte_ring code in order to improve it. The resulting code is shorter, since the existing functions are restructured to reduce code duplication, as well as being more consistent in behaviour. The specific changes made are explained in each patch which makes that change.
Changes in V2:
* Eliminated extra cacheline padding where cachelines are 128B
* Renamed rte_ring_ht_ptr struct to rte_ring_headtail
* Removed missed references to ring watermarks in test code and docs
This patchset is largely the same as that posted previously on-list as an RFC:
http://dpdk.org/ml/archives/dev/2017-February/thread.html#56982
Changes in V1 from RFC:
* Included release notes updates as changes are made in each patch
* Fixed some missed comment updates when changing the code
* Separated some initial fixup patches from this set to send separately
* Dropped the final two patches for an rte_event_ring, as not relevant for this set. That can be done as a separate set later.
* The macros for copying the pointers have an extra parameter added, indicating the start of the ring buffer itself. This allows more flexibility for reusing them in other ring implementations.
Bruce Richardson (14):
ring: remove split cacheline build setting
ring: create common structure for prod and cons metadata
ring: eliminate duplication of size and mask fields
ring: remove debug setting
ring: remove the yield when waiting for tail update
ring: remove watermark support
ring: make bulk and burst fn return vals consistent
ring: allow enqueue fns to return free space value
ring: allow dequeue fns to return remaining entry count examples/quota_watermark: use ring space for watermarks
ring: reduce scope of local variables
ring: separate out head index manipulation for enq/deq
ring: create common function for updating tail idx
ring: make ring struct and enq/deq macros type agnostic
app/pdump/main.c | 2 +- config/common_base | 3 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 - doc/guides/prog_guide/ring_lib.rst | 15 - doc/guides/rel_notes/release_17_05.rst | 32 + doc/guides/sample_app_ug/server_node_efd.rst | 2 +- drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 4 +- examples/distributor/main.c | 5 +- examples/load_balancer/runtime.c | 34 +- .../client_server_mp/mp_client/client.c | 9 +- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 13 +- examples/qos_sched/app_thread.c | 14 +- examples/quota_watermark/qw/init.c | 5 +- examples/quota_watermark/qw/main.c | 21 +- examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 +- examples/quota_watermark/qwctl/qwctl.c | 2 + examples/quota_watermark/qwctl/qwctl.h | 1 + examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 5 +- lib/librte_mempool/rte_mempool_ring.c | 12 +- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 34 +- lib/librte_ring/rte_ring.c | 76 +-- lib/librte_ring/rte_ring.h | 760 ++++++++------------- test/test-pipeline/pipeline_hash.c | 5 +- test/test-pipeline/runtime.c | 19 +- test/test/autotest_test_funcs.py | 7 - test/test/commands.c | 52 -- test/test/test_link_bonding_mode4.c | 6 +- test/test/test_pmd_ring_perf.c | 12 +- test/test/test_ring.c | 704 +++---------------- test/test/test_ring_perf.c | 36 +- test/test/test_table_acl.c | 2 +- test/test/test_table_pipeline.c | 2 +- test/test/test_table_ports.c | 12 +- test/test/virtual_pmd.c | 8 +- 43 files changed, 554 insertions(+), 1388 deletions(-)
Signature · 1 line
2.9.3
PATCH v2 4/14 ring: remove debug setting
The debug option only provided statistics to the user, most of which could be tracked by the application itself. Remove this as a compile time option, and feature, simplifying the code.
--- config/common_base | 1 - doc/guides/prog_guide/ring_lib.rst | 7 - doc/guides/rel_notes/release_17_05.rst | 1 + lib/librte_ring/rte_ring.c | 41 ---- lib/librte_ring/rte_ring.h | 97 +------- test/test/test_ring.c | 410 --------------------------------- 6 files changed, 13 insertions(+), 544 deletions(-)
config/common_base +0 -1
@@ -447,7 +447,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # Compile librte_ring # CONFIG_RTE_LIBRTE_RING=y -CONFIG_RTE_LIBRTE_RING_DEBUG=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #
doc/guides/prog_guide/ring_lib.rst +0 -7
@@ -110,13 +110,6 @@ Once an enqueue operation reaches the high water mark, the producer is notified, This mechanism can be used, for example, to exert a back pressure on I/O to inform the LAN to PAUSE. -Debug -~~~~~ - -When debug is enabled (CONFIG_RTE_LIBRTE_RING_DEBUG is set), -the library stores some per-ring statistic counters about the number of enqueues/dequeues. -These statistics are per-core to avoid concurrent accesses or atomic operations. - Use Cases ---------
doc/guides/rel_notes/release_17_05.rst +1 -0
@@ -116,6 +116,7 @@ API Changes have been made to it: * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` + * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` ABI Changes -----------
lib/librte_ring/rte_ring.c +0 -41
59 lines not on this page · raw message
lib/librte_ring/rte_ring.h +12 -85
183 lines not on this page · raw message
test/test/test_ring.c +0 -410
422 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v2 5/14 ring: remove the yield when waiting for tail update
In reply to Bruce RichardsonThere was a compile time setting to enable a ring to yield when it entered a loop in mp or mc rings waiting for the tail pointer update. Build time settings are not recommended for enabling/disabling features, and since this was off by default, remove it completely. If needed, a runtime enabled equivalent can be used.
--- config/common_base | 1 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 ---- doc/guides/rel_notes/release_17_05.rst | 1 + lib/librte_ring/rte_ring.h | 35 +++++-------------------- 4 files changed, 7 insertions(+), 35 deletions(-)
config/common_base +0 -1
@@ -447,7 +447,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # Compile librte_ring # CONFIG_RTE_LIBRTE_RING=y -CONFIG_RTE_RING_PAUSE_REP_COUNT=0 # # Compile librte_mempool
doc/guides/prog_guide/env_abstraction_layer.rst +0 -5
@@ -352,11 +352,6 @@ Known Issues 3. It MUST not be used by multi-producer/consumer pthreads, whose scheduling policies are SCHED_FIFO or SCHED_RR. - ``RTE_RING_PAUSE_REP_COUNT`` is defined for rte_ring to reduce contention. It's mainly for case 2, a yield is issued after number of times pause repeat. - - It adds a sched_yield() syscall if the thread spins for too long while waiting on the other thread to finish its operations on the ring. - This gives the preempted thread a chance to proceed and finish with the ring enqueue/dequeue operation. - + rte_timer Running ``rte_timer_manager()`` on a non-EAL pthread is not allowed. However, resetting/stopping the timer from a non-EAL pthread is allowed.
doc/guides/rel_notes/release_17_05.rst +1 -0
@@ -117,6 +117,7 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` + * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` ABI Changes -----------
lib/librte_ring/rte_ring.h +6 -29
@@ -114,11 +114,6 @@ enum rte_ring_queue_behavior {#define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \ sizeof(RTE_RING_MZ_PREFIX) + 1) -#ifndef RTE_RING_PAUSE_REP_COUNT -#define RTE_RING_PAUSE_REP_COUNT 0/**< Yield after pause num of times, no yield -* if RTE_RING_PAUSE_REP not defined. */ -#endif -struct rte_memzone ;/* forward declaration, so as not to require memzone.h */ #if RTE_CACHE_LINE_SIZE <128
@@ -396,7 +391,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t cons_tail, free_entries;const unsigned max = n;int success; -unsigned i, rep =0 ; +unsigned int i;uint32_t mask = r->mask;int ret;
@@ -450,18 +445,9 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,* If there are other enqueues in progress that preceded us, * we need to wait for them to complete */ -while (unlikely (r->prod.tail != prod_head)) { +while (unlikely (r->prod.tail != prod_head))rte_pause (); -/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting -* for other thread finish. It gives pre-empted thread a chance -* to proceed and finish with ring dequeue operation. */ -if (RTE_RING_PAUSE_REP_COUNT && - ++rep ==RTE_RING_PAUSE_REP_COUNT ) { - rep =0 ; -sched_yield (); - } - } r->prod.tail = prod_next;return ret; }
@@ -494,7 +480,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, {uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries; -unsigned i; +unsigned int i;uint32_t mask = r->mask;int ret;
@@ -571,7 +557,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_next, entries;const unsigned max = n;int success; -unsigned i, rep =0 ; +unsigned int i;uint32_t mask = r->mask;/* Avoid the unnecessary cmpset operation below, which is also
@@ -616,18 +602,9 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,* If there are other dequeues in progress that preceded us, * we need to wait for them to complete */ -while (unlikely (r->cons.tail != cons_head)) { +while (unlikely (r->cons.tail != cons_head))rte_pause (); -/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting -* for other thread finish. It gives pre-empted thread a chance -* to proceed and finish with ring dequeue operation. */ -if (RTE_RING_PAUSE_REP_COUNT && - ++rep ==RTE_RING_PAUSE_REP_COUNT ) { - rep =0 ; -sched_yield (); - } - } r->cons.tail = cons_next;return behavior ==RTE_RING_QUEUE_FIXED ?0 : n;
@@ -662,7 +639,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, {uint32_t cons_head, prod_tail;uint32_t cons_next, entries; -unsigned i; +unsigned int i;uint32_t mask = r->mask; cons_head = r->cons.head;
Signature · 1 line
2.9.3
PATCH v2 1/14 ring: remove split cacheline build setting
In reply to Bruce RichardsonUsers compiling DPDK should not need to know or care about the arrangement of cachelines in the rte_ring structure. Therefore just remove the build option and set the structures to be always split. On platforms with 64B cachelines, for improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.
---
V2: Limit the cacheline * 2 alignment to platforms with < 128B line size
--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 6 ++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 16 ++++++++++------ 4 files changed, 16 insertions(+), 9 deletions(-)
config/common_base +0 -1
@@ -448,7 +448,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #
doc/guides/rel_notes/release_17_05.rst +6 -0
@@ -110,6 +110,12 @@ API Changes Also, make sure to start the actual text at the margin. ========================================================= +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` ABI Changes -----------
lib/librte_ring/rte_ring.c +0 -2
@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG
lib/librte_ring/rte_ring.h +10 -6
@@ -139,6 +139,14 @@ struct rte_ring_debug_stats {struct rte_memzone ;/* forward declaration, so as not to require memzone.h */ +#if RTE_CACHE_LINE_SIZE <128 +#define PROD_ALIGN (RTE_CACHE_LINE_SIZE * 2) +#define CONS_ALIGN (RTE_CACHE_LINE_SIZE * 2) +#else +#define PROD_ALIGN RTE_CACHE_LINE_SIZE +#define CONS_ALIGN RTE_CACHE_LINE_SIZE +#endif +/** * An RTE ring structure. *
@@ -168,7 +176,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + }prod __rte_aligned (PROD_ALIGN );/** Ring consumer status. */ struct cons {
@@ -177,11 +185,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Consumer head. */ volatile uint32_t tail;/**< Consumer tail. */ -#ifdef RTE_RING_SPLIT_PROD_CONS - }cons __rte_cache_aligned; -#else - } cons; -#endif + }cons __rte_aligned (CONS_ALIGN );#ifdef RTE_LIBRTE_RING_DEBUG struct rte_ring_debug_stats stats[RTE_MAX_LCORE ];
Signature · 1 line
2.9.3
PATCH v2 2/14 ring: create common structure for prod and cons metadata
In reply to Bruce Richardsoncreate a common structure to hold the metadata for the producer and the consumer, since both need essentially the same information - the head and tail values, the ring size and mask.
---
V2: renamed the shared structure based on maintainer feedback.
--- lib/librte_ring/rte_ring.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
lib/librte_ring/rte_ring.h +16 -16
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -147,6 +147,19 @@ struct rte_memzone; /* forward declaration, so as not to require memzone.h */#define CONS_ALIGN RTE_CACHE_LINE_SIZE#endif +/* structure to hold a pair of head/tail values and other metadata */ +struct rte_ring_headtail { +volatile uint32_t head;/**< Prod/consumer head. */ +volatile uint32_t tail;/**< Prod/consumer tail. */ +uint32_t size;/**< Size of ring. */ +uint32_t mask;/**< Mask (size-1) of ring. */ +union { +uint32_t sp_enqueue;/**< True, if single producer. */ +uint32_t sc_dequeue;/**< True, if single consumer. */ + }; +uint32_t watermark;/**< Max items before EDQUOT in producer. */ +}; +/** * An RTE ring structure. *
@@ -169,23 +182,10 @@ struct rte_ring {/**< Memzone, if any, containing the rte_ring */ /** Ring producer status. */ -struct prod { -uint32_t watermark;/**< Maximum items before EDQUOT. */ -uint32_t sp_enqueue;/**< True, if single producer. */ -uint32_t size;/**< Size of ring. */ -uint32_t mask;/**< Mask (size-1) of ring. */ -volatile uint32_t head;/**< Producer head. */ -volatile uint32_t tail;/**< Producer tail. */ - } prod __rte_aligned(PROD_ALIGN); + struct rte_ring_headtail prod __rte_aligned(PROD_ALIGN);/** Ring consumer status. */ -struct cons { -uint32_t sc_dequeue;/**< True, if single consumer. */ -uint32_t size;/**< Size of the ring. */ -uint32_t mask;/**< Mask (size-1) of ring. */ -volatile uint32_t head;/**< Consumer head. */ -volatile uint32_t tail;/**< Consumer tail. */ - } cons __rte_aligned(CONS_ALIGN); + struct rte_ring_headtail cons __rte_aligned(CONS_ALIGN);#ifdef RTE_LIBRTE_RING_DEBUG struct rte_ring_debug_stats stats[RTE_MAX_LCORE ];
Signature · 1 line
2.9.3
PATCH v2 3/14 ring: eliminate duplication of size and mask fields
In reply to Bruce RichardsonThe size and mask fields are duplicated in both the producer and consumer data structures. Move them out of that into the top level structure so they are not duplicated.
--- lib/librte_ring/rte_ring.c | 20 ++++++++++---------- lib/librte_ring/rte_ring.h | 32 ++++++++++++++++---------------- test/test/test_ring.c | 6 +++--- 3 files changed, 29 insertions(+), 29 deletions(-)
lib/librte_ring/rte_ring.c +10 -10
@@ -144,11 +144,11 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->prod.watermark = count; + r->watermark = count; r->prod.sp_enqueue = !!(flags &RING_F_SP_ENQ ); r->cons.sc_dequeue = !!(flags &RING_F_SC_DEQ ); - r->prod.size = r->cons.size = count; - r->prod.mask = r->cons.mask = count-1 ; + r->size = count; + r->mask = count -1 ; r->prod.head = r->cons.head =0 ; r->prod.tail = r->cons.tail =0 ;
@@ -269,14 +269,14 @@ rte_ring_free(struct rte_ring *r)int rte_ring_set_water_mark (struct rte_ring *r,unsigned count) { -if (count >= r->prod.size) +if (count >= r->size)return -EINVAL ;/* if count is 0, disable the watermarking */ if (count ==0 ) - count = r->prod.size; + count = r->size; - r->prod.watermark = count; + r->watermark = count;return 0 ; }
@@ -291,17 +291,17 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)fprintf (f,"ring <%s>@%p\n" , r->name, r);fprintf (f," flags=%x\n" , r->flags); -fprintf (f," size=%" PRIu32"\n" , r->prod.size); +fprintf (f," size=%" PRIu32"\n" , r->size);fprintf (f," ct=%" PRIu32"\n" , r->cons.tail);fprintf (f," ch=%" PRIu32"\n" , r->cons.head);fprintf (f," pt=%" PRIu32"\n" , r->prod.tail);fprintf (f," ph=%" PRIu32"\n" , r->prod.head);fprintf (f," used=%u\n" ,rte_ring_count (r));fprintf (f," avail=%u\n" ,rte_ring_free_count (r)); -if (r->prod.watermark == r->prod.size) +if (r->watermark == r->size)fprintf (f," watermark=0\n" );else -fprintf (f," watermark=%" PRIu32"\n" , r->prod.watermark); +fprintf (f," watermark=%" PRIu32"\n" , r->watermark);/* sum and dump statistics */ #ifdef RTE_LIBRTE_RING_DEBUG
@@ -318,7 +318,7 @@ rte_ring_dump(FILE *f, const struct rte_ring *r) sum.deq_fail_bulk += r->stats[lcore_id].deq_fail_bulk; sum.deq_fail_objs += r->stats[lcore_id].deq_fail_objs; } -fprintf (f," size=%" PRIu32"\n" , r->prod.size); +fprintf (f," size=%" PRIu32"\n" , r->size);fprintf (f," enq_success_bulk=%" PRIu64"\n" , sum.enq_success_bulk);fprintf (f," enq_success_objs=%" PRIu64"\n" , sum.enq_success_objs);fprintf (f," enq_quota_bulk=%" PRIu64"\n" , sum.enq_quota_bulk);
lib/librte_ring/rte_ring.h +16 -16
@@ -151,13 +151,10 @@ struct rte_memzone; /* forward declaration, so as not to require memzone.h */struct rte_ring_headtail {volatile uint32_t head;/**< Prod/consumer head. */ volatile uint32_t tail;/**< Prod/consumer tail. */ -uint32_t size;/**< Size of ring. */ -uint32_t mask;/**< Mask (size-1) of ring. */ union {uint32_t sp_enqueue;/**< True, if single producer. */ uint32_t sc_dequeue;/**< True, if single consumer. */ }; -uint32_t watermark;/**< Max items before EDQUOT in producer. */ };/**
@@ -177,9 +174,12 @@ struct rte_ring {* next time the ABI changes */ char name[RTE_MEMZONE_NAMESIZE ];/**< Name of the ring. */ -int flags;/**< Flags supplied at creation. */ +int flags;/**< Flags supplied at creation. */ const struct rte_memzone *memzone;/**< Memzone, if any, containing the rte_ring */ +uint32_t size;/**< Size of ring. */ +uint32_t mask;/**< Mask (size-1) of ring. */ +uint32_t watermark;/**< Max items before EDQUOT in producer. */ /** Ring producer status. */ struct rte_ring_headtail prod __rte_aligned(PROD_ALIGN);
@@ -358,7 +358,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi producer enqueue functions */ #define ENQUEUE_PTRS () do { \ - const uint32_t size = r->prod.size; \ + const uint32_t size = r->size; \ uint32_t idx = prod_head & mask; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
@@ -385,7 +385,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* single and multi consumer dequeue functions */ #define DEQUEUE_PTRS () do { \ uint32_t idx = cons_head & mask; \ - const uint32_t size = r->cons.size; \ + const uint32_t size = r->size; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\ obj_table[i] = r->ring[idx]; \
@@ -440,7 +440,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,const unsigned max = n;int success;unsigned i, rep =0 ; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;int ret;/* Avoid the unnecessary cmpset operation below, which is also
@@ -488,7 +488,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb ();/* if we exceed the watermark */ -if (unlikely (((mask +1 ) - free_entries + n) > r->prod.watermark)) { +if (unlikely (((mask +1 ) - free_entries + n) > r->watermark)) { ret = (behavior ==RTE_RING_QUEUE_FIXED ) ? -EDQUOT : (int )(n |RTE_RING_QUOT_EXCEED );__RING_STAT_ADD (r, enq_quota, n);
@@ -547,7 +547,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries;unsigned i; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;int ret; prod_head = r->prod.head;
@@ -583,7 +583,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb ();/* if we exceed the watermark */ -if (unlikely (((mask +1 ) - free_entries + n) > r->prod.watermark)) { +if (unlikely (((mask +1 ) - free_entries + n) > r->watermark)) { ret = (behavior ==RTE_RING_QUEUE_FIXED ) ? -EDQUOT : (int )(n |RTE_RING_QUOT_EXCEED );__RING_STAT_ADD (r, enq_quota, n);
@@ -633,7 +633,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,const unsigned max = n;int success;unsigned i, rep =0 ; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;/* Avoid the unnecessary cmpset operation below, which is also * potentially harmful when n equals 0. */
@@ -730,7 +730,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_head, prod_tail;uint32_t cons_next, entries;unsigned i; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask; cons_head = r->cons.head; prod_tail = r->prod.tail;
@@ -1059,7 +1059,7 @@ rte_ring_full(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return ((cons_tail - prod_tail -1 ) & r->prod.mask) ==0 ; +return ((cons_tail - prod_tail -1 ) & r->mask) ==0 ; }/**
@@ -1092,7 +1092,7 @@ rte_ring_count(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return (prod_tail - cons_tail) & r->prod.mask; +return (prod_tail - cons_tail) & r->mask; }/**
@@ -1108,7 +1108,7 @@ rte_ring_free_count(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return (cons_tail - prod_tail -1 ) & r->prod.mask; +return (cons_tail - prod_tail -1 ) & r->mask; }/**
@@ -1122,7 +1122,7 @@ rte_ring_free_count(const struct rte_ring *r)static inline unsigned int rte_ring_get_size (const struct rte_ring *r) { -return r->prod.size; +return r->size; }/**
test/test/test_ring.c +3 -3
@@ -148,7 +148,7 @@ check_live_watermark_change(__attribute__((unused)) void *dummy) }/* read watermark, the only change allowed is from 16 to 32 */ - watermark = r->prod.watermark; + watermark = r->watermark;if (watermark != watermark_old && (watermark_old !=16 || watermark !=32 )) { printf("Bad watermark change %u -> %u\n", watermark_old,
@@ -213,7 +213,7 @@ test_set_watermark( void ){printf (" ring lookup failed\n" ); goto error; } - count = r->prod.size*2 ; + count = r->size *2 ; setwm =rte_ring_set_water_mark (r, count);if (setwm != -EINVAL ){printf ("Test failed to detect invalid watermark count value\n" );
@@ -222,7 +222,7 @@ test_set_watermark( void ){ count =0 ;rte_ring_set_water_mark (r, count); -if (r->prod.watermark != r->prod.size) { +if (r->watermark != r->size) {printf ("Test failed to detect invalid watermark count value\n" ); goto error; }
Signature · 1 line
2.9.3
PATCH v2 6/14 ring: remove watermark support
In reply to Bruce RichardsonRemove the watermark support. A future commit will add support for having enqueue functions return the amount of free space in the ring, which will allow applications to implement their own watermark checks, while also being more useful to the app.
---
V2: fix missed references to watermarks in v1
--- doc/guides/prog_guide/ring_lib.rst | 8 -- doc/guides/rel_notes/release_17_05.rst | 2 + examples/Makefile | 2 +- lib/librte_ring/rte_ring.c | 23 ----- lib/librte_ring/rte_ring.h | 58 +------------ test/test/autotest_test_funcs.py | 7 -- test/test/commands.c | 52 ------------ test/test/test_ring.c | 149 +-------------------------------- 8 files changed, 8 insertions(+), 293 deletions(-)
doc/guides/prog_guide/ring_lib.rst +0 -8
@@ -102,14 +102,6 @@ Name A ring is identified by a unique name. It is not possible to create two rings with the same name (rte_ring_create() returns NULL if this is attempted). -Water Marking -~~~~~~~~~~~~~ - -The ring can have a high water mark (threshold). -Once an enqueue operation reaches the high water mark, the producer is notified, if the water mark is configured. - -This mechanism can be used, for example, to exert a back pressure on I/O to inform the LAN to PAUSE. - Use Cases ---------
doc/guides/rel_notes/release_17_05.rst +2 -0
@@ -118,6 +118,8 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` + * removed the function ``rte_ring_set_water_mark`` as part of a general + removal of watermarks support in the library. ABI Changes -----------
examples/Makefile +1 -1
@@ -81,7 +81,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering DIRS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ptpclient DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched -DIRS-y += quota_watermark +#DIRS-y += quota_watermark DIRS-$(CONFIG_RTE_ETHDEV_RXTX_CALLBACKS) += rxtx_callbacks DIRS-y += skeleton ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
lib/librte_ring/rte_ring.c +0 -23
@@ -138,7 +138,6 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->watermark = count; r->prod.sp_enqueue = !!(flags &RING_F_SP_ENQ ); r->cons.sc_dequeue = !!(flags &RING_F_SC_DEQ ); r->size = count;
@@ -256,24 +255,6 @@ rte_ring_free(struct rte_ring *r)rte_free (te); } -/* -* change the high water mark. If *count* is 0, water marking is -* disabled -*/ -int -rte_ring_set_water_mark (struct rte_ring *r,unsigned count) -{ -if (count >= r->size) -return -EINVAL ; - -/* if count is 0, disable the watermarking */ -if (count ==0 ) - count = r->size; - - r->watermark = count; -return 0 ; -} -/* dump the status of the ring on the console */ void rte_ring_dump (FILE *f,const struct rte_ring *r)
@@ -287,10 +268,6 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)fprintf (f," ph=%" PRIu32"\n" , r->prod.head);fprintf (f," used=%u\n" ,rte_ring_count (r));fprintf (f," avail=%u\n" ,rte_ring_free_count (r)); -if (r->watermark == r->size) -fprintf (f," watermark=0\n" ); -else -fprintf (f," watermark=%" PRIu32"\n" , r->watermark); }/* dump the status of all rings on the console */
lib/librte_ring/rte_ring.h +2 -56
155 lines not on this page · raw message
test/test/autotest_test_funcs.py +0 -7
@@ -292,11 +292,4 @@ def ring_autotest(child, test_name): elif index == 2: return -1, "Fail [Timeout]" - child.sendline("set_watermark test 100") - child.sendline("dump_ring test") - index = child.expect([" watermark=100", - pexpect.TIMEOUT], timeout=1) - if index != 0: - return -1, "Fail [Bad watermark]" - return 0, "Success"
test/test/commands.c +0 -52
64 lines not on this page · raw message
test/test/test_ring.c +3 -146
179 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v2 7/14 ring: make bulk and burst fn return vals consistent
In reply to Bruce RichardsonThe bulk fns for rings returns 0 for all elements enqueued and negative for no space. Change that to make them consistent with the burst functions in returning the number of elements enqueued/dequeued, i.e. 0 or N. This change also allows the return value from enq/deq to be used directly without a branch for error checking.
--- doc/guides/rel_notes/release_17_05.rst | 11 +++ doc/guides/sample_app_ug/server_node_efd.rst | 2 +- examples/load_balancer/runtime.c | 16 ++- .../client_server_mp/mp_client/client.c | 8 +- .../client_server_mp/mp_server/main.c | 2 +- examples/qos_sched/app_thread.c | 8 +- examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 12 ++- lib/librte_ring/rte_ring.h | 109 +++++++-------------- test/test-pipeline/pipeline_hash.c | 2 +- test/test-pipeline/runtime.c | 8 +- test/test/test_ring.c | 46 +++++---- test/test/test_ring_perf.c | 8 +- 14 files changed, 106 insertions(+), 130 deletions(-)
doc/guides/rel_notes/release_17_05.rst +11 -0
@@ -120,6 +120,17 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` * removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library. + * changed the return value of the enqueue and dequeue bulk functions to + match that of the burst equivalents. In all cases, ring functions which + operate on multiple packets now return the number of elements enqueued + or dequeued, as appropriate. The updated functions are: + + - ``rte_ring_mp_enqueue_bulk`` + - ``rte_ring_sp_enqueue_bulk`` + - ``rte_ring_enqueue_bulk`` + - ``rte_ring_mc_dequeue_bulk`` + - ``rte_ring_sc_dequeue_bulk`` + - ``rte_ring_dequeue_bulk`` ABI Changes -----------
doc/guides/sample_app_ug/server_node_efd.rst +1 -1
@@ -286,7 +286,7 @@ repeated infinitely. cl = &nodes[node]; if (rte_ring_enqueue_bulk(cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != 0){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){ for (j = 0; j < cl_rx_buf[node].count; j++) rte_pktmbuf_free(cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
examples/load_balancer/runtime.c +7 -9
@@ -146,7 +146,7 @@ app_lcore_io_rx_buffer_to_send ( (void **) lp->rx.mbuf_out[worker].array, bsz); -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz; k ++) {struct rte_mbuf *m = lp->rx.mbuf_out[worker].array[k];
@@ -312,7 +312,7 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) (void **) lp->rx.mbuf_out[worker].array, lp->rx.mbuf_out[worker].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->rx.mbuf_out[worker].n_mbufs; k ++) {struct rte_mbuf *pkt_to_free = lp->rx.mbuf_out[worker].array[k];
@@ -349,9 +349,8 @@ app_lcore_io_tx( (void **) &lp->tx.mbuf_out[port].array[n_mbufs], bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - } n_mbufs += bsz_rd;
@@ -505,9 +504,8 @@ app_lcore_worker( (void **) lp->mbuf_in.array, bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - }#if APP_WORKER_DROP_ALL_PACKETS for (j =0 ; j < bsz_rd; j ++) {
@@ -559,7 +557,7 @@ app_lcore_worker(#if APP_STATS lp->rings_out_iters[port] ++; -if (ret ==0 ) { +if (ret >0 ) { lp->rings_out_count[port] +=1 ; }if (lp->rings_out_iters[port] ==APP_STATS ){
@@ -572,7 +570,7 @@ app_lcore_worker( }#endif -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz_wr; k ++) {struct rte_mbuf *pkt_to_free = lp->mbuf_out[port].array[k];
@@ -609,7 +607,7 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) (void **) lp->mbuf_out[port].array, lp->mbuf_out[port].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->mbuf_out[port].n_mbufs; k ++) {struct rte_mbuf *pkt_to_free = lp->mbuf_out[port].array[k];
examples/multi_process/client_server_mp/mp_client/client.c +2 -6
@@ -276,14 +276,10 @@ main(int argc, char *argv[])printf ("[Press Ctrl-C to quit ...]\n" );for (;;) { -uint16_t i, rx_pkts =PKT_READ_SIZE ; +uint16_t i, rx_pkts;uint8_t port; -/* try dequeuing max possible packets first, if that fails, get the -* most we can. Loop body should only execute once, maximum */ -while (rx_pkts >0 && -unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, rx_pkts) !=0 )) - rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE ); + rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts,PKT_READ_SIZE );if (unlikely (rx_pkts ==0 )){if (need_flush)
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) !=0 ){ + cl_rx_buf[client].count) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]); cl->stats.rx_drop += cl_rx_buf[client].count;
examples/qos_sched/app_thread.c +5 -3
@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) !=0 )) { + (void **)rx_mbufs, nb_rx) ==0 )) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);
@@ -180,7 +180,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, burst_conf.qos_dequeue); -if (likely (retval ==0 )) { +if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue); conf->counter =0 ;/* reset empty read loop counter */
@@ -230,7 +230,9 @@ app_worker_thread(struct thread_conf **confs) nb_pkt =rte_sched_port_dequeue (conf->sched_port, mbufs, burst_conf.qos_dequeue);if (likely (nb_pkt >0 )) -while (rte_ring_sp_enqueue_bulk (conf->tx_ring, (void **)mbufs, nb_pkt) !=0 ); +while (rte_ring_sp_enqueue_bulk (conf->tx_ring, + (void **)mbufs, nb_pkt) ==0 ) + ;/* empty body */ conf_idx++;if (confs[conf_idx] ==NULL )
examples/server_node_efd/node/node.c +1 -1
@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) !=0 )) + rx_pkts) ==0 )) rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE );
examples/server_node_efd/server/main.c +1 -1
@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) !=0 ){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
lib/librte_mempool/rte_mempool_ring.c +8 -4
@@ -42,26 +42,30 @@ static int common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { - return rte_ring_mp_enqueue_bulk(mp->pool_data, obj_table, n); + return rte_ring_mp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { -return rte_ring_sp_enqueue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_mc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_mc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_sc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static unsigned
lib/librte_ring/rte_ring.h +38 -71
264 lines not on this page · raw message
test/test-pipeline/pipeline_hash.c +1 -1
@@ -547,6 +547,6 @@ app_main_loop_rx_metadata(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }
test/test-pipeline/runtime.c +4 -4
@@ -98,7 +98,7 @@ app_main_loop_rx(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }
@@ -123,7 +123,7 @@ app_main_loop_worker(void) { (void **) worker_mbuf->array, app.burst_size_worker_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; do {
@@ -131,7 +131,7 @@ app_main_loop_worker(void) { app.rings_tx[i ^1 ], (void **) worker_mbuf->array, app.burst_size_worker_write); - }while (ret <0 ); + }while (ret ==0 ); } }
@@ -152,7 +152,7 @@ app_main_loop_tx(void) { (void **) &app.mbuf_tx[i].array[n_mbufs], app.burst_size_tx_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; n_mbufs += app.burst_size_tx_read;
test/test/test_ring.c +22 -24
152 lines not on this page · raw message
test/test/test_ring_perf.c +4 -4
@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();
@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc ();
Signature · 1 line
2.9.3
PATCH v2 8/14 ring: allow enqueue fns to return free space value
In reply to Bruce RichardsonAdd an extra parameter to the ring enqueue burst/bulk functions so that those functions can optionally return the amount of free space in the ring. This information can be used by applications in a number of ways, for instance, with single-producer queues, it provides a max enqueue size which is guaranteed to work. It can also be used to implement watermark functionality in apps, replacing the older functionality with a more flexible version, which enables apps to implement multiple watermark thresholds, rather than just one.
--- doc/guides/rel_notes/release_17_05.rst | 3 + drivers/net/ring/rte_eth_ring.c | 2 +- examples/distributor/main.c | 3 +- examples/load_balancer/runtime.c | 12 ++- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 7 +- examples/qos_sched/app_thread.c | 4 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 4 +- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 28 ++++--- lib/librte_ring/rte_ring.h | 89 +++++++++++----------- test/test-pipeline/pipeline_hash.c | 3 +- test/test-pipeline/runtime.c | 5 +- test/test/test_link_bonding_mode4.c | 3 +- test/test/test_pmd_ring_perf.c | 5 +- test/test/test_ring.c | 55 ++++++------- test/test/test_ring_perf.c | 16 ++-- test/test/test_table_ports.c | 4 +- test/test/virtual_pmd.c | 4 +- 22 files changed, 139 insertions(+), 118 deletions(-)
doc/guides/rel_notes/release_17_05.rst +3 -0
@@ -120,6 +120,9 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` * removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library. + * added an extra parameter to the burst/bulk enqueue functions to + return the number of free spaces in the ring after enqueue. This can + be used by an application to implement its own watermark functionality. * changed the return value of the enqueue and dequeue bulk functions to match that of the burst equivalents. In all cases, ring functions which operate on multiple packets now return the number of elements enqueued
drivers/net/ring/rte_eth_ring.c +1 -1
@@ -102,7 +102,7 @@ eth_ring_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)void **ptrs = (void *)&bufs[0 ];struct ring_queue *r = q;const uint16_t nb_tx = (uint16_t )rte_ring_enqueue_burst (r->rng, - ptrs, nb_bufs); + ptrs, nb_bufs,NULL );if (r->rng->flags &RING_F_SP_ENQ ) { r->tx_pkts.cnt += nb_tx; r->err_pkts.cnt += nb_bufs - nb_tx;
examples/distributor/main.c +2 -1
@@ -238,7 +238,8 @@ lcore_rx(struct lcore_params *p)continue ; } -uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, nb_ret); +uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, + nb_ret,NULL ); app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { RTE_LOG_DP(DEBUG, DISTRAPP,
examples/load_balancer/runtime.c +8 -4
@@ -144,7 +144,8 @@ app_lcore_io_rx_buffer_to_send ( ret =rte_ring_sp_enqueue_bulk ( lp->rx.rings[worker], (void **) lp->rx.mbuf_out[worker].array, - bsz); + bsz, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
@@ -310,7 +311,8 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) ret =rte_ring_sp_enqueue_bulk ( lp->rx.rings[worker], (void **) lp->rx.mbuf_out[worker].array, - lp->rx.mbuf_out[worker].n_mbufs); + lp->rx.mbuf_out[worker].n_mbufs, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
@@ -553,7 +555,8 @@ app_lcore_worker( ret =rte_ring_sp_enqueue_bulk ( lp->rings_out[port], (void **) lp->mbuf_out[port].array, - bsz_wr); + bsz_wr, +NULL );#if APP_STATS lp->rings_out_iters[port] ++;
@@ -605,7 +608,8 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) ret =rte_ring_sp_enqueue_bulk ( lp->rings_out[port], (void **) lp->mbuf_out[port].array, - lp->mbuf_out[port].n_mbufs); + lp->mbuf_out[port].n_mbufs, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) ==0 ){ + cl_rx_buf[client].count,NULL ) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]); cl->stats.rx_drop += cl_rx_buf[client].count;
examples/packet_ordering/main.c +4 -3
@@ -421,8 +421,8 @@ rx_thread(struct rte_ring *ring_out) pkts[i++]->seqn = seqn++;/* enqueue to rx_to_workers ring */ - ret =rte_ring_enqueue_burst (ring_out, (void *) pkts, - nb_rx_pkts); + ret =rte_ring_enqueue_burst (ring_out, + (void *)pkts, nb_rx_pkts,NULL ); app_stats.rx.enqueue_pkts += ret;if (unlikely (ret < nb_rx_pkts)) { app_stats.rx.enqueue_failed_pkts +=
@@ -473,7 +473,8 @@ worker_thread(void *args_ptr) burst_buffer[i++]->port ^= xor_val;/* enqueue the modified mbufs to workers_to_tx ring */ - ret =rte_ring_enqueue_burst (ring_out, (void *)burst_buffer, burst_size); + ret =rte_ring_enqueue_burst (ring_out, (void *)burst_buffer, + burst_size,NULL );__sync_fetch_and_add (&app_stats.wkr.enqueue_pkts, ret);if (unlikely (ret < burst_size)) {/* Return the mbufs to their respective pool, dropping packets */
examples/qos_sched/app_thread.c +2 -2
@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) ==0 )) { + (void **)rx_mbufs, nb_rx,NULL ) ==0 )) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);
@@ -231,7 +231,7 @@ app_worker_thread(struct thread_conf **confs) burst_conf.qos_dequeue);if (likely (nb_pkt >0 ))while (rte_ring_sp_enqueue_bulk (conf->tx_ring, - (void **)mbufs, nb_pkt) ==0 ) + (void **)mbufs, nb_pkt,NULL ) ==0 ) ;/* empty body */ conf_idx++;
examples/server_node_efd/server/main.c +1 -1
@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != cl_rx_buf[node].count){ + cl_rx_buf[node].count,NULL ) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
lib/librte_hash/rte_cuckoo_hash.c +1 -1
@@ -808,7 +808,7 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, unsigned i)/* Need to enqueue the free slots in global ring. */ n_slots =rte_ring_mp_enqueue_burst (h->free_slots, cached_free_slots->objs, -LCORE_CACHE_SIZE ); +LCORE_CACHE_SIZE ,NULL ); cached_free_slots->len -= n_slots; }/* Put index of new free slot in cache. */
lib/librte_mempool/rte_mempool_ring.c +2 -2
@@ -43,7 +43,7 @@ common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) {return rte_ring_mp_enqueue_bulk (mp->pool_data, - obj_table, n) ==0 ? -ENOBUFS :0 ; + obj_table, n,NULL ) ==0 ? -ENOBUFS :0 ; } static int
@@ -51,7 +51,7 @@ common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) {return rte_ring_sp_enqueue_bulk (mp->pool_data, - obj_table, n) ==0 ? -ENOBUFS :0 ; + obj_table, n,NULL ) ==0 ? -ENOBUFS :0 ; } static int
lib/librte_pdump/rte_pdump.c +1 -1
@@ -197,7 +197,7 @@ pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) dup_bufs[d_pkts++] = p; } - ring_enq =rte_ring_enqueue_burst (ring, (void *)dup_bufs, d_pkts); + ring_enq =rte_ring_enqueue_burst (ring, (void *)dup_bufs, d_pkts,NULL );if (unlikely (ring_enq < d_pkts)) {RTE_LOG (DEBUG ,PDUMP ,"only %d of packets enqueued to ring\n" , ring_enq);
lib/librte_port/rte_port_ras.c +1 -1
@@ -167,7 +167,7 @@ send_burst(struct rte_port_ring_writer_ras *p)uint32_t nb_tx; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
lib/librte_port/rte_port_ring.c +16 -12
@@ -241,7 +241,7 @@ send_burst(struct rte_port_ring_writer *p)uint32_t nb_tx; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
@@ -256,7 +256,7 @@ send_burst_mp(struct rte_port_ring_writer *p)uint32_t nb_tx; nb_tx =rte_ring_mp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
@@ -318,11 +318,11 @@ rte_port_ring_writer_tx_bulk_internal(void *port,RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD (p, n_pkts);if (is_multi) - n_pkts_ok =rte_ring_mp_enqueue_burst (p->ring, (void **)pkts, - n_pkts); + n_pkts_ok =rte_ring_mp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );else - n_pkts_ok =rte_ring_sp_enqueue_burst (p->ring, (void **)pkts, - n_pkts); + n_pkts_ok =rte_ring_sp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, n_pkts - n_pkts_ok);for ( ; n_pkts_ok < n_pkts; n_pkts_ok++) {
@@ -517,7 +517,7 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)uint32_t nb_tx =0 , i; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );/* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) {
@@ -527,7 +527,8 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)for (i =0 ; i < p->n_retries; i++) { nb_tx +=rte_ring_sp_enqueue_burst (p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx,NULL );/* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) {
@@ -550,7 +551,7 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p)uint32_t nb_tx =0 , i; nb_tx =rte_ring_mp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );/* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) {
@@ -560,7 +561,8 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p)for (i =0 ; i < p->n_retries; i++) { nb_tx +=rte_ring_mp_enqueue_burst (p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx,NULL );/* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) {
@@ -633,10 +635,12 @@ rte_port_ring_writer_nodrop_tx_bulk_internal(void *port,RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD (p, n_pkts);if (is_multi) n_pkts_ok = -rte_ring_mp_enqueue_burst (p->ring, (void **)pkts, n_pkts); +rte_ring_mp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );else n_pkts_ok = -rte_ring_sp_enqueue_burst (p->ring, (void **)pkts, n_pkts); +rte_ring_sp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );if (n_pkts_ok >= n_pkts)return 0 ;
lib/librte_ring/rte_ring.h +44 -45
196 lines not on this page · raw message
test/test-pipeline/pipeline_hash.c +2 -1
@@ -546,7 +546,8 @@ app_main_loop_rx_metadata(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_rx[i], (void **) app.mbuf_rx.array, - n_mbufs); + n_mbufs, +NULL ); }while (ret ==0 ); } }
test/test-pipeline/runtime.c +3 -2
@@ -97,7 +97,7 @@ app_main_loop_rx(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_rx[i], (void **) app.mbuf_rx.array, - n_mbufs); + n_mbufs,NULL ); }while (ret ==0 ); } }
@@ -130,7 +130,8 @@ app_main_loop_worker(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_tx[i ^1 ], (void **) worker_mbuf->array, - app.burst_size_worker_write); + app.burst_size_worker_write, +NULL ); }while (ret ==0 ); } }
test/test/test_link_bonding_mode4.c +2 -1
@@ -206,7 +206,8 @@ slave_get_pkts(struct slave_conf *slave, struct rte_mbuf **buf, uint16_t size)static int slave_put_pkts (struct slave_conf *slave,struct rte_mbuf **buf,uint16_t size) { -return rte_ring_enqueue_burst (slave->rx_queue, (void **)buf, size); +return rte_ring_enqueue_burst (slave->rx_queue, (void **)buf, + size,NULL ); } static uint16_t
test/test/test_pmd_ring_perf.c +3 -2
@@ -98,7 +98,7 @@ test_single_enqueue_dequeue(void)const uint64_t sc_start =rte_rdtsc_precise ();rte_compiler_barrier ();for (i =0 ; i < iterations; i++) { -rte_ring_enqueue_bulk (r, &burst,1 ); +rte_ring_enqueue_bulk (r, &burst,1 ,NULL );rte_ring_dequeue_bulk (r, &burst,1 ); }const uint64_t sc_end =rte_rdtsc_precise ();
@@ -131,7 +131,8 @@ test_bulk_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_bulk (r, (void *)burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_bulk (r, (void *)burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_bulk (r, (void *)burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();
test/test/test_ring.c +28 -27
203 lines not on this page · raw message
test/test/test_ring_perf.c +10 -6
@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();
@@ -323,14 +323,16 @@ test_burst_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_burst (r, burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_burst (r, burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_burst (r, burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_mp_enqueue_burst (r, burst, bulk_sizes[sz]); +rte_ring_mp_enqueue_burst (r, burst, + bulk_sizes[sz],NULL );rte_ring_mc_dequeue_burst (r, burst, bulk_sizes[sz]); }const uint64_t mc_end =rte_rdtsc ();
@@ -357,14 +359,16 @@ test_bulk_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_bulk (r, burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_mp_enqueue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_mp_enqueue_bulk (r, burst, + bulk_sizes[sz],NULL );rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[sz]); }const uint64_t mc_end =rte_rdtsc ();
test/test/test_table_ports.c +2 -2
@@ -80,7 +80,7 @@ test_port_ring_reader(void) mbuf[0 ] = (void *)rte_pktmbuf_alloc (pool); expected_pkts =rte_ring_sp_enqueue_burst (port_ring_reader_params.ring, - mbuf,1 ); + mbuf,1 ,NULL ); received_pkts = rte_port_ring_reader_ops.f_rx (port, res_mbuf,1 );if (received_pkts < expected_pkts)
@@ -93,7 +93,7 @@ test_port_ring_reader(void) mbuf[i] =rte_pktmbuf_alloc (pool); expected_pkts =rte_ring_sp_enqueue_burst (port_ring_reader_params.ring, - (void *const *) mbuf,RTE_PORT_IN_BURST_SIZE_MAX ); + (void *const *) mbuf,RTE_PORT_IN_BURST_SIZE_MAX ,NULL ); received_pkts = rte_port_ring_reader_ops.f_rx (port, res_mbuf,RTE_PORT_IN_BURST_SIZE_MAX );
test/test/virtual_pmd.c +2 -2
@@ -380,7 +380,7 @@ virtual_ethdev_tx_burst_success(void *queue, struct rte_mbuf **bufs, nb_pkts =0 ; else nb_pkts =rte_ring_enqueue_burst (dev_private->tx_queue, (void **)bufs, - nb_pkts); + nb_pkts,NULL );/* increment opacket count */ dev_private->eth_stats.opackets += nb_pkts;
@@ -496,7 +496,7 @@ virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, vrtl_eth_dev->data->dev_private;return rte_ring_enqueue_burst (dev_private->rx_queue, (void **)pkt_burst, - burst_length); + burst_length,NULL ); }int
Signature · 1 line
2.9.3
PATCH v2 9/14 ring: allow dequeue fns to return remaining entry count
In reply to Bruce RichardsonAdd an extra parameter to the ring dequeue burst/bulk functions so that those functions can optionally return the amount of remaining objs in the ring. This information can be used by applications in a number of ways, for instance, with single-consumer queues, it provides a max dequeue size which is guaranteed to work.
--- app/pdump/main.c | 2 +- doc/guides/rel_notes/release_17_05.rst | 8 ++ drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 2 +- examples/distributor/main.c | 2 +- examples/load_balancer/runtime.c | 6 +- .../client_server_mp/mp_client/client.c | 3 +- examples/packet_ordering/main.c | 6 +- examples/qos_sched/app_thread.c | 6 +- examples/quota_watermark/qw/main.c | 5 +- examples/server_node_efd/node/node.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 3 +- lib/librte_mempool/rte_mempool_ring.c | 4 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ring.c | 6 +- lib/librte_ring/rte_ring.h | 90 +++++++++++----------- test/test-pipeline/runtime.c | 6 +- test/test/test_link_bonding_mode4.c | 3 +- test/test/test_pmd_ring_perf.c | 7 +- test/test/test_ring.c | 54 ++++++------- test/test/test_ring_perf.c | 20 +++-- test/test/test_table_acl.c | 2 +- test/test/test_table_pipeline.c | 2 +- test/test/test_table_ports.c | 8 +- test/test/virtual_pmd.c | 4 +- 26 files changed, 145 insertions(+), 114 deletions(-)
app/pdump/main.c +1 -1
@@ -496,7 +496,7 @@ pdump_rxtx(struct rte_ring *ring, uint8_t vdev_id, struct pdump_stats *stats)/* first dequeue packets from ring of primary process */ const uint16_t nb_in_deq =rte_ring_dequeue_burst (ring, - (void *)rxtx_bufs,BURST_SIZE ); + (void *)rxtx_bufs,BURST_SIZE ,NULL ); stats->dequeue_pkts += nb_in_deq;if (nb_in_deq) {
doc/guides/rel_notes/release_17_05.rst +8 -0
@@ -123,6 +123,8 @@ API Changes * added an extra parameter to the burst/bulk enqueue functions to return the number of free spaces in the ring after enqueue. This can be used by an application to implement its own watermark functionality. + * added an extra parameter to the burst/bulk dequeue functions to return + the number elements remaining in the ring after dequeue. * changed the return value of the enqueue and dequeue bulk functions to match that of the burst equivalents. In all cases, ring functions which operate on multiple packets now return the number of elements enqueued
@@ -135,6 +137,12 @@ API Changes - ``rte_ring_sc_dequeue_bulk`` - ``rte_ring_dequeue_bulk`` + NOTE: the above functions all have different parameters as well as + different return values, due to the other listed changes above. This + means that all instances of the functions in existing code will be + flagged by the compiler. The return value usage should be checked + while fixing the compiler error due to the extra parameter. + ABI Changes -----------
drivers/crypto/null/null_crypto_pmd.c +1 -1
@@ -155,7 +155,7 @@ null_crypto_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_pkts, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/net/bonding/rte_eth_bond_pmd.c +2 -1
@@ -1008,7 +1008,8 @@ bond_ethdev_tx_burst_8023ad(void *queue, struct rte_mbuf **bufs,struct port *port = &mode_8023ad_ports[slaves[i]]; slave_slow_nb_pkts[i] =rte_ring_dequeue_burst (port->tx_ring, - slow_pkts,BOND_MODE_8023AX_SLAVE_TX_PKTS ); + slow_pkts,BOND_MODE_8023AX_SLAVE_TX_PKTS , +NULL ); slave_nb_pkts[i] = slave_slow_nb_pkts[i];for (j =0 ; j < slave_slow_nb_pkts[i]; j++)
drivers/net/ring/rte_eth_ring.c +1 -1
@@ -88,7 +88,7 @@ eth_ring_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)void **ptrs = (void *)&bufs[0 ];struct ring_queue *r = q;const uint16_t nb_rx = (uint16_t )rte_ring_dequeue_burst (r->rng, - ptrs, nb_bufs); + ptrs, nb_bufs,NULL );if (r->rng->flags &RING_F_SC_DEQ ) r->rx_pkts.cnt += nb_rx;else
examples/distributor/main.c +1 -1
@@ -330,7 +330,7 @@ lcore_tx(struct rte_ring *in_r)struct rte_mbuf *bufs[BURST_SIZE ];const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, - (void *)bufs,BURST_SIZE ); + (void *)bufs,BURST_SIZE ,NULL ); app_stats.tx.dequeue_pkts += nb_rx;/* if we get no traffic, flush anything we have */
examples/load_balancer/runtime.c +4 -2
@@ -349,7 +349,8 @@ app_lcore_io_tx( ret =rte_ring_sc_dequeue_bulk ( ring, (void **) &lp->tx.mbuf_out[port].array[n_mbufs], - bsz_rd); + bsz_rd, +NULL );if (unlikely (ret ==0 ))continue ;
@@ -504,7 +505,8 @@ app_lcore_worker( ret =rte_ring_sc_dequeue_bulk ( ring_in, (void **) lp->mbuf_in.array, - bsz_rd); + bsz_rd, +NULL );if (unlikely (ret ==0 ))continue ;
examples/multi_process/client_server_mp/mp_client/client.c +2 -1
@@ -279,7 +279,8 @@ main(int argc, char *argv[])uint16_t i, rx_pkts;uint8_t port; - rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts,PKT_READ_SIZE ); + rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts, +PKT_READ_SIZE ,NULL );if (unlikely (rx_pkts ==0 )){if (need_flush)
examples/packet_ordering/main.c +3 -3
@@ -462,7 +462,7 @@ worker_thread(void *args_ptr)/* dequeue the mbufs from rx_to_workers ring */ burst_size =rte_ring_dequeue_burst (ring_in, - (void *)burst_buffer,MAX_PKTS_BURST ); + (void *)burst_buffer,MAX_PKTS_BURST ,NULL );if (unlikely (burst_size ==0 ))continue ;
@@ -510,7 +510,7 @@ send_thread(struct send_thread_args *args)/* deque the mbufs from workers_to_tx ring */ nb_dq_mbufs =rte_ring_dequeue_burst (args->ring_in, - (void *)mbufs,MAX_PKTS_BURST ); + (void *)mbufs,MAX_PKTS_BURST ,NULL );if (unlikely (nb_dq_mbufs ==0 ))continue ;
@@ -595,7 +595,7 @@ tx_thread(struct rte_ring *ring_in)/* deque the mbufs from workers_to_tx ring */ dqnum =rte_ring_dequeue_burst (ring_in, - (void *)mbufs,MAX_PKTS_BURST ); + (void *)mbufs,MAX_PKTS_BURST ,NULL );if (unlikely (dqnum ==0 ))continue ;
examples/qos_sched/app_thread.c +3 -3
@@ -179,7 +179,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, - burst_conf.qos_dequeue); + burst_conf.qos_dequeue,NULL );if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue);
@@ -218,7 +218,7 @@ app_worker_thread(struct thread_conf **confs)/* Read packet from the ring */ nb_pkt =rte_ring_sc_dequeue_burst (conf->rx_ring, (void **)mbufs, - burst_conf.ring_burst); + burst_conf.ring_burst,NULL );if (likely (nb_pkt)) {int nb_sent =rte_sched_port_enqueue (conf->sched_port, mbufs, nb_pkt);
@@ -254,7 +254,7 @@ app_mixed_thread(struct thread_conf **confs)/* Read packet from the ring */ nb_pkt =rte_ring_sc_dequeue_burst (conf->rx_ring, (void **)mbufs, - burst_conf.ring_burst); + burst_conf.ring_burst,NULL );if (likely (nb_pkt)) {int nb_sent =rte_sched_port_enqueue (conf->sched_port, mbufs, nb_pkt);
examples/quota_watermark/qw/main.c +3 -2
@@ -247,7 +247,8 @@ pipeline_stage(__attribute__((unused)) void *args) }/* Dequeue up to quota mbuf from rx */ - nb_dq_pkts =rte_ring_dequeue_burst (rx, pkts, *quota); + nb_dq_pkts =rte_ring_dequeue_burst (rx, pkts, + *quota,NULL );if (unlikely (nb_dq_pkts <0 ))continue ;
@@ -305,7 +306,7 @@ send_stage(__attribute__((unused)) void *args)/* Dequeue packets from tx and send them */ nb_dq_pkts = (uint16_t )rte_ring_dequeue_burst (tx, - (void *) tx_pkts, *quota); + (void *) tx_pkts, *quota,NULL );rte_eth_tx_burst (dest_port_id,0 , tx_pkts, nb_dq_pkts);/* TODO: Check if nb_dq_pkts == nb_tx_pkts? */
examples/server_node_efd/node/node.c +1 -1
@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) ==0 )) + rx_pkts,NULL ) ==0 )) rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE );
lib/librte_hash/rte_cuckoo_hash.c +2 -1
@@ -536,7 +536,8 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key,if (cached_free_slots->len ==0 ) {/* Need to get another burst of free slots from global ring */ n_slots =rte_ring_mc_dequeue_burst (h->free_slots, - cached_free_slots->objs,LCORE_CACHE_SIZE ); + cached_free_slots->objs, +LCORE_CACHE_SIZE ,NULL );if (n_slots ==0 )return -ENOSPC ;
lib/librte_mempool/rte_mempool_ring.c +2 -2
@@ -58,14 +58,14 @@ static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { return rte_ring_mc_dequeue_bulk(mp->pool_data, - obj_table, n) == 0 ? -ENOBUFS : 0; + obj_table, n, NULL) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { return rte_ring_sc_dequeue_bulk(mp->pool_data, - obj_table, n) == 0 ? -ENOBUFS : 0; + obj_table, n, NULL) == 0 ? -ENOBUFS : 0; } static unsigned
lib/librte_port/rte_port_frag.c +2 -1
@@ -186,7 +186,8 @@ rte_port_ring_reader_frag_rx(void *port,/* If "pkts" buffer is empty, read packet burst from ring */ if (p->n_pkts ==0 ) { p->n_pkts =rte_ring_sc_dequeue_burst (p->ring, - (void **) p->pkts,RTE_PORT_IN_BURST_SIZE_MAX ); + (void **) p->pkts,RTE_PORT_IN_BURST_SIZE_MAX , +NULL );RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD (p, p->n_pkts);if (p->n_pkts ==0 )return n_pkts_out;
lib/librte_port/rte_port_ring.c +4 -2
@@ -111,7 +111,8 @@ rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;uint32_t nb_rx; - nb_rx =rte_ring_sc_dequeue_burst (p->ring, (void **) pkts, n_pkts); + nb_rx =rte_ring_sc_dequeue_burst (p->ring, (void **) pkts, + n_pkts,NULL );RTE_PORT_RING_READER_STATS_PKTS_IN_ADD (p, nb_rx);return nb_rx;
@@ -124,7 +125,8 @@ rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts,struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;uint32_t nb_rx; - nb_rx =rte_ring_mc_dequeue_burst (p->ring, (void **) pkts, n_pkts); + nb_rx =rte_ring_mc_dequeue_burst (p->ring, (void **) pkts, + n_pkts,NULL );RTE_PORT_RING_READER_STATS_PKTS_IN_ADD (p, nb_rx);return nb_rx;
lib/librte_ring/rte_ring.h +47 -43
196 lines not on this page · raw message
test/test-pipeline/runtime.c +4 -2
@@ -121,7 +121,8 @@ app_main_loop_worker(void) { ret =rte_ring_sc_dequeue_bulk ( app.rings_rx[i], (void **) worker_mbuf->array, - app.burst_size_worker_read); + app.burst_size_worker_read, +NULL );if (ret ==0 )continue ;
@@ -151,7 +152,8 @@ app_main_loop_tx(void) { ret =rte_ring_sc_dequeue_bulk ( app.rings_tx[i], (void **) &app.mbuf_tx[i].array[n_mbufs], - app.burst_size_tx_read); + app.burst_size_tx_read, +NULL );if (ret ==0 )continue ;
test/test/test_link_bonding_mode4.c +2 -1
@@ -193,7 +193,8 @@ static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };static int slave_get_pkts (struct slave_conf *slave,struct rte_mbuf **buf,uint16_t size) { -return rte_ring_dequeue_burst (slave->tx_queue, (void **)buf, size); +return rte_ring_dequeue_burst (slave->tx_queue, (void **)buf, + size,NULL ); }/*
test/test/test_pmd_ring_perf.c +4 -3
@@ -67,7 +67,7 @@ test_empty_dequeue(void)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t sc_end =rte_rdtsc ();const uint64_t eth_start =rte_rdtsc ();
@@ -99,7 +99,7 @@ test_single_enqueue_dequeue(void)rte_compiler_barrier ();for (i =0 ; i < iterations; i++) {rte_ring_enqueue_bulk (r, &burst,1 ,NULL ); -rte_ring_dequeue_bulk (r, &burst,1 ); +rte_ring_dequeue_bulk (r, &burst,1 ,NULL ); }const uint64_t sc_end =rte_rdtsc_precise ();rte_compiler_barrier ();
@@ -133,7 +133,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_bulk (r, (void *)burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_bulk (r, (void *)burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_bulk (r, (void *)burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
test/test/test_ring.c +28 -26
197 lines not on this page · raw message
test/test/test_ring_perf.c +12 -8
@@ -152,12 +152,12 @@ test_empty_dequeue(void)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t mc_end =rte_rdtsc (); printf("SC empty dequeue: %.2F\n",
@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc ();
@@ -325,7 +325,8 @@ test_burst_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_burst (r, burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_burst (r, burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_burst (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
@@ -333,7 +334,8 @@ test_burst_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_mp_enqueue_burst (r, burst, bulk_sizes[sz],NULL ); -rte_ring_mc_dequeue_burst (r, burst, bulk_sizes[sz]); +rte_ring_mc_dequeue_burst (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t mc_end =rte_rdtsc ();
@@ -361,7 +363,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_bulk (r, burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_bulk (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
@@ -369,7 +372,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_mp_enqueue_bulk (r, burst, bulk_sizes[sz],NULL ); -rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_mc_dequeue_bulk (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t mc_end =rte_rdtsc ();
test/test/test_table_acl.c +1 -1
@@ -713,7 +713,7 @@ test_pipeline_single_filter(int expected_count)void *objs[RING_TX_SIZE ];struct rte_mbuf *mbuf; - ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ); + ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ,NULL );if (ret <=0 ) {printf ("Got no objects from ring %d - error code %d\n" , i, ret);
test/test/test_table_pipeline.c +1 -1
@@ -494,7 +494,7 @@ test_pipeline_single_filter(int test_type, int expected_count)void *objs[RING_TX_SIZE ];struct rte_mbuf *mbuf; - ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ); + ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ,NULL );if (ret <=0 )printf ("Got no objects from ring %d - error code %d\n" , i, ret);
test/test/test_table_ports.c +4 -4
@@ -163,7 +163,7 @@ test_port_ring_writer(void) rte_port_ring_writer_ops.f_flush (port); expected_pkts =1 ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -7 ;
@@ -178,7 +178,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -8 ;
@@ -193,7 +193,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -8 ;
@@ -208,7 +208,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -9 ;
test/test/virtual_pmd.c +2 -2
@@ -342,7 +342,7 @@ virtual_ethdev_rx_burst_success(void *queue __rte_unused, dev_private = vrtl_eth_dev->data->dev_private; rx_count =rte_ring_dequeue_burst (dev_private->rx_queue, (void **) bufs, - nb_pkts); + nb_pkts,NULL );/* increments ipackets count */ dev_private->eth_stats.ipackets += rx_count;
@@ -508,7 +508,7 @@ virtual_ethdev_get_mbufs_from_tx_queue(uint8_t port_id, dev_private = vrtl_eth_dev->data->dev_private;return rte_ring_dequeue_burst (dev_private->tx_queue, (void **)pkt_burst, - burst_length); + burst_length,NULL ); } static uint8_t
Signature · 1 line
2.9.3
PATCH v2 10/14 examples/quota_watermark: use ring space for watermarks
In reply to Bruce RichardsonNow that the enqueue function returns the amount of space in the ring, we can use that to replace the old watermark functionality. Update the example app to do so, and re-enable it in the examples Makefile.
--- examples/Makefile | 2 +- examples/quota_watermark/qw/init.c | 5 +++-- examples/quota_watermark/qw/main.c | 16 ++++++++++------ examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 ++-- examples/quota_watermark/qwctl/qwctl.c | 2 ++ examples/quota_watermark/qwctl/qwctl.h | 1 + 7 files changed, 20 insertions(+), 11 deletions(-)
examples/Makefile +1 -1
@@ -81,7 +81,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering DIRS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ptpclient DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched -#DIRS-y += quota_watermark +DIRS-y += quota_watermark DIRS-$(CONFIG_RTE_ETHDEV_RXTX_CALLBACKS) += rxtx_callbacks DIRS-y += skeleton ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
examples/quota_watermark/qw/init.c +3 -2
@@ -140,7 +140,7 @@ void init_ring(int lcore_id, uint8_t port_id)if (ring ==NULL )rte_exit (EXIT_FAILURE ,"%s\n" ,rte_strerror (rte_errno)); -rte_ring_set_water_mark (ring,80 *RING_SIZE /100 ); + *high_watermark =80 *RING_SIZE /100 ; rings[lcore_id][port_id] = ring; }
@@ -168,10 +168,11 @@ setup_shared_variables(void)const struct rte_memzone *qw_memzone; qw_memzone =rte_memzone_reserve (QUOTA_WATERMARK_MEMZONE_NAME , -2 *sizeof (int ),rte_socket_id (),0 ); +3 *sizeof (int ),rte_socket_id (),0 );if (qw_memzone ==NULL )rte_exit (EXIT_FAILURE ,"%s\n" ,rte_strerror (rte_errno)); quota = qw_memzone->addr; low_watermark = (unsigned int *) qw_memzone->addr +1 ; + high_watermark = (unsigned int *) qw_memzone->addr +2 ; }
examples/quota_watermark/qw/main.c +10 -6
@@ -67,6 +67,7 @@ struct ether_fc_frame {int *quota;unsigned int *low_watermark; +unsigned int *high_watermark;uint8_t port_pairs[RTE_MAX_ETHPORTS ];
@@ -158,6 +159,7 @@ receive_stage(__attribute__((unused)) void *args)uint16_t nb_rx_pkts;unsigned int lcore_id; +unsigned int free;struct rte_mbuf *pkts[MAX_PKT_QUOTA ];struct rte_ring *ring;
@@ -189,13 +191,13 @@ receive_stage(__attribute__((unused)) void *args) nb_rx_pkts =rte_eth_rx_burst (port_id,0 , pkts, (uint16_t ) *quota); ret =rte_ring_enqueue_bulk (ring, (void *) pkts, - nb_rx_pkts); -if (ret == -EDQUOT ) { + nb_rx_pkts, &free); +if (RING_SIZE - free > *high_watermark) { ring_state[port_id] =RING_OVERLOADED ;send_pause_frame (port_id,1337 ); } -else if (ret == -ENOBUFS ) { +if (ret ==0 ) {/* * Return mbufs to the pool,
@@ -217,6 +219,7 @@ pipeline_stage(__attribute__((unused)) void *args)uint8_t port_id;unsigned int lcore_id, previous_lcore_id; +unsigned int free;void *pkts[MAX_PKT_QUOTA ];struct rte_ring *rx, *tx;
@@ -253,11 +256,12 @@ pipeline_stage(__attribute__((unused)) void *args)continue ;/* Enqueue them on tx */ - ret =rte_ring_enqueue_bulk (tx, pkts, nb_dq_pkts); -if (ret == -EDQUOT ) + ret =rte_ring_enqueue_bulk (tx, pkts, + nb_dq_pkts, &free); +if (RING_SIZE - free > *high_watermark) ring_state[port_id] =RING_OVERLOADED ; -else if (ret == -ENOBUFS ) { +if (ret ==0 ) {/* * Return mbufs to the pool,
examples/quota_watermark/qw/main.h +1 -0
@@ -43,6 +43,7 @@ enum ring_state {extern int *quota;extern unsigned int *low_watermark; +extern unsigned int *high_watermark;extern uint8_t port_pairs[RTE_MAX_ETHPORTS ];
examples/quota_watermark/qwctl/commands.c +2 -2
@@ -140,8 +140,8 @@ cmd_set_handler(__attribute__((unused)) void *parsed_result,else if (tokens->value >= *low_watermark *100 /RING_SIZE && tokens->value <=100 ) -rte_ring_set_water_mark (ring, - tokens->value *RING_SIZE /100 ); + *high_watermark = tokens->value * +RING_SIZE /100 ;else cmdline_printf(cl, "ring high watermark must be between %u%% and 100%%\n",
examples/quota_watermark/qwctl/qwctl.c +2 -0
@@ -55,6 +55,7 @@int *quota;unsigned int *low_watermark; +unsigned int *high_watermark; static void
@@ -68,6 +69,7 @@ setup_shared_variables(void) quota = qw_memzone->addr; low_watermark = (unsigned int *) qw_memzone->addr +1 ; + high_watermark = (unsigned int *) qw_memzone->addr +2 ; }int main (int argc,char **argv)
examples/quota_watermark/qwctl/qwctl.h +1 -0
@@ -36,5 +36,6 @@extern int *quota;extern unsigned int *low_watermark; +extern unsigned int *high_watermark;#endif /* _MAIN_H_ */
Signature · 1 line
2.9.3
PATCH v2 11/14 ring: reduce scope of local variables
In reply to Bruce RichardsonThe local variable i is only used for loop control so define it in the enqueue and dequeue blocks directly, rather than at the function level.
--- lib/librte_ring/rte_ring.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/librte_ring/rte_ring.h +2 -4
@@ -288,6 +288,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi producer enqueue functions */ #define ENQUEUE_PTRS () do { \ + unsigned int i; \ const uint32_t size = r->size; \ uint32_t idx = prod_head & mask; \ if (likely(idx + n < size)) { \
@@ -314,6 +315,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi consumer dequeue functions */ #define DEQUEUE_PTRS () do { \ + unsigned int i; \ uint32_t idx = cons_head & mask; \ const uint32_t size = r->size; \ if (likely(idx + n < size)) { \
@@ -364,7 +366,6 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t cons_tail, free_entries;const unsigned int max = n;int success; -unsigned int i;uint32_t mask = r->mask;/* move prod.head atomically */
@@ -434,7 +435,6 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, {uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries; -unsigned int i;uint32_t mask = r->mask; prod_head = r->prod.head;
@@ -498,7 +498,6 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_next, entries;const unsigned max = n;int success; -unsigned int i;uint32_t mask = r->mask;/* move cons.head atomically */
@@ -569,7 +568,6 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, {uint32_t cons_head, prod_tail;uint32_t cons_next, entries; -unsigned int i;uint32_t mask = r->mask; cons_head = r->cons.head;
Signature · 1 line
2.9.3
PATCH v2 12/14 ring: separate out head index manipulation for enq/deq
In reply to Bruce RichardsonWe can write a single common function for head manipulation for enq and a common one for deq, allowing us to have a single worker function for enq and deq, rather than two of each. Update all other inline functions to use the new functions.
--- lib/librte_ring/rte_ring.c | 4 +- lib/librte_ring/rte_ring.h | 328 ++++++++++++++++++++------------------------- 2 files changed, 149 insertions(+), 183 deletions(-)
lib/librte_ring/rte_ring.c +2 -2
@@ -138,8 +138,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->prod.sp_enqueue = !!(flags &RING_F_SP_ENQ ); - r->cons.sc_dequeue = !!(flags &RING_F_SC_DEQ ); + r->prod.sp_enqueue = (flags &RING_F_SP_ENQ ) ? __IS_SP : __IS_MP; + r->cons.sc_dequeue = (flags &RING_F_SC_DEQ ) ? __IS_SC : __IS_MC; r->size = count; r->mask = count -1 ; r->prod.head = r->cons.head =0 ;
lib/librte_ring/rte_ring.h +147 -181
528 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v2 13/14 ring: create common function for updating tail idx
In reply to Bruce RichardsonBoth producer and consumer use the same logic for updating the tail index so merge into a single function.
--- lib/librte_ring/rte_ring.h | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
lib/librte_ring/rte_ring.h +15 -17
@@ -344,6 +344,19 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r); } \ }while (0 ) +static inline __attribute__((always_inline)) void +update_tail (struct rte_ring_headtail *ht,uint32_t old_val,uint32_t new_val) +{ +/* +* If there are other enqueues/dequeues in progress that preceded us, +* we need to wait for them to complete +*/ +while (unlikely (ht->tail != old_val)) +rte_pause (); + + ht->tail = new_val; +} +/** * @internal This function updates the producer head for enqueue *
@@ -443,15 +456,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,ENQUEUE_PTRS ();rte_smp_wmb (); -/* -* If there are other enqueues in progress that preceded us, -* we need to wait for them to complete -*/ -while (unlikely (r->prod.tail != prod_head)) -rte_pause (); - - r->prod.tail = prod_next; - +update_tail (&r->prod, prod_head, prod_next); end:if (free_space !=NULL ) *free_space = free_entries - n;
@@ -556,14 +561,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,DEQUEUE_PTRS ();rte_smp_rmb (); -/* -* If there are other enqueues in progress that preceded us, -* we need to wait for them to complete -*/ -while (unlikely (r->cons.tail != cons_head)) -rte_pause (); - - r->cons.tail = cons_next; +update_tail (&r->cons, cons_head, cons_next); end:if (available !=NULL )
Signature · 1 line
2.9.3
PATCH v2 14/14 ring: make ring struct and enq/deq macros type agnostic
In reply to Bruce RichardsonModify the enqueue and dequeue macros to support copying any type of object by passing in the exact object type. Rather than using the "ring" structure member of rte_ring, which is of type "array of void *", instead have the macros take the start of the ring a a pointer value, thereby leaving the rte_ring structure as purely a header value. This allows it to be reused by other future ring types which can add on extra fields if they want, or even to have the actual ring elements, of whatever type stored separate from the ring header.
--- lib/librte_ring/rte_ring.h | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-)
lib/librte_ring/rte_ring.h +36 -32
@@ -162,11 +162,7 @@ struct rte_ring {/** Ring consumer status. */ struct rte_ring_headtail cons __rte_aligned(CONS_ALIGN); - - void *ring[] __rte_cache_aligned; /**< Memory space of ring starts here. -* not volatile so need to be careful -* about compiler re-ordering */ -}; +} __rte_cache_aligned;#define RING_F_SP_ENQ 0x0001/**< The default enqueue is "single-producer". */ #define RING_F_SC_DEQ 0x0002/**< The default dequeue is "single-consumer". */
@@ -293,54 +289,62 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);/* the actual enqueue of pointers on the ring. * Placed here since identical code needed in both * single and multi producer enqueue functions */ -#define ENQUEUE_PTRS () do { \ +#define ENQUEUE_PTRS (r, ring_start, prod_head, obj_table, n, obj_type) do { \ unsigned int i; \ - const uint32_t size = r->size; \ - uint32_t idx = prod_head & r->mask; \ + const uint32_t size = (r)->size; \ + uint32_t idx = prod_head & (r)->mask; \ + obj_type *ring = (void *)ring_start; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \ - r->ring[idx] = obj_table[i]; \ - r->ring[idx+1] = obj_table[i+1]; \ - r->ring[idx+2] = obj_table[i+2]; \ - r->ring[idx+3] = obj_table[i+3]; \ + ring[idx] = obj_table[i]; \ + ring[idx+1] = obj_table[i+1]; \ + ring[idx+2] = obj_table[i+2]; \ + ring[idx+3] = obj_table[i+3]; \ } \ switch (n & 0x3) { \ - case 3: r->ring[idx++] = obj_table[i++]; \ - case 2: r->ring[idx++] = obj_table[i++]; \ - case 1: r->ring[idx++] = obj_table[i++]; \ + case 3: \ + ring[idx++] = obj_table[i++];/* fallthrough */ \ +case 2 : \ + ring[idx++] = obj_table[i++];/* fallthrough */ \ +case 1 : \ + ring[idx++] = obj_table[i++]; \ } \ } else { \for (i =0 ; idx < size; i++, idx++)\ - r->ring[idx] = obj_table[i]; \ + ring[idx] = obj_table[i]; \for (idx =0 ; i < n; i++, idx++) \ - r->ring[idx] = obj_table[i]; \ + ring[idx] = obj_table[i]; \ } \ -} while(0) +} while (0)/* the actual copy of pointers on the ring to obj_table. * Placed here since identical code needed in both * single and multi consumer dequeue functions */ -#define DEQUEUE_PTRS () do { \ +#define DEQUEUE_PTRS (r, ring_start, cons_head, obj_table, n, obj_type) do { \ unsigned int i; \ - uint32_t idx = cons_head & r->mask; \ - const uint32_t size = r->size; \ + uint32_t idx = cons_head & (r)->mask; \ + const uint32_t size = (r)->size; \ + obj_type *ring = (void *)ring_start; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\ - obj_table[i] = r->ring[idx]; \ - obj_table[i+1] = r->ring[idx+1]; \ - obj_table[i+2] = r->ring[idx+2]; \ - obj_table[i+3] = r->ring[idx+3]; \ + obj_table[i] = ring[idx]; \ + obj_table[i+1] = ring[idx+1]; \ + obj_table[i+2] = ring[idx+2]; \ + obj_table[i+3] = ring[idx+3]; \ } \ switch (n & 0x3) { \ - case 3: obj_table[i++] = r->ring[idx++]; \ - case 2: obj_table[i++] = r->ring[idx++]; \ - case 1: obj_table[i++] = r->ring[idx++]; \ + case 3: \ + obj_table[i++] = ring[idx++];/* fallthrough */ \ +case 2 : \ + obj_table[i++] = ring[idx++];/* fallthrough */ \ +case 1 : \ + obj_table[i++] = ring[idx++]; \ } \ } else { \for (i =0 ; idx < size; i++, idx++) \ - obj_table[i] = r->ring[idx]; \ + obj_table[i] = ring[idx]; \for (idx =0 ; i < n; i++, idx++) \ - obj_table[i] = r->ring[idx]; \ + obj_table[i] = ring[idx]; \ } \ } while (0)
@@ -453,7 +457,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,if (n ==0 ) goto end; -ENQUEUE_PTRS (); + ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);rte_smp_wmb ();update_tail (&r->prod, prod_head, prod_next);
@@ -558,7 +562,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,if (n ==0 ) goto end; -DEQUEUE_PTRS (); + DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n, void *);rte_smp_rmb ();update_tail (&r->cons, cons_head, cons_next);
Signature · 1 line
2.9.3
Re: [PATCH v2 07/14] ring: make bulk and burst fn return vals consistent
In reply to Bruce RichardsonQuoted 7 lines · Bruce Richardson
The bulk fns for rings returns 0 for all elements enqueued and negative for no space. Change that to make them consistent with the burst functions in returning the number of elements enqueued/dequeued, i.e. 0 or N. This change also allows the return value from enq/deq to be used directly without a branch for error checking.
Signed-off-by Bruce Richardson <[email protected]>
[...]
lib/librte_ring/rte_ring.h rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table, · line 701
Quoted 9 lines
lib/librte_ring/rte_ring.h +1
-1@@ -716,7 +695,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table,static inline int __attribute__((always_inline))rte_ring_mp_enqueue (struct rte_ring *r,void *obj) { -return rte_ring_mp_enqueue_bulk (r, &obj,1 ); +return rte_ring_mp_enqueue_bulk (r, &obj,1 ) ?0 : -ENOBUFS ; }/**
I'm wondering if these functions (enqueue/dequeue of one element) should be modified to return 0 (fail) or 1 (success) too, for consistency with the bulk functions.
Any opinion?
Olivier
Re: [PATCH v1 12/14] ring: separate out head index manipulation for enq/deq
In reply to Bruce RichardsonQuoted 11 lines · Bruce Richardson
We can write a single common function for head manipulation for enq and a common one for deq, allowing us to have a single worker function for enq and deq, rather than two of each. Update all other inline functions to use the new functions.
Signed-off-by Bruce Richardson <[email protected]>--- lib/librte_ring/rte_ring.c | 4 +- lib/librte_ring/rte_ring.h | 328 ++++++++++++++++++++------------------------- 2 files changed, 149 insertions(+), 183 deletions(-)
[...]
Quoted 33 lines
lib/librte_ring/rte_ring.h +8
-20+static inline __attribute__((always_inline))unsigned int +__rte_ring_do_enqueue (struct rte_ring *r,void *const *obj_table, +unsigned int n,enum rte_ring_queue_behavior behavior, +int is_sp,unsigned int *free_space) { -uint32_t prod_head, cons_tail; -uint32_t prod_next, free_entries; -uint32_t mask = r->mask; - - prod_head = r->prod.head; - cons_tail = r->cons.tail; -/* The subtraction is done between two unsigned 32bits value -* (the result is always modulo 32 bits even if we have -* prod_head > cons_tail). So 'free_entries' is always between 0 -* and size(ring)-1. */ - free_entries = mask + cons_tail - prod_head; - -/* check that we have enough room in ring */ -if (unlikely (n > free_entries)) - n = (behavior ==RTE_RING_QUEUE_FIXED ) ?0 : free_entries; +uint32_t prod_head, prod_next; +uint32_t free_entries; + n =__rte_ring_move_prod_head (r, is_sp, n, behavior, + &prod_head, &prod_next, &free_entries);if (n ==0 ) goto end; - - prod_next = prod_head + n; - r->prod.head = prod_next; - -/* write entries in ring */
lib/librte_ring/rte_ring.h __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table, · line 444
Quoted 10 lines
lib/librte_ring/rte_ring.h +7
-0ENQUEUE_PTRS ();rte_smp_wmb (); +/* +* If there are other enqueues in progress that preceded us, +* we need to wait for them to complete +*/ +while (unlikely (r->prod.tail != prod_head)) +rte_pause (); +
I'd say this part should not be done in case is_sp == 1. Since it is sometimes a constant arg in an inline func, it may be better to add the if (is_sp == 0).
[...]
Quoted 35 lines
lib/librte_ring/rte_ring.h +9
-21+static inline __attribute__((always_inline))unsigned int +__rte_ring_do_dequeue (struct rte_ring *r,void **obj_table,unsigned int n,enum rte_ring_queue_behavior behavior, - unsigned int *available) +int is_mp,unsigned int *available) { - uint32_t cons_head, prod_tail; -uint32_t cons_next, entries; -uint32_t mask = r->mask; - - cons_head = r->cons.head; - 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 -* cons_head > prod_tail). So 'entries' is always between 0 -* and size(ring)-1. */ - entries = prod_tail - cons_head; - -if (n > entries) - n = (behavior ==RTE_RING_QUEUE_FIXED ) ?0 : entries; - -if (unlikely (entries ==0 )) - goto end; +uint32_t cons_head, cons_next; +uint32_t entries; - cons_next = cons_head + n; - r->cons.head = cons_next; + n =__rte_ring_move_cons_head (r, is_mp, n, behavior, + &cons_head, &cons_next, &entries); +if (n ==0 ) + goto end; -/* copy in table */ DEQUEUE_PTRS ();
lib/librte_ring/rte_ring.h __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, · line 558
Quoted 10 lines
lib/librte_ring/rte_ring.h +7
-0rte_smp_rmb (); +/* +* If there are other enqueues in progress that preceded us, +* we need to wait for them to complete +*/ +while (unlikely (r->cons.tail != cons_head)) +rte_pause (); + r->cons.tail = cons_next;
Same here.
Re: [PATCH v1 12/14] ring: separate out head index manipulation for enq/deq
Quoted 63 lines · Olivier MATZ
Quoted 11 lines · Bruce Richardson
We can write a single common function for head manipulation for enq and a common one for deq, allowing us to have a single worker function for enq and deq, rather than two of each. Update all other inline functions to use the new functions.
Signed-off-by Bruce Richardson <[email protected]>--- lib/librte_ring/rte_ring.c | 4 +- lib/librte_ring/rte_ring.h | 328 ++++++++++++++++++++------------------------- 2 files changed, 149 insertions(+), 183 deletions(-)[...]
Quoted 33 lines
lib/librte_ring/rte_ring.h +8
-20+static inline __attribute__((always_inline))unsigned int +__rte_ring_do_enqueue (struct rte_ring *r,void *const *obj_table, +unsigned int n,enum rte_ring_queue_behavior behavior, +int is_sp,unsigned int *free_space) { -uint32_t prod_head, cons_tail; -uint32_t prod_next, free_entries; -uint32_t mask = r->mask; - - prod_head = r->prod.head; - cons_tail = r->cons.tail; -/* The subtraction is done between two unsigned 32bits value -* (the result is always modulo 32 bits even if we have -* prod_head > cons_tail). So 'free_entries' is always between 0 -* and size(ring)-1. */ - free_entries = mask + cons_tail - prod_head; - -/* check that we have enough room in ring */ -if (unlikely (n > free_entries)) - n = (behavior ==RTE_RING_QUEUE_FIXED ) ?0 : free_entries; +uint32_t prod_head, prod_next; +uint32_t free_entries; + n =__rte_ring_move_prod_head (r, is_sp, n, behavior, + &prod_head, &prod_next, &free_entries);if (n ==0 ) goto end; - - prod_next = prod_head + n; - r->prod.head = prod_next; - -/* write entries in ring */ lib/librte_ring/rte_ring.h __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table, · line 444
Quoted 10 lines
lib/librte_ring/rte_ring.h +7
-0ENQUEUE_PTRS ();rte_smp_wmb (); +/* +* If there are other enqueues in progress that preceded us, +* we need to wait for them to complete +*/ +while (unlikely (r->prod.tail != prod_head)) +rte_pause (); +I'd say this part should not be done in case
is_sp== 1. Since it is sometimes a constant arg in an inline func, it may be better to add the if (is_sp== 0).
Quoted 2 lines
[...]
Yes, it's an unnecessary check. However, having it in place for the sp case made no performance difference in my test, so I decided to keep the code shorter by avoiding an additional branch. If there is a performance hit I'll remove it, but I would rather not add more branches to the code in the absense of a real impact to not having them.
Regards,
/Bruce
Re: [PATCH v2 07/14] ring: make bulk and burst fn return vals consistent
In reply to Olivier MATZQuoted 19 lines · Olivier MATZ
Quoted 7 lines · Bruce Richardson
The bulk fns for rings returns 0 for all elements enqueued and negative for no space. Change that to make them consistent with the burst functions in returning the number of elements enqueued/dequeued, i.e. 0 or N. This change also allows the return value from enq/deq to be used directly without a branch for error checking.
Signed-off-by Bruce Richardson <[email protected]>[...]
Quoted 8 lines
lib/librte_ring/rte_ring.h +1
-1@@ -716,7 +695,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table,static inline int __attribute__((always_inline))rte_ring_mp_enqueue (struct rte_ring *r,void *obj) { -return rte_ring_mp_enqueue_bulk (r, &obj,1 ); +return rte_ring_mp_enqueue_bulk (r, &obj,1 ) ?0 : -ENOBUFS ; }
Quoted 8 lines
Review rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table, · line 701
Quoted 1 line
(quoted diff) +0
-0/**I'm wondering if these functions (enqueue/dequeue of one element) should be modified to return 0 (fail) or 1 (success) too, for consistency with the bulk functions.
Any opinion?
I thought about that, but I would view it as risky, unless we want to go changing the parameters to the function also, as the compiler won't flag a change in return value like that.
/Bruce
Re: [PATCH v1 12/14] ring: separate out head index manipulation for enq/deq
In reply to Bruce RichardsonQuoted 64 lines · Bruce Richardson
Quoted 63 lines · Olivier MATZ
Quoted 11 lines · Bruce Richardson
We can write a single common function for head manipulation for enq and a common one for deq, allowing us to have a single worker function for enq and deq, rather than two of each. Update all other inline functions to use the new functions.
Signed-off-by Bruce Richardson <[email protected]>--- lib/librte_ring/rte_ring.c | 4 +- lib/librte_ring/rte_ring.h | 328 ++++++++++++++++++++------------------------- 2 files changed, 149 insertions(+), 183 deletions(-)[...]
Quoted 33 lines
lib/librte_ring/rte_ring.h +8
-20+static inline __attribute__((always_inline))unsigned int +__rte_ring_do_enqueue (struct rte_ring *r,void *const *obj_table, +unsigned int n,enum rte_ring_queue_behavior behavior, +int is_sp,unsigned int *free_space) { -uint32_t prod_head, cons_tail; -uint32_t prod_next, free_entries; -uint32_t mask = r->mask; - - prod_head = r->prod.head; - cons_tail = r->cons.tail; -/* The subtraction is done between two unsigned 32bits value -* (the result is always modulo 32 bits even if we have -* prod_head > cons_tail). So 'free_entries' is always between 0 -* and size(ring)-1. */ - free_entries = mask + cons_tail - prod_head; - -/* check that we have enough room in ring */ -if (unlikely (n > free_entries)) - n = (behavior ==RTE_RING_QUEUE_FIXED ) ?0 : free_entries; +uint32_t prod_head, prod_next; +uint32_t free_entries; + n =__rte_ring_move_prod_head (r, is_sp, n, behavior, + &prod_head, &prod_next, &free_entries);if (n ==0 ) goto end; - - prod_next = prod_head + n; - r->prod.head = prod_next; - -/* write entries in ring */ lib/librte_ring/rte_ring.h __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table, · line 444
Quoted 10 lines
lib/librte_ring/rte_ring.h +7
-0ENQUEUE_PTRS ();rte_smp_wmb (); +/* +* If there are other enqueues in progress that preceded us, +* we need to wait for them to complete +*/ +while (unlikely (r->prod.tail != prod_head)) +rte_pause (); +I'd say this part should not be done in case
is_sp== 1. Since it is sometimes a constant arg in an inline func, it may be better to add the if (is_sp== 0).
Quoted 8 lines
Quoted 2 lines
[...]
Yes, it's an unnecessary check. However, having it in place for the sp case made no performance difference in my test, so I decided to keep the code shorter by avoiding an additional branch. If there is a performance hit I'll remove it, but I would rather not add more branches to the code in the absense of a real impact to not having them.
Ok.
Maybe it's worth checking the numbers given by the unit test.
Olivier
Re: [PATCH v2 07/14] ring: make bulk and burst fn return vals consistent
In reply to Bruce RichardsonQuoted 26 lines · Bruce Richardson
Quoted 25 lines · Olivier MATZ
Quoted 7 lines · Bruce Richardson
The bulk fns for rings returns 0 for all elements enqueued and negative for no space. Change that to make them consistent with the burst functions in returning the number of elements enqueued/dequeued, i.e. 0 or N. This change also allows the return value from enq/deq to be used directly without a branch for error checking.
Signed-off-by Bruce Richardson <[email protected]>[...]
lib/librte_ring/rte_ring.h rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table, · line 701
Quoted 9 lines
lib/librte_ring/rte_ring.h +1
-1@@ -716,7 +695,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table,static inline int __attribute__((always_inline))rte_ring_mp_enqueue (struct rte_ring *r,void *obj) { -return rte_ring_mp_enqueue_bulk (r, &obj,1 ); +return rte_ring_mp_enqueue_bulk (r, &obj,1 ) ?0 : -ENOBUFS ; }/** I'm wondering if these functions (enqueue/dequeue of one element) should be modified to return 0 (fail) or 1 (success) too, for consistency with the bulk functions.
Quoted 6 lines
Quoted 2 lines
Any opinion?
I thought about that, but I would view it as risky, unless we want to go changing the parameters to the function also, as the compiler won't flag a change in return value like that.
Ok, I have no better solution anyway.
Olivier
Quoted 80 lines · Bruce Richardson
NOTE: this set depends on the v2 cleanup set sent previously.
http://dpdk.org/ml/archives/dev/2017-February/thread.html#58200This patchset make a set of, sometimes non-backward compatible, cleanup changes to the
rte_ringcode in order to improve it. The resulting code is shorter, since the existing functions are restructured to reduce code duplication, as well as being more consistent in behaviour. The specific changes made are explained in each patch which makes that change.Changes in V2:
* Eliminated extra cacheline padding where cachelines are 128B
* Renamedrte_ring_ht_ptrstruct torte_ring_headtail
* Removed missed references to ring watermarks in test code and docsThis patchset is largely the same as that posted previously on-list as an RFC:
http://dpdk.org/ml/archives/dev/2017-February/thread.html#56982Changes in V1 from RFC:
* Included release notes updates as changes are made in each patch
* Fixed some missed comment updates when changing the code
* Separated some initial fixup patches from this set to send separately
* Dropped the final two patches for anrte_event_ring, as not relevant for this set. That can be done as a separate set later.
* The macros for copying the pointers have an extra parameter added, indicating the start of the ring buffer itself. This allows more flexibility for reusing them in other ring implementations.Bruce Richardson (14):
ring: remove split cacheline build setting
ring: create common structure for prod and cons metadata
ring: eliminate duplication of size and mask fields
ring: remove debug setting
ring: remove the yield when waiting for tail update
ring: remove watermark support
ring: make bulk and burst fn return vals consistent
ring: allow enqueue fns to return free space value
ring: allow dequeue fns to return remaining entry count examples/quota_watermark: use ring space for watermarks
ring: reduce scope of local variables
ring: separate out head index manipulation for enq/deq
ring: create common function for updating tail idx
ring: make ring struct and enq/deq macros type agnosticapp/pdump/main.c | 2 +- config/common_base | 3 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 - doc/guides/prog_guide/ring_lib.rst | 15 - doc/guides/rel_notes/release_17_05.rst | 32 + doc/guides/sample_app_ug/server_node_efd.rst | 2 +- drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 4 +- examples/distributor/main.c | 5 +- examples/load_balancer/runtime.c | 34 +- .../client_server_mp/mp_client/client.c | 9 +- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 13 +- examples/qos_sched/app_thread.c | 14 +- examples/quota_watermark/qw/init.c | 5 +- examples/quota_watermark/qw/main.c | 21 +- examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 +- examples/quota_watermark/qwctl/qwctl.c | 2 + examples/quota_watermark/qwctl/qwctl.h | 1 + examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 5 +- lib/librte_mempool/rte_mempool_ring.c | 12 +- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 34 +- lib/librte_ring/rte_ring.c | 76 +-- lib/librte_ring/rte_ring.h | 760 ++++++++------------- test/test-pipeline/pipeline_hash.c | 5 +- test/test-pipeline/runtime.c | 19 +- test/test/autotest_test_funcs.py | 7 - test/test/commands.c | 52 -- test/test/test_link_bonding_mode4.c | 6 +-
Quoted 9 lines
test/test/test_pmd_ring_perf.c | 12 +- test/test/test_ring.c | 704 +++---------------- test/test/test_ring_perf.c | 36 +- test/test/test_table_acl.c | 2 +- test/test/test_table_pipeline.c | 2 +- test/test/test_table_ports.c | 12 +- test/test/virtual_pmd.c | 8 +- 43 files changed, 554 insertions(+), 1388 deletions(-)
Series
Thanks!
Re: [PATCH v2 02/14] ring: create common structure for prod and cons metadata
In reply to Bruce Richardsonclang error below:
2017-03-07 11:32, Bruce Richardson:
lib/librte_ring/rte_ring.h struct rte_memzone; /* forward declaration, so as not to require memzone.h */ · line 159
Quoted 4 lines
lib/librte_ring/rte_ring.h +4
-0+union { +uint32_t sp_enqueue;/**< True, if single producer. */ +uint32_t sc_dequeue;/**< True, if single consumer. */ + };
error: anonymous unions are a C11 extension
Re: [PATCH v2 02/14] ring: create common structure for prod and cons metadata
Quoted 9 lines · Thomas Monjalon
clang error below:
2017-03-07 11:32, Bruce Richardson:
lib/librte_ring/rte_ring.h struct rte_memzone; /* forward declaration, so as not to require memzone.h */ · line 159
Quoted 4 lines
lib/librte_ring/rte_ring.h +4
-0+union { +uint32_t sp_enqueue;/**< True, if single producer. */ +uint32_t sc_dequeue;/**< True, if single consumer. */ + };error: anonymous unions are a C11 extension
What clang version and other CFLAGS settings are you using? Clang compilation runs fine for me with clang 3.9.1 on Fedora 25.
/Bruce
Re: [PATCH v2 02/14] ring: create common structure for prod and cons metadata
In reply to Thomas MonjalonQuoted 9 lines · Thomas Monjalon
clang error below:
2017-03-07 11:32, Bruce Richardson:
lib/librte_ring/rte_ring.h struct rte_memzone; /* forward declaration, so as not to require memzone.h */ · line 159
Quoted 4 lines
lib/librte_ring/rte_ring.h +4
-0+union { +uint32_t sp_enqueue;/**< True, if single producer. */ +uint32_t sc_dequeue;/**< True, if single consumer. */ + };error: anonymous unions are a C11 extension
Olivier, Thomas, feedback on suggestions for fixing this? Note: I'm still waiting to hear back on what compiler settings are needed to trigger this error.
Two immediately obvious options:
* replace the union with a single variable called e.g. "single", i.e. prod.single indicates single producer, and cons.single indicates single consumer. The downside of this approach is that it makes the patch a little bigger - as other code needs to be modified to use the new name - and is not backward compatible for apps which may reference this public structure memeber.
* just remove the union without renaming anything, leaving two structure members called sp_enqueue and sc_dequeue. This uses a little more space in the structure, which is not a big deal since it needs to fill a cacheline anyway, but it is backward compatible in that no other code should need to be modified.
Other options? My preference is for the first one. Given we are breaking the ring API anyway, I think we might as well use the shorter name and eliminate the need for the union, or multiple variables.
/Bruce
Re: [PATCH v2 02/14] ring: create common structure for prod and cons metadata
Hi Bruce,
Quoted 28 lines · Bruce Richardson
Quoted 9 lines · Thomas Monjalon
clang error below:
2017-03-07 11:32, Bruce Richardson:
lib/librte_ring/rte_ring.h struct rte_memzone; /* forward declaration, so as not to require memzone.h */ · line 159
Quoted 4 lines
lib/librte_ring/rte_ring.h +4
-0+union { +uint32_t sp_enqueue;/**< True, if single producer. */ +uint32_t sc_dequeue;/**< True, if single consumer. */ + };error: anonymous unions are a C11 extension
Olivier, Thomas, feedback on suggestions for fixing this? Note: I'm still waiting to hear back on what compiler settings are needed to trigger this error.
Two immediately obvious options:
* replace the union with a single variable called e.g. "single", i.e. prod.single indicates single producer, and cons.single indicates single consumer. The downside of this approach is that it makes the patch a little bigger - as other code needs to be modified to use the new name - and is not backward compatible for apps which may reference this public structure memeber.
* just remove the union without renaming anything, leaving two structure members calledsp_enqueueandsc_dequeue. This uses a little more space in the structure, which is not a big deal since it needs to fill a cacheline anyway, but it is backward compatible in that no other code should need to be modified.
Quoted 3 lines
Other options? My preference is for the first one. Given we are breaking the ring API anyway, I think we might as well use the shorter name and eliminate the need for the union, or multiple variables.
What about adding RTE_STD_C11 like it's done in rte_mbuf?
I didn't try, but since mbuf compiles, it should solve this issue in ring.
Regards,
Olivier
Re: [PATCH v2 02/14] ring: create common structure for prod and cons metadata
Quoted 31 lines · Olivier Matz
Hi Bruce,
Quoted 28 lines · Bruce Richardson
Quoted 9 lines · Thomas Monjalon
clang error below:
2017-03-07 11:32, Bruce Richardson:
lib/librte_ring/rte_ring.h struct rte_memzone; /* forward declaration, so as not to require memzone.h */ · line 159
Quoted 4 lines
lib/librte_ring/rte_ring.h +4
-0+union { +uint32_t sp_enqueue;/**< True, if single producer. */ +uint32_t sc_dequeue;/**< True, if single consumer. */ + };error: anonymous unions are a C11 extension
Olivier, Thomas, feedback on suggestions for fixing this? Note: I'm still waiting to hear back on what compiler settings are needed to trigger this error.
Two immediately obvious options:
* replace the union with a single variable called e.g. "single", i.e. prod.single indicates single producer, and cons.single indicates single consumer. The downside of this approach is that it makes the patch a little bigger - as other code needs to be modified to use the new name - and is not backward compatible for apps which may reference this public structure memeber.
* just remove the union without renaming anything, leaving two structure members calledsp_enqueueandsc_dequeue. This uses a little more space in the structure, which is not a big deal since it needs to fill a cacheline anyway, but it is backward compatible in that no other code should need to be modified.
Quoted 8 lines
Quoted 3 lines
Other options? My preference is for the first one. Given we are breaking the ring API anyway, I think we might as well use the shorter name and eliminate the need for the union, or multiple variables.
What about adding
RTE_STD_C11like it's done inrte_mbuf?I didn't try, but since mbuf compiles, it should solve this issue in ring.
Yes, it might well. However, looking at the resulting code, I actually think it's cleaner to have just one variable called "single" in the structure. The union is really for backward compatibility, and there is little point in doing so since we are changing the rest of the structure in other ways.
Struct now looks like:
/* structure to hold a pair of head/tail values and other metadata */ struct rte_ring_headtail {
volatile uint32_t head; /**< Prod/consumer head. */
volatile uint32_t tail; /**< Prod/consumer tail. */
uint32_t single; /**< True if single prod/cons */};
And the code checks read e.g. for single producer:
if (r->prod.single)
/Bruce
v3 cover refactor and cleanup of rte_ring
In reply to Bruce RichardsonThis patchset make a set of, sometimes non-backward compatible, cleanup changes to the rte_ring code in order to improve it. The resulting code is shorter, since the existing functions are restructured to reduce code duplication, as well as being more consistent in behaviour. The specific changes made are explained in each patch which makes that change.
Changes in V3:
* removed anonymous union for sp_enqueue and sc_dequeue variables (p2)
* fixed parameter to dequeue function which was mistakenly named is_mp instead of is_sc (as described in the comments) (p12)
* skipped unneeded check in tail pointer update fn for sp/sc operation (p13)
Changes in V2:
* Eliminated extra cacheline padding where cachelines are 128B
* Renamed rte_ring_ht_ptr struct to rte_ring_headtail
* Removed missed references to ring watermarks in test code and docs
This patchset is largely the same as that posted previously on-list as an RFC:
http://dpdk.org/ml/archives/dev/2017-February/thread.html#56982
Changes in V1 from RFC:
* Included release notes updates as changes are made in each patch
* Fixed some missed comment updates when changing the code
* Separated some initial fixup patches from this set to send separately
* Dropped the final two patches for an rte_event_ring, as not relevant for this set. That can be done as a separate set later.
* The macros for copying the pointers have an extra parameter added, indicating the start of the ring buffer itself. This allows more flexibility for reusing them in other ring implementations.
Bruce Richardson (14):
ring: remove split cacheline build setting
ring: create common structure for prod and cons metadata
ring: eliminate duplication of size and mask fields
ring: remove debug setting
ring: remove the yield when waiting for tail update
ring: remove watermark support
ring: make bulk and burst fn return vals consistent
ring: allow enqueue fns to return free space value
ring: allow dequeue fns to return remaining entry count examples/quota_watermark: use ring space for watermarks
ring: reduce scope of local variables
ring: separate out head index manipulation for enq/deq
ring: create common function for updating tail idx
ring: make ring struct and enq/deq macros type agnostic
app/pdump/main.c | 2 +- config/common_base | 3 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 - doc/guides/prog_guide/ring_lib.rst | 15 - doc/guides/rel_notes/release_17_05.rst | 33 + doc/guides/sample_app_ug/server_node_efd.rst | 2 +- drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 4 +- examples/distributor/main.c | 5 +- examples/load_balancer/runtime.c | 34 +- .../client_server_mp/mp_client/client.c | 9 +- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 13 +- examples/qos_sched/app_thread.c | 14 +- examples/quota_watermark/qw/init.c | 5 +- examples/quota_watermark/qw/main.c | 21 +- examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 +- examples/quota_watermark/qwctl/qwctl.c | 2 + examples/quota_watermark/qwctl/qwctl.h | 1 + examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 5 +- lib/librte_mempool/rte_mempool_ring.c | 12 +- lib/librte_pdump/rte_pdump.c | 4 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 46 +- lib/librte_ring/rte_ring.c | 76 +-- lib/librte_ring/rte_ring.h | 759 ++++++++------------- test/test-pipeline/pipeline_hash.c | 5 +- test/test-pipeline/runtime.c | 19 +- test/test/autotest_test_funcs.py | 7 - test/test/commands.c | 52 -- test/test/test_link_bonding_mode4.c | 6 +- test/test/test_pmd_ring_perf.c | 12 +- test/test/test_ring.c | 704 +++---------------- test/test/test_ring_perf.c | 36 +- test/test/test_table_acl.c | 2 +- test/test/test_table_pipeline.c | 2 +- test/test/test_table_ports.c | 12 +- test/test/virtual_pmd.c | 8 +- 43 files changed, 561 insertions(+), 1395 deletions(-)
Signature · 1 line
2.9.3
PATCH v3 1/14 ring: remove split cacheline build setting
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the rte_ring structure. Therefore just remove the build option and set the structures to be always split. On platforms with 64B cachelines, for improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.
---
V2: Limit the cacheline * 2 alignment to platforms with < 128B line size
--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 7 +++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 16 ++++++++++------ 4 files changed, 17 insertions(+), 9 deletions(-)
config/common_base +0 -1
@@ -453,7 +453,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #
doc/guides/rel_notes/release_17_05.rst +7 -0
@@ -120,6 +120,13 @@ API Changes * The LPM ``next_hop`` field is extended from 8 bits to 21 bits for IPv6 while keeping ABI compatibility. +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` + ABI Changes -----------
lib/librte_ring/rte_ring.c +0 -2
@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG
lib/librte_ring/rte_ring.h +10 -6
@@ -139,6 +139,14 @@ struct rte_ring_debug_stats {struct rte_memzone ;/* forward declaration, so as not to require memzone.h */ +#if RTE_CACHE_LINE_SIZE <128 +#define PROD_ALIGN (RTE_CACHE_LINE_SIZE * 2) +#define CONS_ALIGN (RTE_CACHE_LINE_SIZE * 2) +#else +#define PROD_ALIGN RTE_CACHE_LINE_SIZE +#define CONS_ALIGN RTE_CACHE_LINE_SIZE +#endif +/** * An RTE ring structure. *
@@ -168,7 +176,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + }prod __rte_aligned (PROD_ALIGN );/** Ring consumer status. */ struct cons {
@@ -177,11 +185,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Consumer head. */ volatile uint32_t tail;/**< Consumer tail. */ -#ifdef RTE_RING_SPLIT_PROD_CONS - }cons __rte_cache_aligned; -#else - } cons; -#endif + }cons __rte_aligned (CONS_ALIGN );#ifdef RTE_LIBRTE_RING_DEBUG struct rte_ring_debug_stats stats[RTE_MAX_LCORE ];
Signature · 1 line
2.9.3
PATCH v3 2/14 ring: create common structure for prod and cons metadata
In reply to Bruce Richardsoncreate a common structure to hold the metadata for the producer and the consumer, since both need essentially the same information - the head and tail values, the ring size and mask.
---
V3: removed union and replaced with "single" variable
V2: renamed the shared structure based on maintainer feedback.
--- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_ring.c | 12 ++++++------ lib/librte_ring/rte_ring.c | 4 ++-- lib/librte_ring/rte_ring.h | 41 +++++++++++++++++++---------------------- 4 files changed, 28 insertions(+), 31 deletions(-)
lib/librte_pdump/rte_pdump.c +1 -1
@@ -740,7 +740,7 @@ pdump_validate_ring_mp(struct rte_ring *ring, struct rte_mempool *mp) rte_errno =EINVAL ;return -1 ; } -if (ring->prod.sp_enqueue || ring->cons.sc_dequeue) { +if (ring->prod.single || ring->cons.single) {RTE_LOG (ERR ,PDUMP ,"ring with either SP or SC settings" " is not valid for pdump, should have MP and MC settings\n" ); rte_errno =EINVAL ;
lib/librte_port/rte_port_ring.c +6 -6
@@ -73,8 +73,8 @@ rte_port_ring_reader_create_internal(void *params, int socket_id,/* Check input parameters */ if ((conf ==NULL ) || (conf->ring ==NULL ) || - (conf->ring->cons.sc_dequeue && is_multi) || - (!(conf->ring->cons.sc_dequeue) && !is_multi)) { + (conf->ring->cons.single && is_multi) || + (!(conf->ring->cons.single) && !is_multi)) {RTE_LOG (ERR ,PORT ,"%s: Invalid Parameters\n" , __func__);return NULL ; }
@@ -198,8 +198,8 @@ rte_port_ring_writer_create_internal(void *params, int socket_id,/* Check input parameters */ if ((conf ==NULL ) || (conf->ring ==NULL ) || - (conf->ring->prod.sp_enqueue && is_multi) || - (!(conf->ring->prod.sp_enqueue) && !is_multi) || + (conf->ring->prod.single && is_multi) || + (!(conf->ring->prod.single) && !is_multi) || (conf->tx_burst_sz >RTE_PORT_IN_BURST_SIZE_MAX )) {RTE_LOG (ERR ,PORT ,"%s: Invalid Parameters\n" , __func__);return NULL ;
@@ -467,8 +467,8 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id,/* Check input parameters */ if ((conf ==NULL ) || (conf->ring ==NULL ) || - (conf->ring->prod.sp_enqueue && is_multi) || - (!(conf->ring->prod.sp_enqueue) && !is_multi) || + (conf->ring->prod.single && is_multi) || + (!(conf->ring->prod.single) && !is_multi) || (conf->tx_burst_sz >RTE_PORT_IN_BURST_SIZE_MAX )) {RTE_LOG (ERR ,PORT ,"%s: Invalid Parameters\n" , __func__);return NULL ;
lib/librte_ring/rte_ring.c +2 -2
@@ -145,8 +145,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,return -ENAMETOOLONG ; r->flags = flags; r->prod.watermark = count; - r->prod.sp_enqueue = !!(flags &RING_F_SP_ENQ ); - r->cons.sc_dequeue = !!(flags &RING_F_SC_DEQ ); + r->prod.single = !!(flags &RING_F_SP_ENQ ); + r->cons.single = !!(flags &RING_F_SC_DEQ ); r->prod.size = r->cons.size = count; r->prod.mask = r->cons.mask = count-1 ; r->prod.head = r->cons.head =0 ;
lib/librte_ring/rte_ring.h +19 -22
97 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v3 3/14 ring: eliminate duplication of size and mask fields
In reply to Bruce RichardsonThe size and mask fields are duplicated in both the producer and consumer data structures. Move them out of that into the top level structure so they are not duplicated.
--- lib/librte_ring/rte_ring.c | 20 ++++++++++---------- lib/librte_ring/rte_ring.h | 32 ++++++++++++++++---------------- test/test/test_ring.c | 6 +++--- 3 files changed, 29 insertions(+), 29 deletions(-)
lib/librte_ring/rte_ring.c +10 -10
@@ -144,11 +144,11 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->prod.watermark = count; + r->watermark = count; r->prod.single = !!(flags &RING_F_SP_ENQ ); r->cons.single = !!(flags &RING_F_SC_DEQ ); - r->prod.size = r->cons.size = count; - r->prod.mask = r->cons.mask = count-1 ; + r->size = count; + r->mask = count -1 ; r->prod.head = r->cons.head =0 ; r->prod.tail = r->cons.tail =0 ;
@@ -269,14 +269,14 @@ rte_ring_free(struct rte_ring *r)int rte_ring_set_water_mark (struct rte_ring *r,unsigned count) { -if (count >= r->prod.size) +if (count >= r->size)return -EINVAL ;/* if count is 0, disable the watermarking */ if (count ==0 ) - count = r->prod.size; + count = r->size; - r->prod.watermark = count; + r->watermark = count;return 0 ; }
@@ -291,17 +291,17 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)fprintf (f,"ring <%s>@%p\n" , r->name, r);fprintf (f," flags=%x\n" , r->flags); -fprintf (f," size=%" PRIu32"\n" , r->prod.size); +fprintf (f," size=%" PRIu32"\n" , r->size);fprintf (f," ct=%" PRIu32"\n" , r->cons.tail);fprintf (f," ch=%" PRIu32"\n" , r->cons.head);fprintf (f," pt=%" PRIu32"\n" , r->prod.tail);fprintf (f," ph=%" PRIu32"\n" , r->prod.head);fprintf (f," used=%u\n" ,rte_ring_count (r));fprintf (f," avail=%u\n" ,rte_ring_free_count (r)); -if (r->prod.watermark == r->prod.size) +if (r->watermark == r->size)fprintf (f," watermark=0\n" );else -fprintf (f," watermark=%" PRIu32"\n" , r->prod.watermark); +fprintf (f," watermark=%" PRIu32"\n" , r->watermark);/* sum and dump statistics */ #ifdef RTE_LIBRTE_RING_DEBUG
@@ -318,7 +318,7 @@ rte_ring_dump(FILE *f, const struct rte_ring *r) sum.deq_fail_bulk += r->stats[lcore_id].deq_fail_bulk; sum.deq_fail_objs += r->stats[lcore_id].deq_fail_objs; } -fprintf (f," size=%" PRIu32"\n" , r->prod.size); +fprintf (f," size=%" PRIu32"\n" , r->size);fprintf (f," enq_success_bulk=%" PRIu64"\n" , sum.enq_success_bulk);fprintf (f," enq_success_objs=%" PRIu64"\n" , sum.enq_success_objs);fprintf (f," enq_quota_bulk=%" PRIu64"\n" , sum.enq_quota_bulk);
lib/librte_ring/rte_ring.h +16 -16
@@ -151,10 +151,7 @@ struct rte_memzone; /* forward declaration, so as not to require memzone.h */struct rte_ring_headtail {volatile uint32_t head;/**< Prod/consumer head. */ volatile uint32_t tail;/**< Prod/consumer tail. */ -uint32_t size;/**< Size of ring. */ -uint32_t mask;/**< Mask (size-1) of ring. */ uint32_t single;/**< True if single prod/cons */ -uint32_t watermark;/**< Max items before EDQUOT in producer. */ };/**
@@ -174,9 +171,12 @@ struct rte_ring {* next time the ABI changes */ char name[RTE_MEMZONE_NAMESIZE ];/**< Name of the ring. */ -int flags;/**< Flags supplied at creation. */ +int flags;/**< Flags supplied at creation. */ const struct rte_memzone *memzone;/**< Memzone, if any, containing the rte_ring */ +uint32_t size;/**< Size of ring. */ +uint32_t mask;/**< Mask (size-1) of ring. */ +uint32_t watermark;/**< Max items before EDQUOT in producer. */ /** Ring producer status. */ struct rte_ring_headtail prod __rte_aligned(PROD_ALIGN);
@@ -355,7 +355,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi producer enqueue functions */ #define ENQUEUE_PTRS () do { \ - const uint32_t size = r->prod.size; \ + const uint32_t size = r->size; \ uint32_t idx = prod_head & mask; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
@@ -382,7 +382,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* single and multi consumer dequeue functions */ #define DEQUEUE_PTRS () do { \ uint32_t idx = cons_head & mask; \ - const uint32_t size = r->cons.size; \ + const uint32_t size = r->size; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\ obj_table[i] = r->ring[idx]; \
@@ -437,7 +437,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,const unsigned max = n;int success;unsigned i, rep =0 ; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;int ret;/* Avoid the unnecessary cmpset operation below, which is also
@@ -485,7 +485,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb ();/* if we exceed the watermark */ -if (unlikely (((mask +1 ) - free_entries + n) > r->prod.watermark)) { +if (unlikely (((mask +1 ) - free_entries + n) > r->watermark)) { ret = (behavior ==RTE_RING_QUEUE_FIXED ) ? -EDQUOT : (int )(n |RTE_RING_QUOT_EXCEED );__RING_STAT_ADD (r, enq_quota, n);
@@ -544,7 +544,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries;unsigned i; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;int ret; prod_head = r->prod.head;
@@ -580,7 +580,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb ();/* if we exceed the watermark */ -if (unlikely (((mask +1 ) - free_entries + n) > r->prod.watermark)) { +if (unlikely (((mask +1 ) - free_entries + n) > r->watermark)) { ret = (behavior ==RTE_RING_QUEUE_FIXED ) ? -EDQUOT : (int )(n |RTE_RING_QUOT_EXCEED );__RING_STAT_ADD (r, enq_quota, n);
@@ -630,7 +630,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,const unsigned max = n;int success;unsigned i, rep =0 ; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;/* Avoid the unnecessary cmpset operation below, which is also * potentially harmful when n equals 0. */
@@ -727,7 +727,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_head, prod_tail;uint32_t cons_next, entries;unsigned i; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask; cons_head = r->cons.head; prod_tail = r->prod.tail;
@@ -1056,7 +1056,7 @@ rte_ring_full(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return ((cons_tail - prod_tail -1 ) & r->prod.mask) ==0 ; +return ((cons_tail - prod_tail -1 ) & r->mask) ==0 ; }/**
@@ -1089,7 +1089,7 @@ rte_ring_count(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return (prod_tail - cons_tail) & r->prod.mask; +return (prod_tail - cons_tail) & r->mask; }/**
@@ -1105,7 +1105,7 @@ rte_ring_free_count(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return (cons_tail - prod_tail -1 ) & r->prod.mask; +return (cons_tail - prod_tail -1 ) & r->mask; }/**
@@ -1119,7 +1119,7 @@ rte_ring_free_count(const struct rte_ring *r)static inline unsigned int rte_ring_get_size (const struct rte_ring *r) { -return r->prod.size; +return r->size; }/**
test/test/test_ring.c +3 -3
@@ -148,7 +148,7 @@ check_live_watermark_change(__attribute__((unused)) void *dummy) }/* read watermark, the only change allowed is from 16 to 32 */ - watermark = r->prod.watermark; + watermark = r->watermark;if (watermark != watermark_old && (watermark_old !=16 || watermark !=32 )) { printf("Bad watermark change %u -> %u\n", watermark_old,
@@ -213,7 +213,7 @@ test_set_watermark( void ){printf (" ring lookup failed\n" ); goto error; } - count = r->prod.size*2 ; + count = r->size *2 ; setwm =rte_ring_set_water_mark (r, count);if (setwm != -EINVAL ){printf ("Test failed to detect invalid watermark count value\n" );
@@ -222,7 +222,7 @@ test_set_watermark( void ){ count =0 ;rte_ring_set_water_mark (r, count); -if (r->prod.watermark != r->prod.size) { +if (r->watermark != r->size) {printf ("Test failed to detect invalid watermark count value\n" ); goto error; }
Signature · 1 line
2.9.3
PATCH v3 4/14 ring: remove debug setting
In reply to Bruce RichardsonThe debug option only provided statistics to the user, most of which could be tracked by the application itself. Remove this as a compile time option, and feature, simplifying the code.
--- config/common_base | 1 - doc/guides/prog_guide/ring_lib.rst | 7 - doc/guides/rel_notes/release_17_05.rst | 1 + lib/librte_ring/rte_ring.c | 41 ---- lib/librte_ring/rte_ring.h | 97 +------- test/test/test_ring.c | 410 --------------------------------- 6 files changed, 13 insertions(+), 544 deletions(-)
config/common_base +0 -1
@@ -452,7 +452,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # Compile librte_ring # CONFIG_RTE_LIBRTE_RING=y -CONFIG_RTE_LIBRTE_RING_DEBUG=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #
doc/guides/prog_guide/ring_lib.rst +0 -7
@@ -110,13 +110,6 @@ Once an enqueue operation reaches the high water mark, the producer is notified, This mechanism can be used, for example, to exert a back pressure on I/O to inform the LAN to PAUSE. -Debug -~~~~~ - -When debug is enabled (CONFIG_RTE_LIBRTE_RING_DEBUG is set), -the library stores some per-ring statistic counters about the number of enqueues/dequeues. -These statistics are per-core to avoid concurrent accesses or atomic operations. - Use Cases ---------
doc/guides/rel_notes/release_17_05.rst +1 -0
@@ -126,6 +126,7 @@ API Changes have been made to it: * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` + * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` ABI Changes -----------
lib/librte_ring/rte_ring.c +0 -41
59 lines not on this page · raw message
lib/librte_ring/rte_ring.h +12 -85
183 lines not on this page · raw message
test/test/test_ring.c +0 -410
422 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v3 5/14 ring: remove the yield when waiting for tail update
In reply to Bruce RichardsonThere was a compile time setting to enable a ring to yield when it entered a loop in mp or mc rings waiting for the tail pointer update. Build time settings are not recommended for enabling/disabling features, and since this was off by default, remove it completely. If needed, a runtime enabled equivalent can be used.
--- config/common_base | 1 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 ---- doc/guides/rel_notes/release_17_05.rst | 1 + lib/librte_ring/rte_ring.h | 35 +++++-------------------- 4 files changed, 7 insertions(+), 35 deletions(-)
config/common_base +0 -1
@@ -452,7 +452,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # Compile librte_ring # CONFIG_RTE_LIBRTE_RING=y -CONFIG_RTE_RING_PAUSE_REP_COUNT=0 # # Compile librte_mempool
doc/guides/prog_guide/env_abstraction_layer.rst +0 -5
@@ -352,11 +352,6 @@ Known Issues 3. It MUST not be used by multi-producer/consumer pthreads, whose scheduling policies are SCHED_FIFO or SCHED_RR. - ``RTE_RING_PAUSE_REP_COUNT`` is defined for rte_ring to reduce contention. It's mainly for case 2, a yield is issued after number of times pause repeat. - - It adds a sched_yield() syscall if the thread spins for too long while waiting on the other thread to finish its operations on the ring. - This gives the preempted thread a chance to proceed and finish with the ring enqueue/dequeue operation. - + rte_timer Running ``rte_timer_manager()`` on a non-EAL pthread is not allowed. However, resetting/stopping the timer from a non-EAL pthread is allowed.
doc/guides/rel_notes/release_17_05.rst +1 -0
@@ -127,6 +127,7 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` + * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` ABI Changes -----------
lib/librte_ring/rte_ring.h +6 -29
@@ -114,11 +114,6 @@ enum rte_ring_queue_behavior {#define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \ sizeof(RTE_RING_MZ_PREFIX) + 1) -#ifndef RTE_RING_PAUSE_REP_COUNT -#define RTE_RING_PAUSE_REP_COUNT 0/**< Yield after pause num of times, no yield -* if RTE_RING_PAUSE_REP not defined. */ -#endif -struct rte_memzone ;/* forward declaration, so as not to require memzone.h */ #if RTE_CACHE_LINE_SIZE <128
@@ -393,7 +388,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t cons_tail, free_entries;const unsigned max = n;int success; -unsigned i, rep =0 ; +unsigned int i;uint32_t mask = r->mask;int ret;
@@ -447,18 +442,9 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,* If there are other enqueues in progress that preceded us, * we need to wait for them to complete */ -while (unlikely (r->prod.tail != prod_head)) { +while (unlikely (r->prod.tail != prod_head))rte_pause (); -/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting -* for other thread finish. It gives pre-empted thread a chance -* to proceed and finish with ring dequeue operation. */ -if (RTE_RING_PAUSE_REP_COUNT && - ++rep ==RTE_RING_PAUSE_REP_COUNT ) { - rep =0 ; -sched_yield (); - } - } r->prod.tail = prod_next;return ret; }
@@ -491,7 +477,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, {uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries; -unsigned i; +unsigned int i;uint32_t mask = r->mask;int ret;
@@ -568,7 +554,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_next, entries;const unsigned max = n;int success; -unsigned i, rep =0 ; +unsigned int i;uint32_t mask = r->mask;/* Avoid the unnecessary cmpset operation below, which is also
@@ -613,18 +599,9 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,* If there are other dequeues in progress that preceded us, * we need to wait for them to complete */ -while (unlikely (r->cons.tail != cons_head)) { +while (unlikely (r->cons.tail != cons_head))rte_pause (); -/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting -* for other thread finish. It gives pre-empted thread a chance -* to proceed and finish with ring dequeue operation. */ -if (RTE_RING_PAUSE_REP_COUNT && - ++rep ==RTE_RING_PAUSE_REP_COUNT ) { - rep =0 ; -sched_yield (); - } - } r->cons.tail = cons_next;return behavior ==RTE_RING_QUEUE_FIXED ?0 : n;
@@ -659,7 +636,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, {uint32_t cons_head, prod_tail;uint32_t cons_next, entries; -unsigned i; +unsigned int i;uint32_t mask = r->mask; cons_head = r->cons.head;
Signature · 1 line
2.9.3
PATCH v3 6/14 ring: remove watermark support
In reply to Bruce RichardsonRemove the watermark support. A future commit will add support for having enqueue functions return the amount of free space in the ring, which will allow applications to implement their own watermark checks, while also being more useful to the app.
---
V2: fix missed references to watermarks in v1
--- doc/guides/prog_guide/ring_lib.rst | 8 -- doc/guides/rel_notes/release_17_05.rst | 2 + examples/Makefile | 2 +- lib/librte_ring/rte_ring.c | 23 ----- lib/librte_ring/rte_ring.h | 58 +------------ test/test/autotest_test_funcs.py | 7 -- test/test/commands.c | 52 ------------ test/test/test_ring.c | 149 +-------------------------------- 8 files changed, 8 insertions(+), 293 deletions(-)
doc/guides/prog_guide/ring_lib.rst +0 -8
@@ -102,14 +102,6 @@ Name A ring is identified by a unique name. It is not possible to create two rings with the same name (rte_ring_create() returns NULL if this is attempted). -Water Marking -~~~~~~~~~~~~~ - -The ring can have a high water mark (threshold). -Once an enqueue operation reaches the high water mark, the producer is notified, if the water mark is configured. - -This mechanism can be used, for example, to exert a back pressure on I/O to inform the LAN to PAUSE. - Use Cases ---------
doc/guides/rel_notes/release_17_05.rst +2 -0
@@ -128,6 +128,8 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` + * removed the function ``rte_ring_set_water_mark`` as part of a general + removal of watermarks support in the library. ABI Changes -----------
examples/Makefile +1 -1
@@ -81,7 +81,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering DIRS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ptpclient DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched -DIRS-y += quota_watermark +#DIRS-y += quota_watermark DIRS-$(CONFIG_RTE_ETHDEV_RXTX_CALLBACKS) += rxtx_callbacks DIRS-y += skeleton ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
lib/librte_ring/rte_ring.c +0 -23
@@ -138,7 +138,6 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->watermark = count; r->prod.single = !!(flags &RING_F_SP_ENQ ); r->cons.single = !!(flags &RING_F_SC_DEQ ); r->size = count;
@@ -256,24 +255,6 @@ rte_ring_free(struct rte_ring *r)rte_free (te); } -/* -* change the high water mark. If *count* is 0, water marking is -* disabled -*/ -int -rte_ring_set_water_mark (struct rte_ring *r,unsigned count) -{ -if (count >= r->size) -return -EINVAL ; - -/* if count is 0, disable the watermarking */ -if (count ==0 ) - count = r->size; - - r->watermark = count; -return 0 ; -} -/* dump the status of the ring on the console */ void rte_ring_dump (FILE *f,const struct rte_ring *r)
@@ -287,10 +268,6 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)fprintf (f," ph=%" PRIu32"\n" , r->prod.head);fprintf (f," used=%u\n" ,rte_ring_count (r));fprintf (f," avail=%u\n" ,rte_ring_free_count (r)); -if (r->watermark == r->size) -fprintf (f," watermark=0\n" ); -else -fprintf (f," watermark=%" PRIu32"\n" , r->watermark); }/* dump the status of all rings on the console */
lib/librte_ring/rte_ring.h +2 -56
155 lines not on this page · raw message
test/test/autotest_test_funcs.py +0 -7
@@ -292,11 +292,4 @@ def ring_autotest(child, test_name): elif index == 2: return -1, "Fail [Timeout]" - child.sendline("set_watermark test 100") - child.sendline("dump_ring test") - index = child.expect([" watermark=100", - pexpect.TIMEOUT], timeout=1) - if index != 0: - return -1, "Fail [Bad watermark]" - return 0, "Success"
test/test/commands.c +0 -52
64 lines not on this page · raw message
test/test/test_ring.c +3 -146
179 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v3 11/14 ring: reduce scope of local variables
In reply to Bruce RichardsonThe local variable i is only used for loop control so define it in the enqueue and dequeue blocks directly, rather than at the function level.
--- lib/librte_ring/rte_ring.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/librte_ring/rte_ring.h +2 -4
@@ -285,6 +285,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi producer enqueue functions */ #define ENQUEUE_PTRS () do { \ + unsigned int i; \ const uint32_t size = r->size; \ uint32_t idx = prod_head & mask; \ if (likely(idx + n < size)) { \
@@ -311,6 +312,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi consumer dequeue functions */ #define DEQUEUE_PTRS () do { \ + unsigned int i; \ uint32_t idx = cons_head & mask; \ const uint32_t size = r->size; \ if (likely(idx + n < size)) { \
@@ -361,7 +363,6 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t cons_tail, free_entries;const unsigned int max = n;int success; -unsigned int i;uint32_t mask = r->mask;/* move prod.head atomically */
@@ -431,7 +432,6 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, {uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries; -unsigned int i;uint32_t mask = r->mask; prod_head = r->prod.head;
@@ -495,7 +495,6 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_next, entries;const unsigned max = n;int success; -unsigned int i;uint32_t mask = r->mask;/* move cons.head atomically */
@@ -566,7 +565,6 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, {uint32_t cons_head, prod_tail;uint32_t cons_next, entries; -unsigned int i;uint32_t mask = r->mask; cons_head = r->cons.head;
Signature · 1 line
2.9.3
PATCH v3 12/14 ring: separate out head index manipulation for enq/deq
In reply to Bruce RichardsonWe can write a single common function for head manipulation for enq and a common one for deq, allowing us to have a single worker function for enq and deq, rather than two of each. Update all other inline functions to use the new functions.
---
V3: renamed parameter "is_mp" in __rte_ring_do_dequeue to the correct "is_sc"
--- lib/librte_ring/rte_ring.c | 4 +- lib/librte_ring/rte_ring.h | 328 ++++++++++++++++++++------------------------- 2 files changed, 149 insertions(+), 183 deletions(-)
lib/librte_ring/rte_ring.c +2 -2
@@ -138,8 +138,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->prod.single = !!(flags &RING_F_SP_ENQ ); - r->cons.single = !!(flags &RING_F_SC_DEQ ); + r->prod.single = (flags &RING_F_SP_ENQ ) ? __IS_SP : __IS_MP; + r->cons.single = (flags &RING_F_SC_DEQ ) ? __IS_SC : __IS_MC; r->size = count; r->mask = count -1 ; r->prod.head = r->cons.head =0 ;
lib/librte_ring/rte_ring.h +147 -181
528 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v3 13/14 ring: create common function for updating tail idx
In reply to Bruce RichardsonBoth producer and consumer use the same logic for updating the tail index so merge into a single function.
---
V3: added check for "single" mode in tail update to buypass unneeded check
--- lib/librte_ring/rte_ring.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
lib/librte_ring/rte_ring.h +17 -17
@@ -341,6 +341,21 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r); } \ }while (0 ) +static inline __attribute__((always_inline)) void +update_tail (struct rte_ring_headtail *ht,uint32_t old_val,uint32_t new_val, +uint32_t single) +{ +/* +* If there are other enqueues/dequeues in progress that preceded us, +* we need to wait for them to complete +*/ +if (!single) +while (unlikely (ht->tail != old_val)) +rte_pause (); + + ht->tail = new_val; +} +/** * @internal This function updates the producer head for enqueue *
@@ -440,15 +455,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,ENQUEUE_PTRS ();rte_smp_wmb (); -/* -* If there are other enqueues in progress that preceded us, -* we need to wait for them to complete -*/ -while (unlikely (r->prod.tail != prod_head)) -rte_pause (); - - r->prod.tail = prod_next; - +update_tail (&r->prod, prod_head, prod_next, is_sp); end:if (free_space !=NULL ) *free_space = free_entries - n;
@@ -553,14 +560,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,DEQUEUE_PTRS ();rte_smp_rmb (); -/* -* If there are other enqueues in progress that preceded us, -* we need to wait for them to complete -*/ -while (unlikely (r->cons.tail != cons_head)) -rte_pause (); - - r->cons.tail = cons_next; +update_tail (&r->cons, cons_head, cons_next, is_sc); end:if (available !=NULL )
Signature · 1 line
2.9.3
PATCH v3 14/14 ring: make ring struct and enq/deq macros type agnostic
In reply to Bruce RichardsonModify the enqueue and dequeue macros to support copying any type of object by passing in the exact object type. Rather than using the "ring" structure member of rte_ring, which is of type "array of void *", instead have the macros take the start of the ring a a pointer value, thereby leaving the rte_ring structure as purely a header value. This allows it to be reused by other future ring types which can add on extra fields if they want, or even to have the actual ring elements, of whatever type stored separate from the ring header.
--- lib/librte_ring/rte_ring.h | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-)
lib/librte_ring/rte_ring.h +36 -32
@@ -159,11 +159,7 @@ struct rte_ring {/** Ring consumer status. */ struct rte_ring_headtail cons __rte_aligned(CONS_ALIGN); - - void *ring[] __rte_cache_aligned; /**< Memory space of ring starts here. -* not volatile so need to be careful -* about compiler re-ordering */ -}; +} __rte_cache_aligned;#define RING_F_SP_ENQ 0x0001/**< The default enqueue is "single-producer". */ #define RING_F_SC_DEQ 0x0002/**< The default dequeue is "single-consumer". */
@@ -290,54 +286,62 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);/* the actual enqueue of pointers on the ring. * Placed here since identical code needed in both * single and multi producer enqueue functions */ -#define ENQUEUE_PTRS () do { \ +#define ENQUEUE_PTRS (r, ring_start, prod_head, obj_table, n, obj_type) do { \ unsigned int i; \ - const uint32_t size = r->size; \ - uint32_t idx = prod_head & r->mask; \ + const uint32_t size = (r)->size; \ + uint32_t idx = prod_head & (r)->mask; \ + obj_type *ring = (void *)ring_start; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \ - r->ring[idx] = obj_table[i]; \ - r->ring[idx+1] = obj_table[i+1]; \ - r->ring[idx+2] = obj_table[i+2]; \ - r->ring[idx+3] = obj_table[i+3]; \ + ring[idx] = obj_table[i]; \ + ring[idx+1] = obj_table[i+1]; \ + ring[idx+2] = obj_table[i+2]; \ + ring[idx+3] = obj_table[i+3]; \ } \ switch (n & 0x3) { \ - case 3: r->ring[idx++] = obj_table[i++]; \ - case 2: r->ring[idx++] = obj_table[i++]; \ - case 1: r->ring[idx++] = obj_table[i++]; \ + case 3: \ + ring[idx++] = obj_table[i++];/* fallthrough */ \ +case 2 : \ + ring[idx++] = obj_table[i++];/* fallthrough */ \ +case 1 : \ + ring[idx++] = obj_table[i++]; \ } \ } else { \for (i =0 ; idx < size; i++, idx++)\ - r->ring[idx] = obj_table[i]; \ + ring[idx] = obj_table[i]; \for (idx =0 ; i < n; i++, idx++) \ - r->ring[idx] = obj_table[i]; \ + ring[idx] = obj_table[i]; \ } \ -} while(0) +} while (0)/* the actual copy of pointers on the ring to obj_table. * Placed here since identical code needed in both * single and multi consumer dequeue functions */ -#define DEQUEUE_PTRS () do { \ +#define DEQUEUE_PTRS (r, ring_start, cons_head, obj_table, n, obj_type) do { \ unsigned int i; \ - uint32_t idx = cons_head & r->mask; \ - const uint32_t size = r->size; \ + uint32_t idx = cons_head & (r)->mask; \ + const uint32_t size = (r)->size; \ + obj_type *ring = (void *)ring_start; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\ - obj_table[i] = r->ring[idx]; \ - obj_table[i+1] = r->ring[idx+1]; \ - obj_table[i+2] = r->ring[idx+2]; \ - obj_table[i+3] = r->ring[idx+3]; \ + obj_table[i] = ring[idx]; \ + obj_table[i+1] = ring[idx+1]; \ + obj_table[i+2] = ring[idx+2]; \ + obj_table[i+3] = ring[idx+3]; \ } \ switch (n & 0x3) { \ - case 3: obj_table[i++] = r->ring[idx++]; \ - case 2: obj_table[i++] = r->ring[idx++]; \ - case 1: obj_table[i++] = r->ring[idx++]; \ + case 3: \ + obj_table[i++] = ring[idx++];/* fallthrough */ \ +case 2 : \ + obj_table[i++] = ring[idx++];/* fallthrough */ \ +case 1 : \ + obj_table[i++] = ring[idx++]; \ } \ } else { \for (i =0 ; idx < size; i++, idx++) \ - obj_table[i] = r->ring[idx]; \ + obj_table[i] = ring[idx]; \for (idx =0 ; i < n; i++, idx++) \ - obj_table[i] = r->ring[idx]; \ + obj_table[i] = ring[idx]; \ } \ } while (0)
@@ -452,7 +456,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,if (n ==0 ) goto end; -ENQUEUE_PTRS (); + ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);rte_smp_wmb ();update_tail (&r->prod, prod_head, prod_next, is_sp);
@@ -557,7 +561,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,if (n ==0 ) goto end; -DEQUEUE_PTRS (); + DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n, void *);rte_smp_rmb ();update_tail (&r->cons, cons_head, cons_next, is_sc);
Signature · 1 line
2.9.3
PATCH v3 7/14 ring: make bulk and burst fn return vals consistent
In reply to Bruce RichardsonThe bulk fns for rings returns 0 for all elements enqueued and negative for no space. Change that to make them consistent with the burst functions in returning the number of elements enqueued/dequeued, i.e. 0 or N. This change also allows the return value from enq/deq to be used directly without a branch for error checking.
--- doc/guides/rel_notes/release_17_05.rst | 11 +++ doc/guides/sample_app_ug/server_node_efd.rst | 2 +- examples/load_balancer/runtime.c | 16 ++- .../client_server_mp/mp_client/client.c | 8 +- .../client_server_mp/mp_server/main.c | 2 +- examples/qos_sched/app_thread.c | 8 +- examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 12 ++- lib/librte_ring/rte_ring.h | 109 +++++++-------------- test/test-pipeline/pipeline_hash.c | 2 +- test/test-pipeline/runtime.c | 8 +- test/test/test_ring.c | 46 +++++---- test/test/test_ring_perf.c | 8 +- 14 files changed, 106 insertions(+), 130 deletions(-)
doc/guides/rel_notes/release_17_05.rst +11 -0
@@ -130,6 +130,17 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` * removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library. + * changed the return value of the enqueue and dequeue bulk functions to + match that of the burst equivalents. In all cases, ring functions which + operate on multiple packets now return the number of elements enqueued + or dequeued, as appropriate. The updated functions are: + + - ``rte_ring_mp_enqueue_bulk`` + - ``rte_ring_sp_enqueue_bulk`` + - ``rte_ring_enqueue_bulk`` + - ``rte_ring_mc_dequeue_bulk`` + - ``rte_ring_sc_dequeue_bulk`` + - ``rte_ring_dequeue_bulk`` ABI Changes -----------
doc/guides/sample_app_ug/server_node_efd.rst +1 -1
@@ -286,7 +286,7 @@ repeated infinitely. cl = &nodes[node]; if (rte_ring_enqueue_bulk(cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != 0){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){ for (j = 0; j < cl_rx_buf[node].count; j++) rte_pktmbuf_free(cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
examples/load_balancer/runtime.c +7 -9
@@ -146,7 +146,7 @@ app_lcore_io_rx_buffer_to_send ( (void **) lp->rx.mbuf_out[worker].array, bsz); -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz; k ++) {struct rte_mbuf *m = lp->rx.mbuf_out[worker].array[k];
@@ -312,7 +312,7 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) (void **) lp->rx.mbuf_out[worker].array, lp->rx.mbuf_out[worker].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->rx.mbuf_out[worker].n_mbufs; k ++) {struct rte_mbuf *pkt_to_free = lp->rx.mbuf_out[worker].array[k];
@@ -349,9 +349,8 @@ app_lcore_io_tx( (void **) &lp->tx.mbuf_out[port].array[n_mbufs], bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - } n_mbufs += bsz_rd;
@@ -505,9 +504,8 @@ app_lcore_worker( (void **) lp->mbuf_in.array, bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - }#if APP_WORKER_DROP_ALL_PACKETS for (j =0 ; j < bsz_rd; j ++) {
@@ -559,7 +557,7 @@ app_lcore_worker(#if APP_STATS lp->rings_out_iters[port] ++; -if (ret ==0 ) { +if (ret >0 ) { lp->rings_out_count[port] +=1 ; }if (lp->rings_out_iters[port] ==APP_STATS ){
@@ -572,7 +570,7 @@ app_lcore_worker( }#endif -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz_wr; k ++) {struct rte_mbuf *pkt_to_free = lp->mbuf_out[port].array[k];
@@ -609,7 +607,7 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) (void **) lp->mbuf_out[port].array, lp->mbuf_out[port].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->mbuf_out[port].n_mbufs; k ++) {struct rte_mbuf *pkt_to_free = lp->mbuf_out[port].array[k];
examples/multi_process/client_server_mp/mp_client/client.c +2 -6
@@ -276,14 +276,10 @@ main(int argc, char *argv[])printf ("[Press Ctrl-C to quit ...]\n" );for (;;) { -uint16_t i, rx_pkts =PKT_READ_SIZE ; +uint16_t i, rx_pkts;uint8_t port; -/* try dequeuing max possible packets first, if that fails, get the -* most we can. Loop body should only execute once, maximum */ -while (rx_pkts >0 && -unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, rx_pkts) !=0 )) - rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE ); + rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts,PKT_READ_SIZE );if (unlikely (rx_pkts ==0 )){if (need_flush)
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) !=0 ){ + cl_rx_buf[client].count) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]); cl->stats.rx_drop += cl_rx_buf[client].count;
examples/qos_sched/app_thread.c +5 -3
@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) !=0 )) { + (void **)rx_mbufs, nb_rx) ==0 )) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);
@@ -180,7 +180,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, burst_conf.qos_dequeue); -if (likely (retval ==0 )) { +if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue); conf->counter =0 ;/* reset empty read loop counter */
@@ -230,7 +230,9 @@ app_worker_thread(struct thread_conf **confs) nb_pkt =rte_sched_port_dequeue (conf->sched_port, mbufs, burst_conf.qos_dequeue);if (likely (nb_pkt >0 )) -while (rte_ring_sp_enqueue_bulk (conf->tx_ring, (void **)mbufs, nb_pkt) !=0 ); +while (rte_ring_sp_enqueue_bulk (conf->tx_ring, + (void **)mbufs, nb_pkt) ==0 ) + ;/* empty body */ conf_idx++;if (confs[conf_idx] ==NULL )
examples/server_node_efd/node/node.c +1 -1
@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) !=0 )) + rx_pkts) ==0 )) rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE );
examples/server_node_efd/server/main.c +1 -1
@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) !=0 ){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
lib/librte_mempool/rte_mempool_ring.c +8 -4
@@ -42,26 +42,30 @@ static int common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { - return rte_ring_mp_enqueue_bulk(mp->pool_data, obj_table, n); + return rte_ring_mp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { -return rte_ring_sp_enqueue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_mc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_mc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_sc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static unsigned
lib/librte_ring/rte_ring.h +38 -71
264 lines not on this page · raw message
test/test-pipeline/pipeline_hash.c +1 -1
@@ -547,6 +547,6 @@ app_main_loop_rx_metadata(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }
test/test-pipeline/runtime.c +4 -4
@@ -98,7 +98,7 @@ app_main_loop_rx(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }
@@ -123,7 +123,7 @@ app_main_loop_worker(void) { (void **) worker_mbuf->array, app.burst_size_worker_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; do {
@@ -131,7 +131,7 @@ app_main_loop_worker(void) { app.rings_tx[i ^1 ], (void **) worker_mbuf->array, app.burst_size_worker_write); - }while (ret <0 ); + }while (ret ==0 ); } }
@@ -152,7 +152,7 @@ app_main_loop_tx(void) { (void **) &app.mbuf_tx[i].array[n_mbufs], app.burst_size_tx_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; n_mbufs += app.burst_size_tx_read;
test/test/test_ring.c +22 -24
152 lines not on this page · raw message
test/test/test_ring_perf.c +4 -4
@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();
@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc ();
Signature · 1 line
2.9.3
PATCH v3 8/14 ring: allow enqueue fns to return free space value
In reply to Bruce RichardsonAdd an extra parameter to the ring enqueue burst/bulk functions so that those functions can optionally return the amount of free space in the ring. This information can be used by applications in a number of ways, for instance, with single-producer queues, it provides a max enqueue size which is guaranteed to work. It can also be used to implement watermark functionality in apps, replacing the older functionality with a more flexible version, which enables apps to implement multiple watermark thresholds, rather than just one.
--- doc/guides/rel_notes/release_17_05.rst | 3 + drivers/net/ring/rte_eth_ring.c | 2 +- examples/distributor/main.c | 3 +- examples/load_balancer/runtime.c | 12 ++- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 7 +- examples/qos_sched/app_thread.c | 4 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 4 +- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 28 ++++--- lib/librte_ring/rte_ring.h | 89 +++++++++++----------- test/test-pipeline/pipeline_hash.c | 3 +- test/test-pipeline/runtime.c | 5 +- test/test/test_link_bonding_mode4.c | 3 +- test/test/test_pmd_ring_perf.c | 5 +- test/test/test_ring.c | 55 ++++++------- test/test/test_ring_perf.c | 16 ++-- test/test/test_table_ports.c | 4 +- test/test/virtual_pmd.c | 4 +- 22 files changed, 139 insertions(+), 118 deletions(-)
doc/guides/rel_notes/release_17_05.rst +3 -0
@@ -130,6 +130,9 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` * removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library. + * added an extra parameter to the burst/bulk enqueue functions to + return the number of free spaces in the ring after enqueue. This can + be used by an application to implement its own watermark functionality. * changed the return value of the enqueue and dequeue bulk functions to match that of the burst equivalents. In all cases, ring functions which operate on multiple packets now return the number of elements enqueued
drivers/net/ring/rte_eth_ring.c +1 -1
@@ -102,7 +102,7 @@ eth_ring_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)void **ptrs = (void *)&bufs[0 ];struct ring_queue *r = q;const uint16_t nb_tx = (uint16_t )rte_ring_enqueue_burst (r->rng, - ptrs, nb_bufs); + ptrs, nb_bufs,NULL );if (r->rng->flags &RING_F_SP_ENQ ) { r->tx_pkts.cnt += nb_tx; r->err_pkts.cnt += nb_bufs - nb_tx;
examples/distributor/main.c +2 -1
@@ -238,7 +238,8 @@ lcore_rx(struct lcore_params *p)continue ; } -uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, nb_ret); +uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, + nb_ret,NULL ); app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { RTE_LOG_DP(DEBUG, DISTRAPP,
examples/load_balancer/runtime.c +8 -4
@@ -144,7 +144,8 @@ app_lcore_io_rx_buffer_to_send ( ret =rte_ring_sp_enqueue_bulk ( lp->rx.rings[worker], (void **) lp->rx.mbuf_out[worker].array, - bsz); + bsz, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
@@ -310,7 +311,8 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) ret =rte_ring_sp_enqueue_bulk ( lp->rx.rings[worker], (void **) lp->rx.mbuf_out[worker].array, - lp->rx.mbuf_out[worker].n_mbufs); + lp->rx.mbuf_out[worker].n_mbufs, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
@@ -553,7 +555,8 @@ app_lcore_worker( ret =rte_ring_sp_enqueue_bulk ( lp->rings_out[port], (void **) lp->mbuf_out[port].array, - bsz_wr); + bsz_wr, +NULL );#if APP_STATS lp->rings_out_iters[port] ++;
@@ -605,7 +608,8 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) ret =rte_ring_sp_enqueue_bulk ( lp->rings_out[port], (void **) lp->mbuf_out[port].array, - lp->mbuf_out[port].n_mbufs); + lp->mbuf_out[port].n_mbufs, +NULL );if (unlikely (ret ==0 )) {uint32_t k;
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) ==0 ){ + cl_rx_buf[client].count,NULL ) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]); cl->stats.rx_drop += cl_rx_buf[client].count;
examples/packet_ordering/main.c +4 -3
@@ -421,8 +421,8 @@ rx_thread(struct rte_ring *ring_out) pkts[i++]->seqn = seqn++;/* enqueue to rx_to_workers ring */ - ret =rte_ring_enqueue_burst (ring_out, (void *) pkts, - nb_rx_pkts); + ret =rte_ring_enqueue_burst (ring_out, + (void *)pkts, nb_rx_pkts,NULL ); app_stats.rx.enqueue_pkts += ret;if (unlikely (ret < nb_rx_pkts)) { app_stats.rx.enqueue_failed_pkts +=
@@ -473,7 +473,8 @@ worker_thread(void *args_ptr) burst_buffer[i++]->port ^= xor_val;/* enqueue the modified mbufs to workers_to_tx ring */ - ret =rte_ring_enqueue_burst (ring_out, (void *)burst_buffer, burst_size); + ret =rte_ring_enqueue_burst (ring_out, (void *)burst_buffer, + burst_size,NULL );__sync_fetch_and_add (&app_stats.wkr.enqueue_pkts, ret);if (unlikely (ret < burst_size)) {/* Return the mbufs to their respective pool, dropping packets */
examples/qos_sched/app_thread.c +2 -2
@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) ==0 )) { + (void **)rx_mbufs, nb_rx,NULL ) ==0 )) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);
@@ -231,7 +231,7 @@ app_worker_thread(struct thread_conf **confs) burst_conf.qos_dequeue);if (likely (nb_pkt >0 ))while (rte_ring_sp_enqueue_bulk (conf->tx_ring, - (void **)mbufs, nb_pkt) ==0 ) + (void **)mbufs, nb_pkt,NULL ) ==0 ) ;/* empty body */ conf_idx++;
examples/server_node_efd/server/main.c +1 -1
@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != cl_rx_buf[node].count){ + cl_rx_buf[node].count,NULL ) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
lib/librte_hash/rte_cuckoo_hash.c +1 -1
@@ -808,7 +808,7 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, unsigned i)/* Need to enqueue the free slots in global ring. */ n_slots =rte_ring_mp_enqueue_burst (h->free_slots, cached_free_slots->objs, -LCORE_CACHE_SIZE ); +LCORE_CACHE_SIZE ,NULL ); cached_free_slots->len -= n_slots; }/* Put index of new free slot in cache. */
lib/librte_mempool/rte_mempool_ring.c +2 -2
@@ -43,7 +43,7 @@ common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) {return rte_ring_mp_enqueue_bulk (mp->pool_data, - obj_table, n) ==0 ? -ENOBUFS :0 ; + obj_table, n,NULL ) ==0 ? -ENOBUFS :0 ; } static int
@@ -51,7 +51,7 @@ common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) {return rte_ring_sp_enqueue_bulk (mp->pool_data, - obj_table, n) ==0 ? -ENOBUFS :0 ; + obj_table, n,NULL ) ==0 ? -ENOBUFS :0 ; } static int
lib/librte_pdump/rte_pdump.c +1 -1
@@ -197,7 +197,7 @@ pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) dup_bufs[d_pkts++] = p; } - ring_enq =rte_ring_enqueue_burst (ring, (void *)dup_bufs, d_pkts); + ring_enq =rte_ring_enqueue_burst (ring, (void *)dup_bufs, d_pkts,NULL );if (unlikely (ring_enq < d_pkts)) {RTE_LOG (DEBUG ,PDUMP ,"only %d of packets enqueued to ring\n" , ring_enq);
lib/librte_port/rte_port_ras.c +1 -1
@@ -167,7 +167,7 @@ send_burst(struct rte_port_ring_writer_ras *p)uint32_t nb_tx; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
lib/librte_port/rte_port_ring.c +16 -12
@@ -241,7 +241,7 @@ send_burst(struct rte_port_ring_writer *p)uint32_t nb_tx; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
@@ -256,7 +256,7 @@ send_burst_mp(struct rte_port_ring_writer *p)uint32_t nb_tx; nb_tx =rte_ring_mp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, p->tx_buf_count - nb_tx);for ( ; nb_tx < p->tx_buf_count; nb_tx++)
@@ -318,11 +318,11 @@ rte_port_ring_writer_tx_bulk_internal(void *port,RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD (p, n_pkts);if (is_multi) - n_pkts_ok =rte_ring_mp_enqueue_burst (p->ring, (void **)pkts, - n_pkts); + n_pkts_ok =rte_ring_mp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );else - n_pkts_ok =rte_ring_sp_enqueue_burst (p->ring, (void **)pkts, - n_pkts); + n_pkts_ok =rte_ring_sp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD (p, n_pkts - n_pkts_ok);for ( ; n_pkts_ok < n_pkts; n_pkts_ok++) {
@@ -517,7 +517,7 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)uint32_t nb_tx =0 , i; nb_tx =rte_ring_sp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );/* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) {
@@ -527,7 +527,8 @@ send_burst_nodrop(struct rte_port_ring_writer_nodrop *p)for (i =0 ; i < p->n_retries; i++) { nb_tx +=rte_ring_sp_enqueue_burst (p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx,NULL );/* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) {
@@ -550,7 +551,7 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p)uint32_t nb_tx =0 , i; nb_tx =rte_ring_mp_enqueue_burst (p->ring, (void **)p->tx_buf, - p->tx_buf_count); + p->tx_buf_count,NULL );/* We sent all the packets in a first try */ if (nb_tx >= p->tx_buf_count) {
@@ -560,7 +561,8 @@ send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p)for (i =0 ; i < p->n_retries; i++) { nb_tx +=rte_ring_mp_enqueue_burst (p->ring, - (void **) (p->tx_buf + nb_tx), p->tx_buf_count - nb_tx); + (void **) (p->tx_buf + nb_tx), + p->tx_buf_count - nb_tx,NULL );/* We sent all the packets in more than one try */ if (nb_tx >= p->tx_buf_count) {
@@ -633,10 +635,12 @@ rte_port_ring_writer_nodrop_tx_bulk_internal(void *port,RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD (p, n_pkts);if (is_multi) n_pkts_ok = -rte_ring_mp_enqueue_burst (p->ring, (void **)pkts, n_pkts); +rte_ring_mp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );else n_pkts_ok = -rte_ring_sp_enqueue_burst (p->ring, (void **)pkts, n_pkts); +rte_ring_sp_enqueue_burst (p->ring, + (void **)pkts, n_pkts,NULL );if (n_pkts_ok >= n_pkts)return 0 ;
lib/librte_ring/rte_ring.h +44 -45
196 lines not on this page · raw message
test/test-pipeline/pipeline_hash.c +2 -1
@@ -546,7 +546,8 @@ app_main_loop_rx_metadata(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_rx[i], (void **) app.mbuf_rx.array, - n_mbufs); + n_mbufs, +NULL ); }while (ret ==0 ); } }
test/test-pipeline/runtime.c +3 -2
@@ -97,7 +97,7 @@ app_main_loop_rx(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_rx[i], (void **) app.mbuf_rx.array, - n_mbufs); + n_mbufs,NULL ); }while (ret ==0 ); } }
@@ -130,7 +130,8 @@ app_main_loop_worker(void) { ret =rte_ring_sp_enqueue_bulk ( app.rings_tx[i ^1 ], (void **) worker_mbuf->array, - app.burst_size_worker_write); + app.burst_size_worker_write, +NULL ); }while (ret ==0 ); } }
test/test/test_link_bonding_mode4.c +2 -1
@@ -206,7 +206,8 @@ slave_get_pkts(struct slave_conf *slave, struct rte_mbuf **buf, uint16_t size)static int slave_put_pkts (struct slave_conf *slave,struct rte_mbuf **buf,uint16_t size) { -return rte_ring_enqueue_burst (slave->rx_queue, (void **)buf, size); +return rte_ring_enqueue_burst (slave->rx_queue, (void **)buf, + size,NULL ); } static uint16_t
test/test/test_pmd_ring_perf.c +3 -2
@@ -98,7 +98,7 @@ test_single_enqueue_dequeue(void)const uint64_t sc_start =rte_rdtsc_precise ();rte_compiler_barrier ();for (i =0 ; i < iterations; i++) { -rte_ring_enqueue_bulk (r, &burst,1 ); +rte_ring_enqueue_bulk (r, &burst,1 ,NULL );rte_ring_dequeue_bulk (r, &burst,1 ); }const uint64_t sc_end =rte_rdtsc_precise ();
@@ -131,7 +131,8 @@ test_bulk_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_bulk (r, (void *)burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_bulk (r, (void *)burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_bulk (r, (void *)burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();
test/test/test_ring.c +28 -27
203 lines not on this page · raw message
test/test/test_ring_perf.c +10 -6
@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();
@@ -323,14 +323,16 @@ test_burst_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_burst (r, burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_burst (r, burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_burst (r, burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_mp_enqueue_burst (r, burst, bulk_sizes[sz]); +rte_ring_mp_enqueue_burst (r, burst, + bulk_sizes[sz],NULL );rte_ring_mc_dequeue_burst (r, burst, bulk_sizes[sz]); }const uint64_t mc_end =rte_rdtsc ();
@@ -357,14 +359,16 @@ test_bulk_enqueue_dequeue(void)for (sz =0 ; sz <sizeof (bulk_sizes)/sizeof (bulk_sizes[0 ]); sz++) {const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_sp_enqueue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_sp_enqueue_bulk (r, burst, + bulk_sizes[sz],NULL );rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[sz]); }const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) { -rte_ring_mp_enqueue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_mp_enqueue_bulk (r, burst, + bulk_sizes[sz],NULL );rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[sz]); }const uint64_t mc_end =rte_rdtsc ();
test/test/test_table_ports.c +2 -2
@@ -80,7 +80,7 @@ test_port_ring_reader(void) mbuf[0 ] = (void *)rte_pktmbuf_alloc (pool); expected_pkts =rte_ring_sp_enqueue_burst (port_ring_reader_params.ring, - mbuf,1 ); + mbuf,1 ,NULL ); received_pkts = rte_port_ring_reader_ops.f_rx (port, res_mbuf,1 );if (received_pkts < expected_pkts)
@@ -93,7 +93,7 @@ test_port_ring_reader(void) mbuf[i] =rte_pktmbuf_alloc (pool); expected_pkts =rte_ring_sp_enqueue_burst (port_ring_reader_params.ring, - (void *const *) mbuf,RTE_PORT_IN_BURST_SIZE_MAX ); + (void *const *) mbuf,RTE_PORT_IN_BURST_SIZE_MAX ,NULL ); received_pkts = rte_port_ring_reader_ops.f_rx (port, res_mbuf,RTE_PORT_IN_BURST_SIZE_MAX );
test/test/virtual_pmd.c +2 -2
@@ -380,7 +380,7 @@ virtual_ethdev_tx_burst_success(void *queue, struct rte_mbuf **bufs, nb_pkts =0 ; else nb_pkts =rte_ring_enqueue_burst (dev_private->tx_queue, (void **)bufs, - nb_pkts); + nb_pkts,NULL );/* increment opacket count */ dev_private->eth_stats.opackets += nb_pkts;
@@ -496,7 +496,7 @@ virtual_ethdev_add_mbufs_to_rx_queue(uint8_t port_id, vrtl_eth_dev->data->dev_private;return rte_ring_enqueue_burst (dev_private->rx_queue, (void **)pkt_burst, - burst_length); + burst_length,NULL ); }int
Signature · 1 line
2.9.3
PATCH v3 9/14 ring: allow dequeue fns to return remaining entry count
In reply to Bruce RichardsonAdd an extra parameter to the ring dequeue burst/bulk functions so that those functions can optionally return the amount of remaining objs in the ring. This information can be used by applications in a number of ways, for instance, with single-consumer queues, it provides a max dequeue size which is guaranteed to work.
--- app/pdump/main.c | 2 +- doc/guides/rel_notes/release_17_05.rst | 8 ++ drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 2 +- examples/distributor/main.c | 2 +- examples/load_balancer/runtime.c | 6 +- .../client_server_mp/mp_client/client.c | 3 +- examples/packet_ordering/main.c | 6 +- examples/qos_sched/app_thread.c | 6 +- examples/quota_watermark/qw/main.c | 5 +- examples/server_node_efd/node/node.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 3 +- lib/librte_mempool/rte_mempool_ring.c | 4 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ring.c | 6 +- lib/librte_ring/rte_ring.h | 90 +++++++++++----------- test/test-pipeline/runtime.c | 6 +- test/test/test_link_bonding_mode4.c | 3 +- test/test/test_pmd_ring_perf.c | 7 +- test/test/test_ring.c | 54 ++++++------- test/test/test_ring_perf.c | 20 +++-- test/test/test_table_acl.c | 2 +- test/test/test_table_pipeline.c | 2 +- test/test/test_table_ports.c | 8 +- test/test/virtual_pmd.c | 4 +- 26 files changed, 145 insertions(+), 114 deletions(-)
app/pdump/main.c +1 -1
@@ -496,7 +496,7 @@ pdump_rxtx(struct rte_ring *ring, uint8_t vdev_id, struct pdump_stats *stats)/* first dequeue packets from ring of primary process */ const uint16_t nb_in_deq =rte_ring_dequeue_burst (ring, - (void *)rxtx_bufs,BURST_SIZE ); + (void *)rxtx_bufs,BURST_SIZE ,NULL ); stats->dequeue_pkts += nb_in_deq;if (nb_in_deq) {
doc/guides/rel_notes/release_17_05.rst +8 -0
@@ -133,6 +133,8 @@ API Changes * added an extra parameter to the burst/bulk enqueue functions to return the number of free spaces in the ring after enqueue. This can be used by an application to implement its own watermark functionality. + * added an extra parameter to the burst/bulk dequeue functions to return + the number elements remaining in the ring after dequeue. * changed the return value of the enqueue and dequeue bulk functions to match that of the burst equivalents. In all cases, ring functions which operate on multiple packets now return the number of elements enqueued
@@ -145,6 +147,12 @@ API Changes - ``rte_ring_sc_dequeue_bulk`` - ``rte_ring_dequeue_bulk`` + NOTE: the above functions all have different parameters as well as + different return values, due to the other listed changes above. This + means that all instances of the functions in existing code will be + flagged by the compiler. The return value usage should be checked + while fixing the compiler error due to the extra parameter. + ABI Changes -----------
drivers/crypto/null/null_crypto_pmd.c +1 -1
@@ -155,7 +155,7 @@ null_crypto_pmd_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,unsigned nb_dequeued; nb_dequeued =rte_ring_dequeue_burst (qp->processed_pkts, - (void **)ops, nb_ops); + (void **)ops, nb_ops,NULL ); qp->qp_stats.dequeued_count += nb_dequeued;return nb_dequeued;
drivers/net/bonding/rte_eth_bond_pmd.c +2 -1
@@ -1008,7 +1008,8 @@ bond_ethdev_tx_burst_8023ad(void *queue, struct rte_mbuf **bufs,struct port *port = &mode_8023ad_ports[slaves[i]]; slave_slow_nb_pkts[i] =rte_ring_dequeue_burst (port->tx_ring, - slow_pkts,BOND_MODE_8023AX_SLAVE_TX_PKTS ); + slow_pkts,BOND_MODE_8023AX_SLAVE_TX_PKTS , +NULL ); slave_nb_pkts[i] = slave_slow_nb_pkts[i];for (j =0 ; j < slave_slow_nb_pkts[i]; j++)
drivers/net/ring/rte_eth_ring.c +1 -1
@@ -88,7 +88,7 @@ eth_ring_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)void **ptrs = (void *)&bufs[0 ];struct ring_queue *r = q;const uint16_t nb_rx = (uint16_t )rte_ring_dequeue_burst (r->rng, - ptrs, nb_bufs); + ptrs, nb_bufs,NULL );if (r->rng->flags &RING_F_SC_DEQ ) r->rx_pkts.cnt += nb_rx;else
examples/distributor/main.c +1 -1
@@ -330,7 +330,7 @@ lcore_tx(struct rte_ring *in_r)struct rte_mbuf *bufs[BURST_SIZE ];const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, - (void *)bufs,BURST_SIZE ); + (void *)bufs,BURST_SIZE ,NULL ); app_stats.tx.dequeue_pkts += nb_rx;/* if we get no traffic, flush anything we have */
examples/load_balancer/runtime.c +4 -2
@@ -349,7 +349,8 @@ app_lcore_io_tx( ret =rte_ring_sc_dequeue_bulk ( ring, (void **) &lp->tx.mbuf_out[port].array[n_mbufs], - bsz_rd); + bsz_rd, +NULL );if (unlikely (ret ==0 ))continue ;
@@ -504,7 +505,8 @@ app_lcore_worker( ret =rte_ring_sc_dequeue_bulk ( ring_in, (void **) lp->mbuf_in.array, - bsz_rd); + bsz_rd, +NULL );if (unlikely (ret ==0 ))continue ;
examples/multi_process/client_server_mp/mp_client/client.c +2 -1
@@ -279,7 +279,8 @@ main(int argc, char *argv[])uint16_t i, rx_pkts;uint8_t port; - rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts,PKT_READ_SIZE ); + rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts, +PKT_READ_SIZE ,NULL );if (unlikely (rx_pkts ==0 )){if (need_flush)
examples/packet_ordering/main.c +3 -3
@@ -462,7 +462,7 @@ worker_thread(void *args_ptr)/* dequeue the mbufs from rx_to_workers ring */ burst_size =rte_ring_dequeue_burst (ring_in, - (void *)burst_buffer,MAX_PKTS_BURST ); + (void *)burst_buffer,MAX_PKTS_BURST ,NULL );if (unlikely (burst_size ==0 ))continue ;
@@ -510,7 +510,7 @@ send_thread(struct send_thread_args *args)/* deque the mbufs from workers_to_tx ring */ nb_dq_mbufs =rte_ring_dequeue_burst (args->ring_in, - (void *)mbufs,MAX_PKTS_BURST ); + (void *)mbufs,MAX_PKTS_BURST ,NULL );if (unlikely (nb_dq_mbufs ==0 ))continue ;
@@ -595,7 +595,7 @@ tx_thread(struct rte_ring *ring_in)/* deque the mbufs from workers_to_tx ring */ dqnum =rte_ring_dequeue_burst (ring_in, - (void *)mbufs,MAX_PKTS_BURST ); + (void *)mbufs,MAX_PKTS_BURST ,NULL );if (unlikely (dqnum ==0 ))continue ;
examples/qos_sched/app_thread.c +3 -3
@@ -179,7 +179,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, - burst_conf.qos_dequeue); + burst_conf.qos_dequeue,NULL );if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue);
@@ -218,7 +218,7 @@ app_worker_thread(struct thread_conf **confs)/* Read packet from the ring */ nb_pkt =rte_ring_sc_dequeue_burst (conf->rx_ring, (void **)mbufs, - burst_conf.ring_burst); + burst_conf.ring_burst,NULL );if (likely (nb_pkt)) {int nb_sent =rte_sched_port_enqueue (conf->sched_port, mbufs, nb_pkt);
@@ -254,7 +254,7 @@ app_mixed_thread(struct thread_conf **confs)/* Read packet from the ring */ nb_pkt =rte_ring_sc_dequeue_burst (conf->rx_ring, (void **)mbufs, - burst_conf.ring_burst); + burst_conf.ring_burst,NULL );if (likely (nb_pkt)) {int nb_sent =rte_sched_port_enqueue (conf->sched_port, mbufs, nb_pkt);
examples/quota_watermark/qw/main.c +3 -2
@@ -247,7 +247,8 @@ pipeline_stage(__attribute__((unused)) void *args) }/* Dequeue up to quota mbuf from rx */ - nb_dq_pkts =rte_ring_dequeue_burst (rx, pkts, *quota); + nb_dq_pkts =rte_ring_dequeue_burst (rx, pkts, + *quota,NULL );if (unlikely (nb_dq_pkts <0 ))continue ;
@@ -305,7 +306,7 @@ send_stage(__attribute__((unused)) void *args)/* Dequeue packets from tx and send them */ nb_dq_pkts = (uint16_t )rte_ring_dequeue_burst (tx, - (void *) tx_pkts, *quota); + (void *) tx_pkts, *quota,NULL );rte_eth_tx_burst (dest_port_id,0 , tx_pkts, nb_dq_pkts);/* TODO: Check if nb_dq_pkts == nb_tx_pkts? */
examples/server_node_efd/node/node.c +1 -1
@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) ==0 )) + rx_pkts,NULL ) ==0 )) rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE );
lib/librte_hash/rte_cuckoo_hash.c +2 -1
@@ -536,7 +536,8 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key,if (cached_free_slots->len ==0 ) {/* Need to get another burst of free slots from global ring */ n_slots =rte_ring_mc_dequeue_burst (h->free_slots, - cached_free_slots->objs,LCORE_CACHE_SIZE ); + cached_free_slots->objs, +LCORE_CACHE_SIZE ,NULL );if (n_slots ==0 )return -ENOSPC ;
lib/librte_mempool/rte_mempool_ring.c +2 -2
@@ -58,14 +58,14 @@ static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { return rte_ring_mc_dequeue_bulk(mp->pool_data, - obj_table, n) == 0 ? -ENOBUFS : 0; + obj_table, n, NULL) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { return rte_ring_sc_dequeue_bulk(mp->pool_data, - obj_table, n) == 0 ? -ENOBUFS : 0; + obj_table, n, NULL) == 0 ? -ENOBUFS : 0; } static unsigned
lib/librte_port/rte_port_frag.c +2 -1
@@ -186,7 +186,8 @@ rte_port_ring_reader_frag_rx(void *port,/* If "pkts" buffer is empty, read packet burst from ring */ if (p->n_pkts ==0 ) { p->n_pkts =rte_ring_sc_dequeue_burst (p->ring, - (void **) p->pkts,RTE_PORT_IN_BURST_SIZE_MAX ); + (void **) p->pkts,RTE_PORT_IN_BURST_SIZE_MAX , +NULL );RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD (p, p->n_pkts);if (p->n_pkts ==0 )return n_pkts_out;
lib/librte_port/rte_port_ring.c +4 -2
@@ -111,7 +111,8 @@ rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;uint32_t nb_rx; - nb_rx =rte_ring_sc_dequeue_burst (p->ring, (void **) pkts, n_pkts); + nb_rx =rte_ring_sc_dequeue_burst (p->ring, (void **) pkts, + n_pkts,NULL );RTE_PORT_RING_READER_STATS_PKTS_IN_ADD (p, nb_rx);return nb_rx;
@@ -124,7 +125,8 @@ rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts,struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port;uint32_t nb_rx; - nb_rx =rte_ring_mc_dequeue_burst (p->ring, (void **) pkts, n_pkts); + nb_rx =rte_ring_mc_dequeue_burst (p->ring, (void **) pkts, + n_pkts,NULL );RTE_PORT_RING_READER_STATS_PKTS_IN_ADD (p, nb_rx);return nb_rx;
lib/librte_ring/rte_ring.h +47 -43
196 lines not on this page · raw message
test/test-pipeline/runtime.c +4 -2
@@ -121,7 +121,8 @@ app_main_loop_worker(void) { ret =rte_ring_sc_dequeue_bulk ( app.rings_rx[i], (void **) worker_mbuf->array, - app.burst_size_worker_read); + app.burst_size_worker_read, +NULL );if (ret ==0 )continue ;
@@ -151,7 +152,8 @@ app_main_loop_tx(void) { ret =rte_ring_sc_dequeue_bulk ( app.rings_tx[i], (void **) &app.mbuf_tx[i].array[n_mbufs], - app.burst_size_tx_read); + app.burst_size_tx_read, +NULL );if (ret ==0 )continue ;
test/test/test_link_bonding_mode4.c +2 -1
@@ -193,7 +193,8 @@ static uint8_t lacpdu_rx_count[RTE_MAX_ETHPORTS] = {0, };static int slave_get_pkts (struct slave_conf *slave,struct rte_mbuf **buf,uint16_t size) { -return rte_ring_dequeue_burst (slave->tx_queue, (void **)buf, size); +return rte_ring_dequeue_burst (slave->tx_queue, (void **)buf, + size,NULL ); }/*
test/test/test_pmd_ring_perf.c +4 -3
@@ -67,7 +67,7 @@ test_empty_dequeue(void)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t sc_end =rte_rdtsc ();const uint64_t eth_start =rte_rdtsc ();
@@ -99,7 +99,7 @@ test_single_enqueue_dequeue(void)rte_compiler_barrier ();for (i =0 ; i < iterations; i++) {rte_ring_enqueue_bulk (r, &burst,1 ,NULL ); -rte_ring_dequeue_bulk (r, &burst,1 ); +rte_ring_dequeue_bulk (r, &burst,1 ,NULL ); }const uint64_t sc_end =rte_rdtsc_precise ();rte_compiler_barrier ();
@@ -133,7 +133,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_bulk (r, (void *)burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_bulk (r, (void *)burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_bulk (r, (void *)burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
test/test/test_ring.c +28 -26
197 lines not on this page · raw message
test/test/test_ring_perf.c +12 -8
@@ -152,12 +152,12 @@ test_empty_dequeue(void)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[0 ]); +rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[0 ],NULL );const uint64_t mc_end =rte_rdtsc (); printf("SC empty dequeue: %.2F\n",
@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size,NULL ) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc ();
@@ -325,7 +325,8 @@ test_burst_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_burst (r, burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_burst (r, burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_burst (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
@@ -333,7 +334,8 @@ test_burst_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_mp_enqueue_burst (r, burst, bulk_sizes[sz],NULL ); -rte_ring_mc_dequeue_burst (r, burst, bulk_sizes[sz]); +rte_ring_mc_dequeue_burst (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t mc_end =rte_rdtsc ();
@@ -361,7 +363,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_sp_enqueue_bulk (r, burst, bulk_sizes[sz],NULL ); -rte_ring_sc_dequeue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_sc_dequeue_bulk (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t sc_end =rte_rdtsc ();
@@ -369,7 +372,8 @@ test_bulk_enqueue_dequeue(void)for (i =0 ; i < iterations; i++) {rte_ring_mp_enqueue_bulk (r, burst, bulk_sizes[sz],NULL ); -rte_ring_mc_dequeue_bulk (r, burst, bulk_sizes[sz]); +rte_ring_mc_dequeue_bulk (r, burst, + bulk_sizes[sz],NULL ); }const uint64_t mc_end =rte_rdtsc ();
test/test/test_table_acl.c +1 -1
@@ -713,7 +713,7 @@ test_pipeline_single_filter(int expected_count)void *objs[RING_TX_SIZE ];struct rte_mbuf *mbuf; - ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ); + ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ,NULL );if (ret <=0 ) {printf ("Got no objects from ring %d - error code %d\n" , i, ret);
test/test/test_table_pipeline.c +1 -1
@@ -494,7 +494,7 @@ test_pipeline_single_filter(int test_type, int expected_count)void *objs[RING_TX_SIZE ];struct rte_mbuf *mbuf; - ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ); + ret =rte_ring_sc_dequeue_burst (rings_tx[i], objs,10 ,NULL );if (ret <=0 )printf ("Got no objects from ring %d - error code %d\n" , i, ret);
test/test/test_table_ports.c +4 -4
@@ -163,7 +163,7 @@ test_port_ring_writer(void) rte_port_ring_writer_ops.f_flush (port); expected_pkts =1 ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -7 ;
@@ -178,7 +178,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -8 ;
@@ -193,7 +193,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -8 ;
@@ -208,7 +208,7 @@ test_port_ring_writer(void) expected_pkts =RTE_PORT_IN_BURST_SIZE_MAX ; received_pkts =rte_ring_sc_dequeue_burst (port_ring_writer_params.ring, - (void **)res_mbuf, port_ring_writer_params.tx_burst_sz); + (void **)res_mbuf, port_ring_writer_params.tx_burst_sz,NULL );if (received_pkts < expected_pkts)return -9 ;
test/test/virtual_pmd.c +2 -2
@@ -342,7 +342,7 @@ virtual_ethdev_rx_burst_success(void *queue __rte_unused, dev_private = vrtl_eth_dev->data->dev_private; rx_count =rte_ring_dequeue_burst (dev_private->rx_queue, (void **) bufs, - nb_pkts); + nb_pkts,NULL );/* increments ipackets count */ dev_private->eth_stats.ipackets += rx_count;
@@ -508,7 +508,7 @@ virtual_ethdev_get_mbufs_from_tx_queue(uint8_t port_id, dev_private = vrtl_eth_dev->data->dev_private;return rte_ring_dequeue_burst (dev_private->tx_queue, (void **)pkt_burst, - burst_length); + burst_length,NULL ); } static uint8_t
Signature · 1 line
2.9.3
PATCH v3 10/14 examples/quota_watermark: use ring space for watermarks
In reply to Bruce RichardsonNow that the enqueue function returns the amount of space in the ring, we can use that to replace the old watermark functionality. Update the example app to do so, and re-enable it in the examples Makefile.
--- examples/Makefile | 2 +- examples/quota_watermark/qw/init.c | 5 +++-- examples/quota_watermark/qw/main.c | 16 ++++++++++------ examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 ++-- examples/quota_watermark/qwctl/qwctl.c | 2 ++ examples/quota_watermark/qwctl/qwctl.h | 1 + 7 files changed, 20 insertions(+), 11 deletions(-)
examples/Makefile +1 -1
@@ -81,7 +81,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering DIRS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ptpclient DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched -#DIRS-y += quota_watermark +DIRS-y += quota_watermark DIRS-$(CONFIG_RTE_ETHDEV_RXTX_CALLBACKS) += rxtx_callbacks DIRS-y += skeleton ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
examples/quota_watermark/qw/init.c +3 -2
@@ -140,7 +140,7 @@ void init_ring(int lcore_id, uint8_t port_id)if (ring ==NULL )rte_exit (EXIT_FAILURE ,"%s\n" ,rte_strerror (rte_errno)); -rte_ring_set_water_mark (ring,80 *RING_SIZE /100 ); + *high_watermark =80 *RING_SIZE /100 ; rings[lcore_id][port_id] = ring; }
@@ -168,10 +168,11 @@ setup_shared_variables(void)const struct rte_memzone *qw_memzone; qw_memzone =rte_memzone_reserve (QUOTA_WATERMARK_MEMZONE_NAME , -2 *sizeof (int ),rte_socket_id (),0 ); +3 *sizeof (int ),rte_socket_id (),0 );if (qw_memzone ==NULL )rte_exit (EXIT_FAILURE ,"%s\n" ,rte_strerror (rte_errno)); quota = qw_memzone->addr; low_watermark = (unsigned int *) qw_memzone->addr +1 ; + high_watermark = (unsigned int *) qw_memzone->addr +2 ; }
examples/quota_watermark/qw/main.c +10 -6
@@ -67,6 +67,7 @@ struct ether_fc_frame {int *quota;unsigned int *low_watermark; +unsigned int *high_watermark;uint8_t port_pairs[RTE_MAX_ETHPORTS ];
@@ -158,6 +159,7 @@ receive_stage(__attribute__((unused)) void *args)uint16_t nb_rx_pkts;unsigned int lcore_id; +unsigned int free;struct rte_mbuf *pkts[MAX_PKT_QUOTA ];struct rte_ring *ring;
@@ -189,13 +191,13 @@ receive_stage(__attribute__((unused)) void *args) nb_rx_pkts =rte_eth_rx_burst (port_id,0 , pkts, (uint16_t ) *quota); ret =rte_ring_enqueue_bulk (ring, (void *) pkts, - nb_rx_pkts); -if (ret == -EDQUOT ) { + nb_rx_pkts, &free); +if (RING_SIZE - free > *high_watermark) { ring_state[port_id] =RING_OVERLOADED ;send_pause_frame (port_id,1337 ); } -else if (ret == -ENOBUFS ) { +if (ret ==0 ) {/* * Return mbufs to the pool,
@@ -217,6 +219,7 @@ pipeline_stage(__attribute__((unused)) void *args)uint8_t port_id;unsigned int lcore_id, previous_lcore_id; +unsigned int free;void *pkts[MAX_PKT_QUOTA ];struct rte_ring *rx, *tx;
@@ -253,11 +256,12 @@ pipeline_stage(__attribute__((unused)) void *args)continue ;/* Enqueue them on tx */ - ret =rte_ring_enqueue_bulk (tx, pkts, nb_dq_pkts); -if (ret == -EDQUOT ) + ret =rte_ring_enqueue_bulk (tx, pkts, + nb_dq_pkts, &free); +if (RING_SIZE - free > *high_watermark) ring_state[port_id] =RING_OVERLOADED ; -else if (ret == -ENOBUFS ) { +if (ret ==0 ) {/* * Return mbufs to the pool,
examples/quota_watermark/qw/main.h +1 -0
@@ -43,6 +43,7 @@ enum ring_state {extern int *quota;extern unsigned int *low_watermark; +extern unsigned int *high_watermark;extern uint8_t port_pairs[RTE_MAX_ETHPORTS ];
examples/quota_watermark/qwctl/commands.c +2 -2
@@ -140,8 +140,8 @@ cmd_set_handler(__attribute__((unused)) void *parsed_result,else if (tokens->value >= *low_watermark *100 /RING_SIZE && tokens->value <=100 ) -rte_ring_set_water_mark (ring, - tokens->value *RING_SIZE /100 ); + *high_watermark = tokens->value * +RING_SIZE /100 ;else cmdline_printf(cl, "ring high watermark must be between %u%% and 100%%\n",
examples/quota_watermark/qwctl/qwctl.c +2 -0
@@ -55,6 +55,7 @@int *quota;unsigned int *low_watermark; +unsigned int *high_watermark; static void
@@ -68,6 +69,7 @@ setup_shared_variables(void) quota = qw_memzone->addr; low_watermark = (unsigned int *) qw_memzone->addr +1 ; + high_watermark = (unsigned int *) qw_memzone->addr +2 ; }int main (int argc,char **argv)
examples/quota_watermark/qwctl/qwctl.h +1 -0
@@ -36,5 +36,6 @@extern int *quota;extern unsigned int *low_watermark; +extern unsigned int *high_watermark;#endif /* _MAIN_H_ */
Signature · 1 line
2.9.3
Re: [PATCH v3 02/14] ring: create common structure for prod and cons metadata
In reply to Bruce RichardsonQuoted 5 lines · Bruce Richardson
create a common structure to hold the metadata for the producer and the consumer, since both need essentially the same information - the head and tail values, the ring size and mask.
Signed-off-by Bruce Richardson <[email protected]>
Re: [PATCH v3 03/14] ring: eliminate duplication of size and mask fields
In reply to Bruce Richardson2017-03-24 17:09, Bruce Richardson:
Quoted 6 lines
The size and mask fields are duplicated in both the producer and consumer data structures. Move them out of that into the top level structure so they are not duplicated.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Olivier Matz <[email protected]>
Sorry Bruce, I encounter this error:
fatal error: no member named 'size' in 'struct rte_ring_headtail'
if (r->prod.size >= ring_size) {
~~~~~~~ ^Re: [PATCH v3 03/14] ring: eliminate duplication of size and mask fields
Quoted 5 lines · Thomas Monjalon
2017-03-24 17:09, Bruce Richardson:
Quoted 4 lines
The size and mask fields are duplicated in both the producer and consumer data structures. Move them out of that into the top level structure so they are not duplicated.
Quoted 9 lines
Quoted 2 lines
Signed-off-by Bruce Richardson <[email protected]>Acked-by Olivier Matz <[email protected]>Sorry Bruce, I encounter this error:
fatal error: no member named 'size' in 'struct
rte_ring_headtail'if (r->prod.size >= ring_size) { ~~~~~~~ ^
Hi Thomas,
again I need more information here. I've just revalidated these first three patches doing 7 builds with each one (gcc, clang, debug, shared library, old ABI, default-machine and 32-bit), as well as compiling the apps for gcc and clang, and I see no errors.
/Bruce
Re: [PATCH v3 03/14] ring: eliminate duplication of size and mask fields
In reply to Thomas MonjalonQuoted 5 lines · Thomas Monjalon
2017-03-24 17:09, Bruce Richardson:
Quoted 4 lines
The size and mask fields are duplicated in both the producer and consumer data structures. Move them out of that into the top level structure so they are not duplicated.
Quoted 9 lines
Quoted 2 lines
Signed-off-by Bruce Richardson <[email protected]>Acked-by Olivier Matz <[email protected]>Sorry Bruce, I encounter this error:
fatal error: no member named 'size' in 'struct
rte_ring_headtail'if (r->prod.size >= ring_size) { ~~~~~~~ ^
Ok, I think I've found it now using git grep. I assume this is in the crypto code which is disabled by default, right?
/Bruce
Re: [PATCH v3 03/14] ring: eliminate duplication of size and mask fields
2017-03-27 11:15, Bruce Richardson:
Quoted 9 lines · Thomas Monjalon
Quoted 8 lines
2017-03-24 17:09, Bruce Richardson:
Quoted 6 lines
The size and mask fields are duplicated in both the producer and consumer data structures. Move them out of that into the top level structure so they are not duplicated.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Olivier Matz <[email protected]>
Quoted 8 lines
Quoted 6 lines
Sorry Bruce, I encounter this error:
fatal error: no member named 'size' in 'struct
rte_ring_headtail'if (r->prod.size >= ring_size) { ~~~~~~~ ^Ok, I think I've found it now using git grep. I assume this is in the crypto code which is disabled by default, right?
Right, sorry for forgetting the context.
Re: [PATCH v3 03/14] ring: eliminate duplication of size and mask fields
Quoted 12 lines · Thomas Monjalon
2017-03-27 11:15, Bruce Richardson:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
2017-03-24 17:09, Bruce Richardson:
Quoted 6 lines
The size and mask fields are duplicated in both the producer and consumer data structures. Move them out of that into the top level structure so they are not duplicated.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Olivier Matz <[email protected]>Sorry Bruce, I encounter this error:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
fatal error: no member named 'size' in 'struct
rte_ring_headtail'if (r->prod.size >= ring_size) { ~~~~~~~ ^Ok, I think I've found it now using git grep. I assume this is in the crypto code which is disabled by default, right?
Right, sorry for forgetting the context.
Submitted a new patch for the crypto drivers to fix this issue. The previous patch I did to fix this as a pre-requisite didn't catch the drivers that were disabled by default.
http://dpdk.org/dev/patchwork/patch/22445/
I've verified this now compiles with the aesni-mb crypto PMD enabled at least. I'll see about enabling a few more crypto drivers on my system just in case there are other things I missed in them for this set.
/Bruce
Re: [PATCH v3 08/14] ring: allow enqueue fns to return free space value
In reply to Bruce Richardson2017-03-24 17:10, Bruce Richardson:
Quoted 11 lines
Add an extra parameter to the ring enqueue burst/bulk functions so that those functions can optionally return the amount of free space in the ring. This information can be used by applications in a number of ways, for instance, with single-producer queues, it provides a max enqueue size which is guaranteed to work. It can also be used to implement watermark functionality in apps, replacing the older functionality with a more flexible version, which enables apps to implement multiple watermark thresholds, rather than just one.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Olivier Matz <[email protected]>
There is a an error with this patch and crypto drivers:
drivers/crypto/kasumi/rte_kasumi_pmd.c:362:32: fatal error:
too few arguments to function call, expected 4, have 3
(void **)ops, processed_ops);
^rte_ring.h:1018:1: note: 'rte_ring_enqueue_burst' declared here
drivers/crypto/snow3g/rte_snow3g_pmd.c:366:31: fatal error:
too few arguments to function call, expected 4, have 3
(void **)ops, processed_ops);
^rte_ring.h:1018:1: note: 'rte_ring_enqueue_burst' declared here
Re: [PATCH v3 08/14] ring: allow enqueue fns to return free space value
Quoted 21 lines · Thomas Monjalon
2017-03-24 17:10, Bruce Richardson:
Quoted 11 lines
Add an extra parameter to the ring enqueue burst/bulk functions so that those functions can optionally return the amount of free space in the ring. This information can be used by applications in a number of ways, for instance, with single-producer queues, it provides a max enqueue size which is guaranteed to work. It can also be used to implement watermark functionality in apps, replacing the older functionality with a more flexible version, which enables apps to implement multiple watermark thresholds, rather than just one.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Olivier Matz <[email protected]>There is a an error with this patch and crypto drivers:
drivers/crypto/kasumi/rte_kasumi_pmd.c:362:32: fatal error:
too few arguments to function call, expected 4, have 3(void **)ops, processed_ops); ^
Quoted 9 lines
rte_ring.h:1018:1: note: '
rte_ring_enqueue_burst' declared here
drivers/crypto/snow3g/rte_snow3g_pmd.c:366:31: fatal error:
too few arguments to function call, expected 4, have 3(void **)ops, processed_ops); ^rte_ring.h:1018:1: note: '
rte_ring_enqueue_burst' declared here
Yes, I'm still working through this patchset with crypto drivers enabled myself. Patch 9 also has issues with some of the other drivers - though I don't have this kasumi one enabled on my system myself. I'll need to do a v4, hopefully today. Sorry for not flagging this sooner, I didn't know you were going to try again to apply the set, so I thought I had more time to report the results of testing with the crypto drivers.
/Bruce
v4 cover refactor and cleanup of rte_ring
In reply to Bruce RichardsonThis patchset make a set of, sometimes non-backward compatible, cleanup changes to the rte_ring code in order to improve it. The resulting code is shorter, since the existing functions are restructured to reduce code duplication, as well as being more consistent in behaviour. The specific changes made are explained in each patch which makes that change.
Changes in V4:
* Fixed errors in the crypto PMDs due to missed updates to their enqueue/dequeue calls (p8 & p9).
* Updated quota_watermarks documentation to match changed code (p10)
Changes in V3:
* removed anonymous union for sp_enqueue and sc_dequeue variables (p2)
* fixed parameter to dequeue function which was mistakenly named is_mp instead of is_sc (as described in the comments) (p12)
* skipped unneeded check in tail pointer update fn for sp/sc operation (p13)
Changes in V2:
* Eliminated extra cacheline padding where cachelines are 128B
* Renamed rte_ring_ht_ptr struct to rte_ring_headtail
* Removed missed references to ring watermarks in test code and docs
This patchset is largely the same as that posted previously on-list as an RFC:
http://dpdk.org/ml/archives/dev/2017-February/thread.html#56982
Changes in V1 from RFC:
* Included release notes updates as changes are made in each patch
* Fixed some missed comment updates when changing the code
* Separated some initial fixup patches from this set to send separately
* Dropped the final two patches for an rte_event_ring, as not relevant for this set. That can be done as a separate set later.
* The macros for copying the pointers have an extra parameter added, indicating the start of the ring buffer itself. This allows more flexibility for reusing them in other ring implementations.
Bruce Richardson (14):
ring: remove split cacheline build setting
ring: create common structure for prod and cons metadata
ring: eliminate duplication of size and mask fields
ring: remove debug setting
ring: remove the yield when waiting for tail update
ring: remove watermark support
ring: make bulk and burst fn return vals consistent
ring: allow enqueue fns to return free space value
ring: allow dequeue fns to return remaining entry count examples/quota_watermark: use ring space for watermarks
ring: reduce scope of local variables
ring: separate out head index manipulation for enq/deq
ring: create common function for updating tail idx
ring: make ring struct and enq/deq macros type agnostic
app/pdump/main.c | 2 +- config/common_base | 3 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 - doc/guides/prog_guide/ring_lib.rst | 15 - doc/guides/prog_guide/writing_efficient_code.rst | 2 +- doc/guides/rel_notes/release_17_05.rst | 33 + doc/guides/sample_app_ug/quota_watermark.rst | 148 ++-- doc/guides/sample_app_ug/server_node_efd.rst | 2 +- drivers/crypto/aesni_gcm/aesni_gcm_pmd.c | 2 +- drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 2 +- drivers/crypto/armv8/rte_armv8_pmd.c | 8 +- drivers/crypto/kasumi/rte_kasumi_pmd.c | 6 +- drivers/crypto/null/null_crypto_pmd.c | 2 +- drivers/crypto/openssl/rte_openssl_pmd.c | 2 +- drivers/crypto/snow3g/rte_snow3g_pmd.c | 6 +- drivers/crypto/zuc/rte_zuc_pmd.c | 4 +- drivers/net/bonding/rte_eth_bond_pmd.c | 3 +- drivers/net/ring/rte_eth_ring.c | 4 +- examples/distributor/main.c | 5 +- examples/load_balancer/runtime.c | 34 +- .../client_server_mp/mp_client/client.c | 9 +- .../client_server_mp/mp_server/main.c | 2 +- examples/packet_ordering/main.c | 13 +- examples/qos_sched/app_thread.c | 14 +- examples/quota_watermark/qw/init.c | 5 +- examples/quota_watermark/qw/main.c | 21 +- examples/quota_watermark/qw/main.h | 1 + examples/quota_watermark/qwctl/commands.c | 4 +- examples/quota_watermark/qwctl/qwctl.c | 2 + examples/quota_watermark/qwctl/qwctl.h | 1 + examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_hash/rte_cuckoo_hash.c | 5 +- lib/librte_mempool/rte_mempool_ring.c | 12 +- lib/librte_pdump/rte_pdump.c | 4 +- lib/librte_port/rte_port_frag.c | 3 +- lib/librte_port/rte_port_ras.c | 2 +- lib/librte_port/rte_port_ring.c | 46 +- lib/librte_ring/rte_ring.c | 76 +-- lib/librte_ring/rte_ring.h | 759 ++++++++------------- test/test-pipeline/pipeline_hash.c | 5 +- test/test-pipeline/runtime.c | 19 +- test/test/autotest_test_funcs.py | 7 - test/test/commands.c | 52 -- test/test/test_link_bonding_mode4.c | 6 +- test/test/test_pmd_ring_perf.c | 12 +- test/test/test_ring.c | 704 +++---------------- test/test/test_ring_perf.c | 36 +- test/test/test_table_acl.c | 2 +- test/test/test_table_pipeline.c | 2 +- test/test/test_table_ports.c | 12 +- test/test/virtual_pmd.c | 8 +- 52 files changed, 664 insertions(+), 1472 deletions(-)
Signature · 1 line
2.9.3
PATCH v4 1/14 ring: remove split cacheline build setting
Users compiling DPDK should not need to know or care about the arrangement of cachelines in the rte_ring structure. Therefore just remove the build option and set the structures to be always split. On platforms with 64B cachelines, for improved performance use 128B rather than 64B alignment since it stops the producer and consumer data being on adjacent cachelines.
---
V2: Limit the cacheline * 2 alignment to platforms with < 128B line size
--- config/common_base | 1 - doc/guides/rel_notes/release_17_05.rst | 7 +++++++ lib/librte_ring/rte_ring.c | 2 -- lib/librte_ring/rte_ring.h | 16 ++++++++++------ 4 files changed, 17 insertions(+), 9 deletions(-)
config/common_base +0 -1
@@ -453,7 +453,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # CONFIG_RTE_LIBRTE_RING=y CONFIG_RTE_LIBRTE_RING_DEBUG=n -CONFIG_RTE_RING_SPLIT_PROD_CONS=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #
doc/guides/rel_notes/release_17_05.rst +7 -0
@@ -127,6 +127,13 @@ API Changes * The LPM ``next_hop`` field is extended from 8 bits to 21 bits for IPv6 while keeping ABI compatibility. +* **Reworked rte_ring library** + + The rte_ring library has been reworked and updated. The following changes + have been made to it: + + * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` + ABI Changes -----------
lib/librte_ring/rte_ring.c +0 -2
@@ -127,10 +127,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,/* compilation-time checks */ RTE_BUILD_BUG_ON ((sizeof (struct rte_ring ) &RTE_CACHE_LINE_MASK ) !=0 ); -#ifdef RTE_RING_SPLIT_PROD_CONS RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , cons) &RTE_CACHE_LINE_MASK ) !=0 ); -#endif RTE_BUILD_BUG_ON ((offsetof(struct rte_ring , prod) &RTE_CACHE_LINE_MASK ) !=0 );#ifdef RTE_LIBRTE_RING_DEBUG
lib/librte_ring/rte_ring.h +10 -6
@@ -139,6 +139,14 @@ struct rte_ring_debug_stats {struct rte_memzone ;/* forward declaration, so as not to require memzone.h */ +#if RTE_CACHE_LINE_SIZE <128 +#define PROD_ALIGN (RTE_CACHE_LINE_SIZE * 2) +#define CONS_ALIGN (RTE_CACHE_LINE_SIZE * 2) +#else +#define PROD_ALIGN RTE_CACHE_LINE_SIZE +#define CONS_ALIGN RTE_CACHE_LINE_SIZE +#endif +/** * An RTE ring structure. *
@@ -168,7 +176,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Producer head. */ volatile uint32_t tail;/**< Producer tail. */ - }prod __rte_cache_aligned; + }prod __rte_aligned (PROD_ALIGN );/** Ring consumer status. */ struct cons {
@@ -177,11 +185,7 @@ struct rte_ring {uint32_t mask;/**< Mask (size-1) of ring. */ volatile uint32_t head;/**< Consumer head. */ volatile uint32_t tail;/**< Consumer tail. */ -#ifdef RTE_RING_SPLIT_PROD_CONS - }cons __rte_cache_aligned; -#else - } cons; -#endif + }cons __rte_aligned (CONS_ALIGN );#ifdef RTE_LIBRTE_RING_DEBUG struct rte_ring_debug_stats stats[RTE_MAX_LCORE ];
Signature · 1 line
2.9.3
PATCH v4 2/14 ring: create common structure for prod and cons metadata
In reply to Bruce Richardsoncreate a common structure to hold the metadata for the producer and the consumer, since both need essentially the same information - the head and tail values, the ring size and mask.
---
V3: removed union and replaced with "single" variable
V2: renamed the shared structure based on maintainer feedback.
--- lib/librte_pdump/rte_pdump.c | 2 +- lib/librte_port/rte_port_ring.c | 12 ++++++------ lib/librte_ring/rte_ring.c | 4 ++-- lib/librte_ring/rte_ring.h | 41 +++++++++++++++++++---------------------- 4 files changed, 28 insertions(+), 31 deletions(-)
lib/librte_pdump/rte_pdump.c +1 -1
@@ -740,7 +740,7 @@ pdump_validate_ring_mp(struct rte_ring *ring, struct rte_mempool *mp) rte_errno =EINVAL ;return -1 ; } -if (ring->prod.sp_enqueue || ring->cons.sc_dequeue) { +if (ring->prod.single || ring->cons.single) {RTE_LOG (ERR ,PDUMP ,"ring with either SP or SC settings" " is not valid for pdump, should have MP and MC settings\n" ); rte_errno =EINVAL ;
lib/librte_port/rte_port_ring.c +6 -6
@@ -73,8 +73,8 @@ rte_port_ring_reader_create_internal(void *params, int socket_id,/* Check input parameters */ if ((conf ==NULL ) || (conf->ring ==NULL ) || - (conf->ring->cons.sc_dequeue && is_multi) || - (!(conf->ring->cons.sc_dequeue) && !is_multi)) { + (conf->ring->cons.single && is_multi) || + (!(conf->ring->cons.single) && !is_multi)) {RTE_LOG (ERR ,PORT ,"%s: Invalid Parameters\n" , __func__);return NULL ; }
@@ -198,8 +198,8 @@ rte_port_ring_writer_create_internal(void *params, int socket_id,/* Check input parameters */ if ((conf ==NULL ) || (conf->ring ==NULL ) || - (conf->ring->prod.sp_enqueue && is_multi) || - (!(conf->ring->prod.sp_enqueue) && !is_multi) || + (conf->ring->prod.single && is_multi) || + (!(conf->ring->prod.single) && !is_multi) || (conf->tx_burst_sz >RTE_PORT_IN_BURST_SIZE_MAX )) {RTE_LOG (ERR ,PORT ,"%s: Invalid Parameters\n" , __func__);return NULL ;
@@ -467,8 +467,8 @@ rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id,/* Check input parameters */ if ((conf ==NULL ) || (conf->ring ==NULL ) || - (conf->ring->prod.sp_enqueue && is_multi) || - (!(conf->ring->prod.sp_enqueue) && !is_multi) || + (conf->ring->prod.single && is_multi) || + (!(conf->ring->prod.single) && !is_multi) || (conf->tx_burst_sz >RTE_PORT_IN_BURST_SIZE_MAX )) {RTE_LOG (ERR ,PORT ,"%s: Invalid Parameters\n" , __func__);return NULL ;
lib/librte_ring/rte_ring.c +2 -2
@@ -145,8 +145,8 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,return -ENAMETOOLONG ; r->flags = flags; r->prod.watermark = count; - r->prod.sp_enqueue = !!(flags &RING_F_SP_ENQ ); - r->cons.sc_dequeue = !!(flags &RING_F_SC_DEQ ); + r->prod.single = !!(flags &RING_F_SP_ENQ ); + r->cons.single = !!(flags &RING_F_SC_DEQ ); r->prod.size = r->cons.size = count; r->prod.mask = r->cons.mask = count-1 ; r->prod.head = r->cons.head =0 ;
lib/librte_ring/rte_ring.h +19 -22
97 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v4 3/14 ring: eliminate duplication of size and mask fields
In reply to Bruce RichardsonThe size and mask fields are duplicated in both the producer and consumer data structures. Move them out of that into the top level structure so they are not duplicated.
--- lib/librte_ring/rte_ring.c | 20 ++++++++++---------- lib/librte_ring/rte_ring.h | 32 ++++++++++++++++---------------- test/test/test_ring.c | 6 +++--- 3 files changed, 29 insertions(+), 29 deletions(-)
lib/librte_ring/rte_ring.c +10 -10
@@ -144,11 +144,11 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->prod.watermark = count; + r->watermark = count; r->prod.single = !!(flags &RING_F_SP_ENQ ); r->cons.single = !!(flags &RING_F_SC_DEQ ); - r->prod.size = r->cons.size = count; - r->prod.mask = r->cons.mask = count-1 ; + r->size = count; + r->mask = count -1 ; r->prod.head = r->cons.head =0 ; r->prod.tail = r->cons.tail =0 ;
@@ -269,14 +269,14 @@ rte_ring_free(struct rte_ring *r)int rte_ring_set_water_mark (struct rte_ring *r,unsigned count) { -if (count >= r->prod.size) +if (count >= r->size)return -EINVAL ;/* if count is 0, disable the watermarking */ if (count ==0 ) - count = r->prod.size; + count = r->size; - r->prod.watermark = count; + r->watermark = count;return 0 ; }
@@ -291,17 +291,17 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)fprintf (f,"ring <%s>@%p\n" , r->name, r);fprintf (f," flags=%x\n" , r->flags); -fprintf (f," size=%" PRIu32"\n" , r->prod.size); +fprintf (f," size=%" PRIu32"\n" , r->size);fprintf (f," ct=%" PRIu32"\n" , r->cons.tail);fprintf (f," ch=%" PRIu32"\n" , r->cons.head);fprintf (f," pt=%" PRIu32"\n" , r->prod.tail);fprintf (f," ph=%" PRIu32"\n" , r->prod.head);fprintf (f," used=%u\n" ,rte_ring_count (r));fprintf (f," avail=%u\n" ,rte_ring_free_count (r)); -if (r->prod.watermark == r->prod.size) +if (r->watermark == r->size)fprintf (f," watermark=0\n" );else -fprintf (f," watermark=%" PRIu32"\n" , r->prod.watermark); +fprintf (f," watermark=%" PRIu32"\n" , r->watermark);/* sum and dump statistics */ #ifdef RTE_LIBRTE_RING_DEBUG
@@ -318,7 +318,7 @@ rte_ring_dump(FILE *f, const struct rte_ring *r) sum.deq_fail_bulk += r->stats[lcore_id].deq_fail_bulk; sum.deq_fail_objs += r->stats[lcore_id].deq_fail_objs; } -fprintf (f," size=%" PRIu32"\n" , r->prod.size); +fprintf (f," size=%" PRIu32"\n" , r->size);fprintf (f," enq_success_bulk=%" PRIu64"\n" , sum.enq_success_bulk);fprintf (f," enq_success_objs=%" PRIu64"\n" , sum.enq_success_objs);fprintf (f," enq_quota_bulk=%" PRIu64"\n" , sum.enq_quota_bulk);
lib/librte_ring/rte_ring.h +16 -16
@@ -151,10 +151,7 @@ struct rte_memzone; /* forward declaration, so as not to require memzone.h */struct rte_ring_headtail {volatile uint32_t head;/**< Prod/consumer head. */ volatile uint32_t tail;/**< Prod/consumer tail. */ -uint32_t size;/**< Size of ring. */ -uint32_t mask;/**< Mask (size-1) of ring. */ uint32_t single;/**< True if single prod/cons */ -uint32_t watermark;/**< Max items before EDQUOT in producer. */ };/**
@@ -174,9 +171,12 @@ struct rte_ring {* next time the ABI changes */ char name[RTE_MEMZONE_NAMESIZE ];/**< Name of the ring. */ -int flags;/**< Flags supplied at creation. */ +int flags;/**< Flags supplied at creation. */ const struct rte_memzone *memzone;/**< Memzone, if any, containing the rte_ring */ +uint32_t size;/**< Size of ring. */ +uint32_t mask;/**< Mask (size-1) of ring. */ +uint32_t watermark;/**< Max items before EDQUOT in producer. */ /** Ring producer status. */ struct rte_ring_headtail prod __rte_aligned(PROD_ALIGN);
@@ -355,7 +355,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* Placed here since identical code needed in both * single and multi producer enqueue functions */ #define ENQUEUE_PTRS () do { \ - const uint32_t size = r->prod.size; \ + const uint32_t size = r->size; \ uint32_t idx = prod_head & mask; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
@@ -382,7 +382,7 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r);* single and multi consumer dequeue functions */ #define DEQUEUE_PTRS () do { \ uint32_t idx = cons_head & mask; \ - const uint32_t size = r->cons.size; \ + const uint32_t size = r->size; \ if (likely(idx + n < size)) { \ for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\ obj_table[i] = r->ring[idx]; \
@@ -437,7 +437,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,const unsigned max = n;int success;unsigned i, rep =0 ; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;int ret;/* Avoid the unnecessary cmpset operation below, which is also
@@ -485,7 +485,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb ();/* if we exceed the watermark */ -if (unlikely (((mask +1 ) - free_entries + n) > r->prod.watermark)) { +if (unlikely (((mask +1 ) - free_entries + n) > r->watermark)) { ret = (behavior ==RTE_RING_QUEUE_FIXED ) ? -EDQUOT : (int )(n |RTE_RING_QUOT_EXCEED );__RING_STAT_ADD (r, enq_quota, n);
@@ -544,7 +544,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries;unsigned i; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;int ret; prod_head = r->prod.head;
@@ -580,7 +580,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,rte_smp_wmb ();/* if we exceed the watermark */ -if (unlikely (((mask +1 ) - free_entries + n) > r->prod.watermark)) { +if (unlikely (((mask +1 ) - free_entries + n) > r->watermark)) { ret = (behavior ==RTE_RING_QUEUE_FIXED ) ? -EDQUOT : (int )(n |RTE_RING_QUOT_EXCEED );__RING_STAT_ADD (r, enq_quota, n);
@@ -630,7 +630,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,const unsigned max = n;int success;unsigned i, rep =0 ; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask;/* Avoid the unnecessary cmpset operation below, which is also * potentially harmful when n equals 0. */
@@ -727,7 +727,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_head, prod_tail;uint32_t cons_next, entries;unsigned i; -uint32_t mask = r->prod.mask; +uint32_t mask = r->mask; cons_head = r->cons.head; prod_tail = r->prod.tail;
@@ -1056,7 +1056,7 @@ rte_ring_full(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return ((cons_tail - prod_tail -1 ) & r->prod.mask) ==0 ; +return ((cons_tail - prod_tail -1 ) & r->mask) ==0 ; }/**
@@ -1089,7 +1089,7 @@ rte_ring_count(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return (prod_tail - cons_tail) & r->prod.mask; +return (prod_tail - cons_tail) & r->mask; }/**
@@ -1105,7 +1105,7 @@ rte_ring_free_count(const struct rte_ring *r) {uint32_t prod_tail = r->prod.tail;uint32_t cons_tail = r->cons.tail; -return (cons_tail - prod_tail -1 ) & r->prod.mask; +return (cons_tail - prod_tail -1 ) & r->mask; }/**
@@ -1119,7 +1119,7 @@ rte_ring_free_count(const struct rte_ring *r)static inline unsigned int rte_ring_get_size (const struct rte_ring *r) { -return r->prod.size; +return r->size; }/**
test/test/test_ring.c +3 -3
@@ -148,7 +148,7 @@ check_live_watermark_change(__attribute__((unused)) void *dummy) }/* read watermark, the only change allowed is from 16 to 32 */ - watermark = r->prod.watermark; + watermark = r->watermark;if (watermark != watermark_old && (watermark_old !=16 || watermark !=32 )) { printf("Bad watermark change %u -> %u\n", watermark_old,
@@ -213,7 +213,7 @@ test_set_watermark( void ){printf (" ring lookup failed\n" ); goto error; } - count = r->prod.size*2 ; + count = r->size *2 ; setwm =rte_ring_set_water_mark (r, count);if (setwm != -EINVAL ){printf ("Test failed to detect invalid watermark count value\n" );
@@ -222,7 +222,7 @@ test_set_watermark( void ){ count =0 ;rte_ring_set_water_mark (r, count); -if (r->prod.watermark != r->prod.size) { +if (r->watermark != r->size) {printf ("Test failed to detect invalid watermark count value\n" ); goto error; }
Signature · 1 line
2.9.3
PATCH v4 4/14 ring: remove debug setting
In reply to Bruce RichardsonThe debug option only provided statistics to the user, most of which could be tracked by the application itself. Remove this as a compile time option, and feature, simplifying the code.
--- config/common_base | 1 - doc/guides/prog_guide/ring_lib.rst | 7 - doc/guides/rel_notes/release_17_05.rst | 1 + lib/librte_ring/rte_ring.c | 41 ---- lib/librte_ring/rte_ring.h | 97 +------- test/test/test_ring.c | 410 --------------------------------- 6 files changed, 13 insertions(+), 544 deletions(-)
config/common_base +0 -1
@@ -452,7 +452,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # Compile librte_ring # CONFIG_RTE_LIBRTE_RING=y -CONFIG_RTE_LIBRTE_RING_DEBUG=n CONFIG_RTE_RING_PAUSE_REP_COUNT=0 #
doc/guides/prog_guide/ring_lib.rst +0 -7
@@ -110,13 +110,6 @@ Once an enqueue operation reaches the high water mark, the producer is notified, This mechanism can be used, for example, to exert a back pressure on I/O to inform the LAN to PAUSE. -Debug -~~~~~ - -When debug is enabled (CONFIG_RTE_LIBRTE_RING_DEBUG is set), -the library stores some per-ring statistic counters about the number of enqueues/dequeues. -These statistics are per-core to avoid concurrent accesses or atomic operations. - Use Cases ---------
doc/guides/rel_notes/release_17_05.rst +1 -0
@@ -133,6 +133,7 @@ API Changes have been made to it: * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` + * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` ABI Changes -----------
lib/librte_ring/rte_ring.c +0 -41
59 lines not on this page · raw message
lib/librte_ring/rte_ring.h +12 -85
183 lines not on this page · raw message
test/test/test_ring.c +0 -410
422 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v4 5/14 ring: remove the yield when waiting for tail update
In reply to Bruce RichardsonThere was a compile time setting to enable a ring to yield when it entered a loop in mp or mc rings waiting for the tail pointer update. Build time settings are not recommended for enabling/disabling features, and since this was off by default, remove it completely. If needed, a runtime enabled equivalent can be used.
--- config/common_base | 1 - doc/guides/prog_guide/env_abstraction_layer.rst | 5 ---- doc/guides/rel_notes/release_17_05.rst | 1 + lib/librte_ring/rte_ring.h | 35 +++++-------------------- 4 files changed, 7 insertions(+), 35 deletions(-)
config/common_base +0 -1
@@ -452,7 +452,6 @@ CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO=y # Compile librte_ring # CONFIG_RTE_LIBRTE_RING=y -CONFIG_RTE_RING_PAUSE_REP_COUNT=0 # # Compile librte_mempool
doc/guides/prog_guide/env_abstraction_layer.rst +0 -5
@@ -352,11 +352,6 @@ Known Issues 3. It MUST not be used by multi-producer/consumer pthreads, whose scheduling policies are SCHED_FIFO or SCHED_RR. - ``RTE_RING_PAUSE_REP_COUNT`` is defined for rte_ring to reduce contention. It's mainly for case 2, a yield is issued after number of times pause repeat. - - It adds a sched_yield() syscall if the thread spins for too long while waiting on the other thread to finish its operations on the ring. - This gives the preempted thread a chance to proceed and finish with the ring enqueue/dequeue operation. - + rte_timer Running ``rte_timer_manager()`` on a non-EAL pthread is not allowed. However, resetting/stopping the timer from a non-EAL pthread is allowed.
doc/guides/rel_notes/release_17_05.rst +1 -0
@@ -134,6 +134,7 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` + * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` ABI Changes -----------
lib/librte_ring/rte_ring.h +6 -29
@@ -114,11 +114,6 @@ enum rte_ring_queue_behavior {#define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \ sizeof(RTE_RING_MZ_PREFIX) + 1) -#ifndef RTE_RING_PAUSE_REP_COUNT -#define RTE_RING_PAUSE_REP_COUNT 0/**< Yield after pause num of times, no yield -* if RTE_RING_PAUSE_REP not defined. */ -#endif -struct rte_memzone ;/* forward declaration, so as not to require memzone.h */ #if RTE_CACHE_LINE_SIZE <128
@@ -393,7 +388,7 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,uint32_t cons_tail, free_entries;const unsigned max = n;int success; -unsigned i, rep =0 ; +unsigned int i;uint32_t mask = r->mask;int ret;
@@ -447,18 +442,9 @@ __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,* If there are other enqueues in progress that preceded us, * we need to wait for them to complete */ -while (unlikely (r->prod.tail != prod_head)) { +while (unlikely (r->prod.tail != prod_head))rte_pause (); -/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting -* for other thread finish. It gives pre-empted thread a chance -* to proceed and finish with ring dequeue operation. */ -if (RTE_RING_PAUSE_REP_COUNT && - ++rep ==RTE_RING_PAUSE_REP_COUNT ) { - rep =0 ; -sched_yield (); - } - } r->prod.tail = prod_next;return ret; }
@@ -491,7 +477,7 @@ __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table, {uint32_t prod_head, cons_tail;uint32_t prod_next, free_entries; -unsigned i; +unsigned int i;uint32_t mask = r->mask;int ret;
@@ -568,7 +554,7 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,uint32_t cons_next, entries;const unsigned max = n;int success; -unsigned i, rep =0 ; +unsigned int i;uint32_t mask = r->mask;/* Avoid the unnecessary cmpset operation below, which is also
@@ -613,18 +599,9 @@ __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,* If there are other dequeues in progress that preceded us, * we need to wait for them to complete */ -while (unlikely (r->cons.tail != cons_head)) { +while (unlikely (r->cons.tail != cons_head))rte_pause (); -/* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting -* for other thread finish. It gives pre-empted thread a chance -* to proceed and finish with ring dequeue operation. */ -if (RTE_RING_PAUSE_REP_COUNT && - ++rep ==RTE_RING_PAUSE_REP_COUNT ) { - rep =0 ; -sched_yield (); - } - } r->cons.tail = cons_next;return behavior ==RTE_RING_QUEUE_FIXED ?0 : n;
@@ -659,7 +636,7 @@ __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table, {uint32_t cons_head, prod_tail;uint32_t cons_next, entries; -unsigned i; +unsigned int i;uint32_t mask = r->mask; cons_head = r->cons.head;
Signature · 1 line
2.9.3
PATCH v4 6/14 ring: remove watermark support
In reply to Bruce RichardsonRemove the watermark support. A future commit will add support for having enqueue functions return the amount of free space in the ring, which will allow applications to implement their own watermark checks, while also being more useful to the app.
---
V2: fix missed references to watermarks in v1
--- doc/guides/prog_guide/ring_lib.rst | 8 -- doc/guides/rel_notes/release_17_05.rst | 2 + examples/Makefile | 2 +- lib/librte_ring/rte_ring.c | 23 ----- lib/librte_ring/rte_ring.h | 58 +------------ test/test/autotest_test_funcs.py | 7 -- test/test/commands.c | 52 ------------ test/test/test_ring.c | 149 +-------------------------------- 8 files changed, 8 insertions(+), 293 deletions(-)
doc/guides/prog_guide/ring_lib.rst +0 -8
@@ -102,14 +102,6 @@ Name A ring is identified by a unique name. It is not possible to create two rings with the same name (rte_ring_create() returns NULL if this is attempted). -Water Marking -~~~~~~~~~~~~~ - -The ring can have a high water mark (threshold). -Once an enqueue operation reaches the high water mark, the producer is notified, if the water mark is configured. - -This mechanism can be used, for example, to exert a back pressure on I/O to inform the LAN to PAUSE. - Use Cases ---------
doc/guides/rel_notes/release_17_05.rst +2 -0
@@ -135,6 +135,8 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_SPLIT_PROD_CONS`` * removed the build-time setting ``CONFIG_RTE_LIBRTE_RING_DEBUG`` * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` + * removed the function ``rte_ring_set_water_mark`` as part of a general + removal of watermarks support in the library. ABI Changes -----------
examples/Makefile +1 -1
@@ -81,7 +81,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += packet_ordering DIRS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ptpclient DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched -DIRS-y += quota_watermark +#DIRS-y += quota_watermark DIRS-$(CONFIG_RTE_ETHDEV_RXTX_CALLBACKS) += rxtx_callbacks DIRS-y += skeleton ifeq ($(CONFIG_RTE_LIBRTE_HASH),y)
lib/librte_ring/rte_ring.c +0 -23
@@ -138,7 +138,6 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count,if (ret <0 || ret >= (int )sizeof (r->name))return -ENAMETOOLONG ; r->flags = flags; - r->watermark = count; r->prod.single = !!(flags &RING_F_SP_ENQ ); r->cons.single = !!(flags &RING_F_SC_DEQ ); r->size = count;
@@ -256,24 +255,6 @@ rte_ring_free(struct rte_ring *r)rte_free (te); } -/* -* change the high water mark. If *count* is 0, water marking is -* disabled -*/ -int -rte_ring_set_water_mark (struct rte_ring *r,unsigned count) -{ -if (count >= r->size) -return -EINVAL ; - -/* if count is 0, disable the watermarking */ -if (count ==0 ) - count = r->size; - - r->watermark = count; -return 0 ; -} -/* dump the status of the ring on the console */ void rte_ring_dump (FILE *f,const struct rte_ring *r)
@@ -287,10 +268,6 @@ rte_ring_dump(FILE *f, const struct rte_ring *r)fprintf (f," ph=%" PRIu32"\n" , r->prod.head);fprintf (f," used=%u\n" ,rte_ring_count (r));fprintf (f," avail=%u\n" ,rte_ring_free_count (r)); -if (r->watermark == r->size) -fprintf (f," watermark=0\n" ); -else -fprintf (f," watermark=%" PRIu32"\n" , r->watermark); }/* dump the status of all rings on the console */
lib/librte_ring/rte_ring.h +2 -56
155 lines not on this page · raw message
test/test/autotest_test_funcs.py +0 -7
@@ -292,11 +292,4 @@ def ring_autotest(child, test_name): elif index == 2: return -1, "Fail [Timeout]" - child.sendline("set_watermark test 100") - child.sendline("dump_ring test") - index = child.expect([" watermark=100", - pexpect.TIMEOUT], timeout=1) - if index != 0: - return -1, "Fail [Bad watermark]" - return 0, "Success"
test/test/commands.c +0 -52
64 lines not on this page · raw message
test/test/test_ring.c +3 -146
179 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v4 7/14 ring: make bulk and burst fn return vals consistent
In reply to Bruce RichardsonThe bulk fns for rings returns 0 for all elements enqueued and negative for no space. Change that to make them consistent with the burst functions in returning the number of elements enqueued/dequeued, i.e. 0 or N. This change also allows the return value from enq/deq to be used directly without a branch for error checking.
--- doc/guides/rel_notes/release_17_05.rst | 11 +++ doc/guides/sample_app_ug/server_node_efd.rst | 2 +- examples/load_balancer/runtime.c | 16 ++- .../client_server_mp/mp_client/client.c | 8 +- .../client_server_mp/mp_server/main.c | 2 +- examples/qos_sched/app_thread.c | 8 +- examples/server_node_efd/node/node.c | 2 +- examples/server_node_efd/server/main.c | 2 +- lib/librte_mempool/rte_mempool_ring.c | 12 ++- lib/librte_ring/rte_ring.h | 109 +++++++-------------- test/test-pipeline/pipeline_hash.c | 2 +- test/test-pipeline/runtime.c | 8 +- test/test/test_ring.c | 46 +++++---- test/test/test_ring_perf.c | 8 +- 14 files changed, 106 insertions(+), 130 deletions(-)
doc/guides/rel_notes/release_17_05.rst +11 -0
@@ -137,6 +137,17 @@ API Changes * removed the build-time setting ``CONFIG_RTE_RING_PAUSE_REP_COUNT`` * removed the function ``rte_ring_set_water_mark`` as part of a general removal of watermarks support in the library. + * changed the return value of the enqueue and dequeue bulk functions to + match that of the burst equivalents. In all cases, ring functions which + operate on multiple packets now return the number of elements enqueued + or dequeued, as appropriate. The updated functions are: + + - ``rte_ring_mp_enqueue_bulk`` + - ``rte_ring_sp_enqueue_bulk`` + - ``rte_ring_enqueue_bulk`` + - ``rte_ring_mc_dequeue_bulk`` + - ``rte_ring_sc_dequeue_bulk`` + - ``rte_ring_dequeue_bulk`` ABI Changes -----------
doc/guides/sample_app_ug/server_node_efd.rst +1 -1
@@ -286,7 +286,7 @@ repeated infinitely. cl = &nodes[node]; if (rte_ring_enqueue_bulk(cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) != 0){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){ for (j = 0; j < cl_rx_buf[node].count; j++) rte_pktmbuf_free(cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
examples/load_balancer/runtime.c +7 -9
@@ -146,7 +146,7 @@ app_lcore_io_rx_buffer_to_send ( (void **) lp->rx.mbuf_out[worker].array, bsz); -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz; k ++) {struct rte_mbuf *m = lp->rx.mbuf_out[worker].array[k];
@@ -312,7 +312,7 @@ app_lcore_io_rx_flush(struct app_lcore_params_io *lp, uint32_t n_workers) (void **) lp->rx.mbuf_out[worker].array, lp->rx.mbuf_out[worker].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->rx.mbuf_out[worker].n_mbufs; k ++) {struct rte_mbuf *pkt_to_free = lp->rx.mbuf_out[worker].array[k];
@@ -349,9 +349,8 @@ app_lcore_io_tx( (void **) &lp->tx.mbuf_out[port].array[n_mbufs], bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - } n_mbufs += bsz_rd;
@@ -505,9 +504,8 @@ app_lcore_worker( (void **) lp->mbuf_in.array, bsz_rd); -if (unlikely (ret == -ENOENT )) { +if (unlikely (ret ==0 ))continue ; - }#if APP_WORKER_DROP_ALL_PACKETS for (j =0 ; j < bsz_rd; j ++) {
@@ -559,7 +557,7 @@ app_lcore_worker(#if APP_STATS lp->rings_out_iters[port] ++; -if (ret ==0 ) { +if (ret >0 ) { lp->rings_out_count[port] +=1 ; }if (lp->rings_out_iters[port] ==APP_STATS ){
@@ -572,7 +570,7 @@ app_lcore_worker( }#endif -if (unlikely (ret == -ENOBUFS )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < bsz_wr; k ++) {struct rte_mbuf *pkt_to_free = lp->mbuf_out[port].array[k];
@@ -609,7 +607,7 @@ app_lcore_worker_flush(struct app_lcore_params_worker *lp) (void **) lp->mbuf_out[port].array, lp->mbuf_out[port].n_mbufs); -if (unlikely (ret <0 )) { +if (unlikely (ret ==0 )) {uint32_t k;for (k =0 ; k < lp->mbuf_out[port].n_mbufs; k ++) {struct rte_mbuf *pkt_to_free = lp->mbuf_out[port].array[k];
examples/multi_process/client_server_mp/mp_client/client.c +2 -6
@@ -276,14 +276,10 @@ main(int argc, char *argv[])printf ("[Press Ctrl-C to quit ...]\n" );for (;;) { -uint16_t i, rx_pkts =PKT_READ_SIZE ; +uint16_t i, rx_pkts;uint8_t port; -/* try dequeuing max possible packets first, if that fails, get the -* most we can. Loop body should only execute once, maximum */ -while (rx_pkts >0 && -unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, rx_pkts) !=0 )) - rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE ); + rx_pkts =rte_ring_dequeue_burst (rx_ring, pkts,PKT_READ_SIZE );if (unlikely (rx_pkts ==0 )){if (need_flush)
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -227,7 +227,7 @@ flush_rx_queue(uint16_t client) cl = &clients[client];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[client].buffer, - cl_rx_buf[client].count) !=0 ){ + cl_rx_buf[client].count) ==0 ){for (j =0 ; j < cl_rx_buf[client].count; j++)rte_pktmbuf_free (cl_rx_buf[client].buffer[j]); cl->stats.rx_drop += cl_rx_buf[client].count;
examples/qos_sched/app_thread.c +5 -3
@@ -107,7 +107,7 @@ app_rx_thread(struct thread_conf **confs) }if (unlikely (rte_ring_sp_enqueue_bulk (conf->rx_ring, - (void **)rx_mbufs, nb_rx) !=0 )) { + (void **)rx_mbufs, nb_rx) ==0 )) {for (i =0 ; i < nb_rx; i++) {rte_pktmbuf_free (rx_mbufs[i]);
@@ -180,7 +180,7 @@ app_tx_thread(struct thread_conf **confs)while ((conf = confs[conf_idx])) { retval =rte_ring_sc_dequeue_bulk (conf->tx_ring, (void **)mbufs, burst_conf.qos_dequeue); -if (likely (retval ==0 )) { +if (likely (retval !=0 )) {app_send_packets (conf, mbufs, burst_conf.qos_dequeue); conf->counter =0 ;/* reset empty read loop counter */
@@ -230,7 +230,9 @@ app_worker_thread(struct thread_conf **confs) nb_pkt =rte_sched_port_dequeue (conf->sched_port, mbufs, burst_conf.qos_dequeue);if (likely (nb_pkt >0 )) -while (rte_ring_sp_enqueue_bulk (conf->tx_ring, (void **)mbufs, nb_pkt) !=0 ); +while (rte_ring_sp_enqueue_bulk (conf->tx_ring, + (void **)mbufs, nb_pkt) ==0 ) + ;/* empty body */ conf_idx++;if (confs[conf_idx] ==NULL )
examples/server_node_efd/node/node.c +1 -1
@@ -392,7 +392,7 @@ main(int argc, char *argv[])*/ while (rx_pkts >0 &&unlikely (rte_ring_dequeue_bulk (rx_ring, pkts, - rx_pkts) !=0 )) + rx_pkts) ==0 )) rx_pkts = (uint16_t )RTE_MIN (rte_ring_count (rx_ring),PKT_READ_SIZE );
examples/server_node_efd/server/main.c +1 -1
@@ -247,7 +247,7 @@ flush_rx_queue(uint16_t node) cl = &nodes[node];if (rte_ring_enqueue_bulk (cl->rx_q, (void **)cl_rx_buf[node].buffer, - cl_rx_buf[node].count) !=0 ){ + cl_rx_buf[node].count) != cl_rx_buf[node].count){for (j =0 ; j < cl_rx_buf[node].count; j++)rte_pktmbuf_free (cl_rx_buf[node].buffer[j]); cl->stats.rx_drop += cl_rx_buf[node].count;
lib/librte_mempool/rte_mempool_ring.c +8 -4
@@ -42,26 +42,30 @@ static int common_ring_mp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { - return rte_ring_mp_enqueue_bulk(mp->pool_data, obj_table, n); + return rte_ring_mp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sp_enqueue(struct rte_mempool *mp, void * const *obj_table, unsigned n) { -return rte_ring_sp_enqueue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sp_enqueue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_mc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_mc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_mc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static int common_ring_sc_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n) { -return rte_ring_sc_dequeue_bulk (mp->pool_data, obj_table, n); + return rte_ring_sc_dequeue_bulk(mp->pool_data, + obj_table, n) == 0 ? -ENOBUFS : 0; } static unsigned
lib/librte_ring/rte_ring.h +38 -71
264 lines not on this page · raw message
test/test-pipeline/pipeline_hash.c +1 -1
@@ -547,6 +547,6 @@ app_main_loop_rx_metadata(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }
test/test-pipeline/runtime.c +4 -4
@@ -98,7 +98,7 @@ app_main_loop_rx(void) { app.rings_rx[i], (void **) app.mbuf_rx.array, n_mbufs); - }while (ret <0 ); + }while (ret ==0 ); } }
@@ -123,7 +123,7 @@ app_main_loop_worker(void) { (void **) worker_mbuf->array, app.burst_size_worker_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; do {
@@ -131,7 +131,7 @@ app_main_loop_worker(void) { app.rings_tx[i ^1 ], (void **) worker_mbuf->array, app.burst_size_worker_write); - }while (ret <0 ); + }while (ret ==0 ); } }
@@ -152,7 +152,7 @@ app_main_loop_tx(void) { (void **) &app.mbuf_tx[i].array[n_mbufs], app.burst_size_tx_read); -if (ret == -ENOENT ) +if (ret ==0 )continue ; n_mbufs += app.burst_size_tx_read;
test/test/test_ring.c +22 -24
152 lines not on this page · raw message
test/test/test_ring_perf.c +4 -4
@@ -195,13 +195,13 @@ enqueue_bulk(void *p)const uint64_t sp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_sp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sp_end =rte_rdtsc ();const uint64_t mp_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mp_enqueue_bulk (r, burst, size) !=0 ) +while (rte_ring_mp_enqueue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mp_end =rte_rdtsc ();
@@ -230,13 +230,13 @@ dequeue_bulk(void *p)const uint64_t sc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_sc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_sc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t sc_end =rte_rdtsc ();const uint64_t mc_start =rte_rdtsc ();for (i =0 ; i < iterations; i++) -while (rte_ring_mc_dequeue_bulk (r, burst, size) !=0 ) +while (rte_ring_mc_dequeue_bulk (r, burst, size) ==0 )rte_pause ();const uint64_t mc_end =rte_rdtsc ();
Signature · 1 line
2.9.3