The rte_malloc() API documentation has the following to say about the align parameter:

"If 0, the return is a pointer that is suitably aligned for any kind of variable (in the same manner as malloc()). Otherwise, the return is a pointer that is a multiple of align. In this case, it must be a power of two. (Minimum alignment is the cacheline size, i.e. 64-bytes)"

After reading this, one might be left with the impression that the parenthesis refers to only the "otherwise" (non-zero-align) case, since surely, cache line alignment should be sufficient for any kind of variable and it semantics would be "in the same manner as malloc()".

However, in the actual RTE malloc implementation, any align parameter value less than RTE_CACHE_LINE_SIZE results in an alignment of RTE_CACHE_LINE_SIZE, unless I'm missing something.

Is there any conceivable scenario where passing a non-zero align parameter is useful?

Would it be an improvement to rephrase the documentation to:

"The alignment of the allocated memory meets all of the following criteria:
1) able to hold any built-in type.
2) be at least as large as the align parameter.
3) be at least as large as RTE_CACHE_LINE_SIZE.

The align parameter must be a power-of-2 or 0.
"

...so it actually describes what is implemented? And also adds the theoretical (?) case of a built-in type requiring > RTE_CACHE_LINE_SIZE amount of alignment.

Reply via email to