[v2] examples/multi_proces: fix Rx packets distribution

Message ID 20211109095847.7642-1-getelson@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] examples/multi_proces: fix Rx packets distribution |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Gregory Etelson Nov. 9, 2021, 9:58 a.m. UTC
  MP servers distributes Rx packets between clients according to
round-robin scheme.

Current implementation always started packets distribution from
the first client. That procedure resulted in uniform distribution
in cases when Rx packets number was around clients number
multiplication. However, if RX burst repeatedly returned single
packet, round-robin scheme would not work because all packets
were assigned to the first client only.

The patch does not restart packets distribution from
the first client.
Packets distribution always continues to the next client.

Cc: stable@dpdk.org

Fixes: af75078fece3 ("first public release")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
v2: Remove explisit static variable initialization.
---
 examples/multi_process/client_server_mp/mp_server/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Nov. 9, 2021, 11:35 a.m. UTC | #1
09/11/2021 10:58, Gregory Etelson:
> -	uint8_t client = 0;
> +	/*
> +	 * C99: All objects with static storage duration
> +	 * shall be initialized (set to their initial values) before
> +	 * program startup.
> +	 */

Why adding this comment?

> +	static uint8_t client;
  
Gregory Etelson Nov. 9, 2021, 11:49 a.m. UTC | #2
Hello Thomas,

> 09/11/2021 10:58, Gregory Etelson:
> > -     uint8_t client = 0;
> > +     /*
> > +      * C99: All objects with static storage
> duration
> > +      * shall be initialized (set to their initial
> values) before
> > +      * program startup.
> > +      */
> 
> Why adding this comment?
> 
> > +     static uint8_t client;
> 
> 

C99 optimization that was used here is not obvious.
The patch relies on client=0 initialization.
I added the comment to clarify why the client was not initialized.
  
Thomas Monjalon Nov. 9, 2021, 2:17 p.m. UTC | #3
09/11/2021 12:49, Gregory Etelson:
> Hello Thomas,
> 
> > 09/11/2021 10:58, Gregory Etelson:
> > > -     uint8_t client = 0;
> > > +     /*
> > > +      * C99: All objects with static storage
> > duration
> > > +      * shall be initialized (set to their initial
> > values) before
> > > +      * program startup.
> > > +      */
> > 
> > Why adding this comment?
> > 
> > > +     static uint8_t client;
> > 
> > 
> 
> C99 optimization that was used here is not obvious.
> The patch relies on client=0 initialization.
> I added the comment to clarify why the client was not initialized.

I think it is the C standard, not only C99.
As far as I know, having static as 0 is obvious for a lot of people.
  

Patch

diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/examples/multi_process/client_server_mp/mp_server/main.c
index b4761ebc7b..31e7e76706 100644
--- a/examples/multi_process/client_server_mp/mp_server/main.c
+++ b/examples/multi_process/client_server_mp/mp_server/main.c
@@ -234,7 +234,12 @@  process_packets(uint32_t port_num __rte_unused,
 		struct rte_mbuf *pkts[], uint16_t rx_count)
 {
 	uint16_t i;
-	uint8_t client = 0;
+	/*
+	 * C99: All objects with static storage duration
+	 * shall be initialized (set to their initial values) before
+	 * program startup.
+	 */
+	static uint8_t client;
 
 	for (i = 0; i < rx_count; i++) {
 		enqueue_rx_packet(client, pkts[i]);