[PATCH 1/4] latencystats: use alloca instead of vla trivial
Morten Brørup
mb at smartsharesystems.com
Sat Apr 6 17:28:12 CEST 2024
> From: Tyler Retzlaff [mailto:roretzla at linux.microsoft.com]
> Sent: Thursday, 4 April 2024 19.15
>
> RFC sample illustrating simple conversion of VLA to alloca().
>
> Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
> ---
[...]
> --- a/lib/latencystats/rte_latencystats.c
> +++ b/lib/latencystats/rte_latencystats.c
> @@ -159,7 +159,7 @@ struct latency_stats_nameoff {
> {
> unsigned int i, cnt = 0;
> uint64_t now;
> - float latency[nb_pkts];
> + float *latency = alloca(sizeof(float) * nb_pkts);
In cases where we are processing packet bursts, I would prefer introducing a global #define RTE_MAX_PKT_BURST_SIZE, indicating the max packet burst size supported by libraries and drivers.
For reference, rte_config.h already has #define RTE_GRAPH_BURST_SIZE 256.
Such a common define should also be used by functions such as rte_pktmbuf_free_bulk(); although it also supports segmented packets, so it must still be able to handle more mbufs.
https://elixir.bootlin.com/dpdk/v24.03/source/lib/mbuf/rte_mbuf.c#L486
More information about the dev
mailing list