| 32 | } |
| 33 | |
| 34 | static int |
| 35 | alloc_seg(struct rte_memseg *ms, void *requested_addr, int socket_id, |
| 36 | struct hugepage_info *hi) |
| 37 | { |
| 38 | HANDLE current_process; |
| 39 | unsigned int numa_node; |
| 40 | size_t alloc_sz; |
| 41 | void *addr; |
| 42 | rte_iova_t iova = RTE_BAD_IOVA; |
| 43 | PSAPI_WORKING_SET_EX_INFORMATION info; |
| 44 | PSAPI_WORKING_SET_EX_BLOCK *page; |
| 45 | |
| 46 | if (ms->len > 0) { |
| 47 | /* If a segment is already allocated as needed, return it. */ |
| 48 | if ((ms->addr == requested_addr) && |
| 49 | (ms->socket_id == socket_id) && |
| 50 | (ms->hugepage_sz == hi->hugepage_sz)) { |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | /* Bugcheck, should not happen. */ |
| 55 | RTE_LOG(DEBUG, EAL, "Attempted to reallocate segment %p " |
| 56 | "(size %zu) on socket %d", ms->addr, |
| 57 | ms->len, ms->socket_id); |
| 58 | return -1; |
| 59 | } |
| 60 | |
| 61 | current_process = GetCurrentProcess(); |
| 62 | numa_node = eal_socket_numa_node(socket_id); |
| 63 | alloc_sz = hi->hugepage_sz; |
| 64 | |
| 65 | if (requested_addr == NULL) { |
| 66 | /* Request a new chunk of memory from OS. */ |
| 67 | addr = eal_mem_alloc_socket(alloc_sz, socket_id); |
| 68 | if (addr == NULL) { |
| 69 | RTE_LOG(DEBUG, EAL, "Cannot allocate %zu bytes " |
| 70 | "on socket %d\n", alloc_sz, socket_id); |
| 71 | return -1; |
| 72 | } |
| 73 | } else { |
| 74 | /* Requested address is already reserved, commit memory. */ |
| 75 | addr = eal_mem_commit(requested_addr, alloc_sz, socket_id); |
| 76 | |
| 77 | /* During commitment, memory is temporary freed and might |
| 78 | * be allocated by different non-EAL thread. This is a fatal |
| 79 | * error, because it breaks MSL assumptions. |
| 80 | */ |
| 81 | if ((addr != NULL) && (addr != requested_addr)) { |
| 82 | RTE_LOG(CRIT, EAL, "Address %p occupied by an alien " |
| 83 | " allocation - MSL is not VA-contiguous!\n", |
| 84 | requested_addr); |
| 85 | return -1; |
| 86 | } |
| 87 | |
| 88 | if (addr == NULL) { |
| 89 | RTE_LOG(DEBUG, EAL, "Cannot commit reserved memory %p " |
| 90 | "(size %zu) on socket %d\n", |
| 91 | requested_addr, alloc_sz, socket_id); |
no test coverage detected