| 152 | } |
| 153 | |
| 154 | static int |
| 155 | test_memzone_reserve_flags(void) |
| 156 | { |
| 157 | const struct rte_memzone *mz; |
| 158 | struct walk_arg wa; |
| 159 | int hugepage_2MB_avail, hugepage_1GB_avail; |
| 160 | int hugepage_16MB_avail, hugepage_16GB_avail; |
| 161 | const size_t size = 100; |
| 162 | |
| 163 | memset(&wa, 0, sizeof(wa)); |
| 164 | |
| 165 | rte_memseg_list_walk(find_available_pagesz, &wa); |
| 166 | |
| 167 | hugepage_2MB_avail = wa.hugepage_2MB_avail; |
| 168 | hugepage_1GB_avail = wa.hugepage_1GB_avail; |
| 169 | hugepage_16MB_avail = wa.hugepage_16MB_avail; |
| 170 | hugepage_16GB_avail = wa.hugepage_16GB_avail; |
| 171 | |
| 172 | /* Display the availability of 2MB ,1GB, 16MB, 16GB pages */ |
| 173 | if (hugepage_2MB_avail) |
| 174 | printf("2MB Huge pages available\n"); |
| 175 | if (hugepage_1GB_avail) |
| 176 | printf("1GB Huge pages available\n"); |
| 177 | if (hugepage_16MB_avail) |
| 178 | printf("16MB Huge pages available\n"); |
| 179 | if (hugepage_16GB_avail) |
| 180 | printf("16GB Huge pages available\n"); |
| 181 | /* |
| 182 | * If 2MB pages available, check that a small memzone is correctly |
| 183 | * reserved from 2MB huge pages when requested by the RTE_MEMZONE_2MB flag. |
| 184 | * Also check that RTE_MEMZONE_SIZE_HINT_ONLY flag only defaults to an |
| 185 | * available page size (i.e 1GB ) when 2MB pages are unavailable. |
| 186 | */ |
| 187 | if (hugepage_2MB_avail) { |
| 188 | mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_2M"), |
| 189 | size, SOCKET_ID_ANY, RTE_MEMZONE_2MB); |
| 190 | if (mz == NULL) { |
| 191 | printf("MEMZONE FLAG 2MB\n"); |
| 192 | return -1; |
| 193 | } |
| 194 | if (mz->hugepage_sz != RTE_PGSIZE_2M) { |
| 195 | printf("hugepage_sz not equal 2M\n"); |
| 196 | return -1; |
| 197 | } |
| 198 | if (rte_memzone_free(mz)) { |
| 199 | printf("Fail memzone free\n"); |
| 200 | return -1; |
| 201 | } |
| 202 | |
| 203 | mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_2M_HINT"), |
| 204 | size, SOCKET_ID_ANY, |
| 205 | RTE_MEMZONE_2MB|RTE_MEMZONE_SIZE_HINT_ONLY); |
| 206 | if (mz == NULL) { |
| 207 | printf("MEMZONE FLAG 2MB\n"); |
| 208 | return -1; |
| 209 | } |
| 210 | if (mz->hugepage_sz != RTE_PGSIZE_2M) { |
| 211 | printf("hugepage_sz not equal 2M\n"); |
no test coverage detected