MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_realloc_numa

Function test_realloc_numa

dpdk/app/test/test_malloc.c:629–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627}
628
629static int
630test_realloc_numa(void)
631{
632 /* check realloc_socket part */
633 int32_t socket_count = 0, socket_allocated, socket;
634 void *ptr1, *ptr2;
635 int ret = -1;
636 size_t size = 1024;
637
638 ptr1 = NULL;
639 for (socket = 0; socket < RTE_MAX_NUMA_NODES; socket++) {
640 if (is_mem_on_socket(socket)) {
641 int j = 2;
642
643 socket_count++;
644 while (j--) {
645 /* j == 1 -> resizing */
646 ptr2 = rte_realloc_socket(ptr1, size,
647 RTE_CACHE_LINE_SIZE,
648 socket);
649 if (ptr2 == NULL) {
650 printf("NULL pointer returned from rte_realloc_socket\n");
651 goto end;
652 }
653
654 ptr1 = ptr2;
655 socket_allocated = addr_to_socket(ptr2);
656 if (socket_allocated != socket) {
657 printf("Requested socket (%d) doesn't mach allocated one (%d)\n",
658 socket, socket_allocated);
659 goto end;
660 }
661 size += RTE_CACHE_LINE_SIZE;
662 }
663 }
664 }
665
666 /* Print warning if only a single socket, but don't fail the test */
667 if (socket_count < 2)
668 printf("WARNING: realloc_socket test needs memory on multiple sockets!\n");
669
670 ret = 0;
671end:
672 rte_free(ptr1);
673 return ret;
674}
675
676static int
677test_realloc(void)

Callers 1

test_reallocFunction · 0.85

Calls 5

is_mem_on_socketFunction · 0.85
rte_realloc_socketFunction · 0.85
addr_to_socketFunction · 0.85
rte_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected