| 811 | bool exact; |
| 812 | }; |
| 813 | static int |
| 814 | alloc_seg_walk(const struct rte_memseg_list *msl, void *arg) |
| 815 | { |
| 816 | struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; |
| 817 | struct alloc_walk_param *wa = arg; |
| 818 | struct rte_memseg_list *cur_msl; |
| 819 | size_t page_sz; |
| 820 | int cur_idx, start_idx, j, dir_fd = -1; |
| 821 | unsigned int msl_idx, need, i; |
| 822 | const struct internal_config *internal_conf = |
| 823 | eal_get_internal_configuration(); |
| 824 | |
| 825 | if (msl->page_sz != wa->page_sz) |
| 826 | return 0; |
| 827 | if (msl->socket_id != wa->socket) |
| 828 | return 0; |
| 829 | |
| 830 | page_sz = (size_t)msl->page_sz; |
| 831 | |
| 832 | msl_idx = msl - mcfg->memsegs; |
| 833 | cur_msl = &mcfg->memsegs[msl_idx]; |
| 834 | |
| 835 | need = wa->n_segs; |
| 836 | |
| 837 | /* try finding space in memseg list */ |
| 838 | if (wa->exact) { |
| 839 | /* if we require exact number of pages in a list, find them */ |
| 840 | cur_idx = rte_fbarray_find_next_n_free(&cur_msl->memseg_arr, 0, |
| 841 | need); |
| 842 | if (cur_idx < 0) |
| 843 | return 0; |
| 844 | start_idx = cur_idx; |
| 845 | } else { |
| 846 | int cur_len; |
| 847 | |
| 848 | /* we don't require exact number of pages, so we're going to go |
| 849 | * for best-effort allocation. that means finding the biggest |
| 850 | * unused block, and going with that. |
| 851 | */ |
| 852 | cur_idx = rte_fbarray_find_biggest_free(&cur_msl->memseg_arr, |
| 853 | 0); |
| 854 | if (cur_idx < 0) |
| 855 | return 0; |
| 856 | start_idx = cur_idx; |
| 857 | /* adjust the size to possibly be smaller than original |
| 858 | * request, but do not allow it to be bigger. |
| 859 | */ |
| 860 | cur_len = rte_fbarray_find_contig_free(&cur_msl->memseg_arr, |
| 861 | cur_idx); |
| 862 | need = RTE_MIN(need, (unsigned int)cur_len); |
| 863 | } |
| 864 | |
| 865 | /* do not allow any page allocations during the time we're allocating, |
| 866 | * because file creation and locking operations are not atomic, |
| 867 | * and we might be the first or the last ones to use a particular page, |
| 868 | * so we need to ensure atomicity of every operation. |
| 869 | * |
| 870 | * during init, we already hold a write lock, so don't try to take out |
nothing calls this directly
no test coverage detected