Skip to content

Commit

Permalink
src: reduce large pages code duplication
Browse files Browse the repository at this point in the history
Declaring and initializing a `struct text_region` is common to all
three implementations of the large pages mapping code. Let's make it
unconditional.

PR-URL: #31385
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: JungMinu - Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Gus Caplan <me@gus.host>
  • Loading branch information
Gabriel Schulhof authored and codebytere committed Mar 17, 2020
1 parent 2750e65 commit 8f88d62
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/large_pages/node_large_page.cc
Expand Up @@ -100,16 +100,15 @@ inline uintptr_t hugepage_align_down(uintptr_t addr) {
// This is also handling the case where the first line is not the binary.

static struct text_region FindNodeTextRegion() {
struct text_region nregion;
nregion.found_text_region = false;
#if defined(__linux__)
std::ifstream ifs;
std::string map_line;
std::string permission;
std::string dev;
char dash;
uintptr_t start, end, offset, inode;
struct text_region nregion;

nregion.found_text_region = false;

ifs.open("/proc/self/maps");
if (!ifs) {
Expand Down Expand Up @@ -161,9 +160,6 @@ static struct text_region FindNodeTextRegion() {

ifs.close();
#elif defined(__FreeBSD__)
struct text_region nregion;
nregion.found_text_region = false;

std::string exename;
{
char selfexe[PATH_MAX];
Expand Down Expand Up @@ -220,8 +216,6 @@ static struct text_region FindNodeTextRegion() {
start += cursz;
}
#elif defined(__APPLE__)
struct text_region nregion;
nregion.found_text_region = false;
struct vm_region_submap_info_64 map;
mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64;
vm_address_t addr = 0UL;
Expand Down

0 comments on commit 8f88d62

Please sign in to comment.