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

Function eal_memalloc_is_contig

dpdk/lib/eal/common/eal_common_memalloc.c:68–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68bool
69eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start,
70 size_t len)
71{
72 void *end, *aligned_start, *aligned_end;
73 size_t pgsz = (size_t)msl->page_sz;
74 const struct rte_memseg *ms;
75 const struct internal_config *internal_conf =
76 eal_get_internal_configuration();
77
78 /* for IOVA_VA, it's always contiguous */
79 if (rte_eal_iova_mode() == RTE_IOVA_VA && !msl->external)
80 return true;
81
82 /* for legacy memory, it's always contiguous */
83 if (internal_conf->legacy_mem)
84 return true;
85
86 end = RTE_PTR_ADD(start, len);
87
88 /* for nohuge, we check pagemap, otherwise check memseg */
89 if (!rte_eal_has_hugepages()) {
90 rte_iova_t cur, expected;
91
92 aligned_start = RTE_PTR_ALIGN_FLOOR(start, pgsz);
93 aligned_end = RTE_PTR_ALIGN_CEIL(end, pgsz);
94
95 /* if start and end are on the same page, bail out early */
96 if (RTE_PTR_DIFF(aligned_end, aligned_start) == pgsz)
97 return true;
98
99 /* skip first iteration */
100 cur = rte_mem_virt2iova(aligned_start);
101 expected = cur + pgsz;
102 aligned_start = RTE_PTR_ADD(aligned_start, pgsz);
103
104 while (aligned_start < aligned_end) {
105 cur = rte_mem_virt2iova(aligned_start);
106 if (cur != expected)
107 return false;
108 aligned_start = RTE_PTR_ADD(aligned_start, pgsz);
109 expected += pgsz;
110 }
111 } else {
112 int start_seg, end_seg, cur_seg;
113 rte_iova_t cur, expected;
114
115 aligned_start = RTE_PTR_ALIGN_FLOOR(start, pgsz);
116 aligned_end = RTE_PTR_ALIGN_CEIL(end, pgsz);
117
118 start_seg = RTE_PTR_DIFF(aligned_start, msl->base_va) /
119 pgsz;
120 end_seg = RTE_PTR_DIFF(aligned_end, msl->base_va) /
121 pgsz;
122
123 /* if start and end are on the same page, bail out early */
124 if (RTE_PTR_DIFF(aligned_end, aligned_start) == pgsz)
125 return true;

Callers 2

elem_check_phys_contigFunction · 0.85
alloc_pages_on_heapFunction · 0.85

Calls 5

rte_eal_iova_modeFunction · 0.85
rte_eal_has_hugepagesFunction · 0.85
rte_fbarray_getFunction · 0.85
rte_mem_virt2iovaFunction · 0.50

Tested by

no test coverage detected