From de88d6c18796ad31edd1dbf4af102c4b05c64684 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 17 Jul 2019 19:26:14 +0100 Subject: [PATCH] src: large pages fix FreeBSD fix region size Makes the size aligned to huge page size by calculating it from the aligned lower and upper boundary of the executable address. PR-URL: https://github.com/nodejs/node/pull/28735 Reviewed-By: Rod Vagg Reviewed-By: Ben Noordhuis Reviewed-By: Rich Trott --- src/large_pages/node_large_page.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/large_pages/node_large_page.cc b/src/large_pages/node_large_page.cc index e6829708aa0803..d87ccfaa26abcd 100644 --- a/src/large_pages/node_large_page.cc +++ b/src/large_pages/node_large_page.cc @@ -199,12 +199,14 @@ static struct text_region FindNodeTextRegion() { (entry->kve_protection & KVME_PROT_EXEC)); if (!strcmp(exename.c_str(), entry->kve_path) && excmapping) { - size_t size = entry->kve_end - entry->kve_start; + char* estart = + reinterpret_cast(hugepage_align_up(entry->kve_start)); + char* eend = + reinterpret_cast(hugepage_align_down(entry->kve_end)); + size_t size = eend - estart; nregion.found_text_region = true; - nregion.from = - reinterpret_cast(hugepage_align_up(entry->kve_start)); - nregion.to = - reinterpret_cast(hugepage_align_down(entry->kve_end)); + nregion.from = estart; + nregion.to = eend; nregion.total_hugepages = size / hps; break; }