|
26 | 26 |
|
27 | 27 | // Besides returning ENOTSUP at runtime we do nothing if this define is missing.
|
28 | 28 | #if defined(NODE_ENABLE_LARGE_CODE_PAGES) && NODE_ENABLE_LARGE_CODE_PAGES
|
| 29 | +#include "debug_utils-inl.h" |
29 | 30 | #include "util.h"
|
30 | 31 | #include "uv.h"
|
31 | 32 |
|
@@ -97,11 +98,18 @@ struct text_region {
|
97 | 98 |
|
98 | 99 | static const size_t hps = 2L * 1024 * 1024;
|
99 | 100 |
|
100 |
| -static void PrintWarning(const char* warn) { |
| 101 | +template <typename... Args> |
| 102 | +inline void Debug(Args&&... args) { |
| 103 | + node::Debug(&per_process::enabled_debug_list, |
| 104 | + DebugCategory::HUGEPAGES, |
| 105 | + std::forward<Args>(args)...); |
| 106 | +} |
| 107 | + |
| 108 | +inline void PrintWarning(const char* warn) { |
101 | 109 | fprintf(stderr, "Hugepages WARNING: %s\n", warn);
|
102 | 110 | }
|
103 | 111 |
|
104 |
| -static void PrintSystemError(int error) { |
| 112 | +inline void PrintSystemError(int error) { |
105 | 113 | PrintWarning(strerror(error));
|
106 | 114 | }
|
107 | 115 |
|
@@ -152,13 +160,22 @@ struct text_region FindNodeTextRegion() {
|
152 | 160 | uintptr_t lpstub_start = reinterpret_cast<uintptr_t>(&__start_lpstub);
|
153 | 161 |
|
154 | 162 | if (dl_iterate_phdr(FindMapping, &dl_params) == 1) {
|
| 163 | + Debug("Hugepages info: start: %p - sym: %p - end: %p\n", |
| 164 | + reinterpret_cast<void*>(dl_params.start), |
| 165 | + reinterpret_cast<void*>(dl_params.reference_sym), |
| 166 | + reinterpret_cast<void*>(dl_params.end)); |
| 167 | + |
155 | 168 | dl_params.start = dl_params.reference_sym;
|
156 |
| - if (lpstub_start > dl_params.start && lpstub_start <= dl_params.end) |
| 169 | + if (lpstub_start > dl_params.start && lpstub_start <= dl_params.end) { |
| 170 | + Debug("Hugepages info: Trimming end for lpstub: %p\n", |
| 171 | + reinterpret_cast<void*>(lpstub_start)); |
157 | 172 | dl_params.end = lpstub_start;
|
| 173 | + } |
158 | 174 |
|
159 | 175 | if (dl_params.start < dl_params.end) {
|
160 | 176 | char* from = reinterpret_cast<char*>(hugepage_align_up(dl_params.start));
|
161 | 177 | char* to = reinterpret_cast<char*>(hugepage_align_down(dl_params.end));
|
| 178 | + Debug("Hugepages info: Aligned range is %p - %p\n", from, to); |
162 | 179 | if (from < to) {
|
163 | 180 | size_t pagecount = (to - from) / hps;
|
164 | 181 | if (pagecount > 0) {
|
@@ -261,6 +278,7 @@ struct text_region FindNodeTextRegion() {
|
261 | 278 | }
|
262 | 279 | }
|
263 | 280 | #endif
|
| 281 | + Debug("Hugepages info: Found %d huge pages\n", nregion.total_hugepages); |
264 | 282 | return nregion;
|
265 | 283 | }
|
266 | 284 |
|
|
0 commit comments