The DPDK function rte_malloc returns NULL while no allocation is made yet

Viewed 83

This is my code:

int main(int argc, char *argv[]) {
    rte_eal_init(argc, argv);
    size_t size = 1000;
    void *p = rte_malloc(NULL, size, 0);
    printf("p: %p\n", p);
    return 0;
}

It's wonderful that I get the following output:

p: (nil)

I didn't forget to reserve huge pages and dpdk-hugepages.py -s shows that.

What may be the problem?

1 Answers

After minor fix in the code, I am able to get the pseudo code up and running properly.

Code:

$ cat test.c
#include <stdio.h>
#include <rte_eal.h>
#include <rte_malloc.h>

int main(int argc, char *argv[]) {
    int ret = rte_eal_init(argc, argv);

    if (ret >= 0) {
        size_t size = 1000;
        void *p = rte_malloc(NULL, size, 0);
        printf("p: %p\n", p);
    }

     return ret;
}
  1. Static DPDK Library Compile: gcc test.c $(pkg-config --cflags --libs libdpdk --static)
  2. Dynamic DPDK Library Compile: gcc test.c $(pkg-config --cflags --libs libdpdk)
  3. Run: sudo ./a.out -l 1 --no-pci --log-level=8

Logs:

$ sudo ./a.out -l 1 --no-pci --log-level=8
EAL: Detected CPU lcores: 128
EAL: Detected NUMA nodes: 2
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: VFIO support initialized
TELEMETRY: No legacy callbacks, legacy socket not created
**p: 0x17ffd5b00**
Related