Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Memory alignment with vmalloc under linux kernel

adrien
Beginner
961 Views
Hello,

I keep getting the "Misaligned pointer in operation ..." warning from ippsFFTInitAlloc_R_16s. My free() function seems to be called automaticaly right after the failure but generates the kernel warning --> Trying to vfree() bad address . The vmalloced and vfree addresses are the same and are 32 bytes aligned. Thats what I don't understand. Any help is appreciated.

Thanks,
Adrien

void* malloc(int length)
{
void *ptr = (void*)0;
ptr = vmalloc(length + 32 + sizeof(void*));
if (ptr) {
void **ap = (void**)( ((unsigned long)(ptr) +
32 + sizeof(void*) - 1 ) & (~0x1F) );
ap[-1] = (void*)ptr;
return (void *)ap;
}else{
return NULL;
}
}

void free(void *ptr)
{
if( ptr )
vfree( ((void**)ptr)[-1] );
}

0 Kudos
5 Replies
Vladimir_Dudnik
Employee
961 Views

Hello,

IPP functions like InitAlloc requires appropriate IPP Free counterpart functon. For example,

ippsFFTInitAlloc_R_16s
and
ippsFFTFree_R_16s

Regards,
Vladimir

0 Kudos
adrien
Beginner
961 Views
Thanks Vladimir

Actually ,I get strange behaviour when calling ipp function in a kernel space. From previous post in the forum I read that the static lib are compiled with -fPIC and because of that, ipp libs cannot be used in a driver under linux. Is this still true? Can I compile a linux kernel module using the ipp static ipp libs?
0 Kudos
Vladimir_Dudnik
Employee
961 Views

Starting from IPP 5.1 we also include IPP static libraries compiled without -fPIC, especially for Linux kernel module developers. You can find them in ipp/lib/nonpic folder after you install IPP

Vladimir

0 Kudos
adrien
Beginner
961 Views
Ok great. Though, the nonpic version has no dispatcher library.
There is an example on how to use the merged static libraries for windows by creating static dispatching stubs to select the correct function. How can I do the same under Linux. I can't seem to find any example.

Thanks again
Adrien
0 Kudos
Vladimir_Dudnik
Employee
961 Views

Please find IPP product integration sample on IPP code samples page. It is available for both Windows and Linux.

Vladimir

0 Kudos
Reply