[v2] examples/multi_proces: fix Rx packets distribution
Checks
Commit Message
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
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;
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.
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.
@@ -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]);