On Sat, 20 Dec 2025 14:15:17 +0800
Junlong Wang <[email protected]> wrote:

>  
> +static unsigned int
> +log2above(unsigned int v)
> +{
> +     unsigned int l;
> +     unsigned int r;
> +
> +     for (l = 0, r = 0; (v >> 1); ++l, v >>= 1)
> +             r |= (v & 1);
> +     return l + r;
> +}
> +

It is only used during initalization so performance is not a big issue,
but this could could be optimized by using the compiler builtins.

static uint32_t
log2above(uint32_t v)
{
        if (v <= 1)
                return 0;
        return 32 - __rte_clz32(v - 1);
}

Will merge as is.

Reply via email to