The KMALLOC_MAX_SIZE value you’re seeing is a limitation inherent to the Linux kernel, particularly for allocations done with kmalloc() . This limit isn’t set by Toradex but by the kernel itself, primarily due to the way memory management works in the kernel space and it defined by CPU architecture. kmalloc() is designed for allocating small amounts of memory. It allocates memory from a contiguous region, which can become fragmented over time. As a result, allocating large chunks of memory with kmalloc() is generally discouraged, and the kernel imposes this limit to mitigate issues with fragmentation and to maintain efficiency.
You can use the vmalloc() to allocate non-contiguous memory. It’s more suitable for large memory allocations because it can gather memory from various places in physical memory and present it as a contiguous block to the user. However, accessing memory allocated by vmalloc() is slower compared to kmalloc() because of the additional layer of indirection. Another disadvantage of memory allocated by vmalloc() is its inability to be directly accessed by DMA.