MCPcopy Create free account
hub / github.com/apache/trafficserver / do_alloc_stack

Method do_alloc_stack

src/iocore/eventsystem/UnixEventProcessor.cc:196–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196void *
197ThreadAffinityInitializer::do_alloc_stack(size_t stacksize)
198{
199 size_t pagesize = ats_hugepage_enabled() ? ats_hugepage_size() : ats_pagesize();
200 int stackguard_pages;
201 REC_ReadConfigInteger(stackguard_pages, "proxy.config.thread.default.stackguard_pages");
202 ink_release_assert(stackguard_pages >= 0);
203
204 size_t size = INK_ALIGN(stacksize + stackguard_pages * pagesize, pagesize);
205 int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
206#ifdef MAP_HUGETLB
207 if (ats_hugepage_enabled()) {
208 mmap_flags |= MAP_HUGETLB;
209 }
210#endif
211 void *stack_and_guard = mmap(nullptr, size, PROT_READ | PROT_WRITE, mmap_flags, -1, 0);
212 if (stack_and_guard == MAP_FAILED) {
213 Error("Failed to allocate stack pages: size = %zu", size);
214 return nullptr;
215 }
216
217 setup_stack_guard(stack_and_guard, stackguard_pages);
218
219 void *stack_begin = static_cast<char *>(stack_and_guard) + stackguard_pages * pagesize;
220 Dbg(dbg_ctl_iocore_thread, "Allocated %zu bytes (%zu bytes in guard pages) for stack {%p-%p guard, %p-%p stack}", size,
221 stackguard_pages * pagesize, stack_and_guard, stack_begin, stack_begin, static_cast<char *>(stack_begin) + stacksize);
222
223 return stack_begin;
224}
225
226#if TS_USE_HWLOC
227void

Callers 2

alloc_numa_stackMethod · 0.95
alloc_stackMethod · 0.95

Calls 4

ats_hugepage_enabledFunction · 0.85
ats_hugepage_sizeFunction · 0.85
ats_pagesizeFunction · 0.85
ErrorClass · 0.50

Tested by

no test coverage detected