[PATCH 2/4] hash: use alloca instead of vla trivial
Morten Brørup
mb at smartsharesystems.com
Sat Apr 6 18:01:06 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() where
> dimension multiplier removed.
>
> Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
> ---
[...]
> {
> - uint32_t tmp_tuple[tuple_len / sizeof(uint32_t)];
> + uint32_t *tmp_tuple = alloca(tuple_len);
This code is in the rte_thash_adjust_tuple() function [1].
I think we could use a constant size array here, making it large enough for what we think would suffice for any realistic purpose.
The function could check the tuple_len parameter at runtime and return an error value if too big for the array.
It could also check the tuple_len parameter, if constant, at build time.
[1]: https://elixir.bootlin.com/dpdk/v24.03/source/lib/hash/rte_thash.c#L768
More information about the dev
mailing list