Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: use __executable_start for linux hugepages #31547

Closed
wants to merge 3 commits into from

Conversation

bnoordhuis
Copy link
Member

__executable_start is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the INSERT BEFORE directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between &__executable_start and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: #31520

`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: nodejs#31520
@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. c++ Issues and PRs that require attention from people who are familiar with C++. labels Jan 28, 2020
@nodejs-github-bot
Copy link
Collaborator

@bnoordhuis
Copy link
Member Author

bnoordhuis commented Jan 28, 2020

https://ci.nodejs.org/job/node-test-commit-linux-containered/nodes=ubuntu1804_sharedlibs_shared_x64/17715/console

05:17:03 /home/iojs/build/workspace/node-test-commit-linux-containered/./node: symbol lookup error: /home/iojs/build/workspace/node-test-commit-linux-containered/out/Release/lib.target/libnode.so.81: undefined symbol: __executable_start
05:17:03 /home/iojs/build/workspace/node-test-commit-linux-containered/./node: symbol lookup error: /home/iojs/build/workspace/node-test-commit-linux-containered/out/Release/lib.target/libnode.so.81: undefined symbol: __executable_start
05:17:03 ./node: symbol lookup error: /home/iojs/build/workspace/node-test-commit-linux-containered/out/Release/lib.target/libnode.so.81: undefined symbol: __executable_start

I'm 99% sure this is caused by node.gyp adding node_large_page.cc to the wrong target. It should only be added to the target that builds the binary, not libnode.so.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@devsnek
Copy link
Member

devsnek commented Jan 28, 2020

I believe this also fixes #31249

@bnoordhuis
Copy link
Member Author

@devnexen Can you take a look at the last commit? That check makes me think that large pages aren't actually working on freebsd.

I believe this also fixes #31249

@devsnek You're right, it does.

Copy link
Contributor

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but will probably break other platforms.

@bnoordhuis
Copy link
Member Author

@devnexen It shouldn't. The linker scripts weren't used outside of linux and there have been no functional changes to the non-linux code.

(Small white lie, I made a tiny bug fix. Before, r.from == &MoveTextRegionToLargePages bailed out. As that's the only symbol in .lpstub it seems like a likely condition.)

The reason I think it doesn't work on freebsd (with or without this patch) is that it wants .lpstub mapped below .text, but the binary seems to crash without the aforementioned guard, suggesting that .text <= .lpstub.

@Trott
Copy link
Member

Trott commented Feb 1, 2020

@bnoordhuis Seems OK to land this? Or did you want to gather more information about what is or isn't going on with FreeBSD first?

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Feb 1, 2020

@bnoordhuis
Copy link
Member Author

@Trott Yep, this is good to go. The works/works not thing on freebsd was more of a heads-up for @devnexen.

addaleax pushed a commit that referenced this pull request Feb 1, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: #31520

PR-URL: #31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
@addaleax
Copy link
Member

addaleax commented Feb 1, 2020

Landed in 938abd9

@addaleax addaleax closed this Feb 1, 2020
@addaleax
Copy link
Member

addaleax commented Feb 1, 2020

Any chance this CI failure is related? I haven't seen it before.

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

null !== 0

    at Object.<anonymous> (/home/iojs/build/workspace/node-test-commit-linux/nodes/alpine-latest-x64/test/parallel/test-startup-large-pages.js:13:10)
    at Module._compile (internal/modules/cjs/loader.js:1208:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1228:10)
    at Module.load (internal/modules/cjs/loader.js:1057:32)
    at Function.Module._load (internal/modules/cjs/loader.js:952:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: null,
  expected: 0,
  operator: 'strictEqual'
}

(from https://ci.nodejs.org/job/node-test-commit-linux/32614/nodes=alpine-latest-x64/testReport/junit/(root)/test/parallel_test_startup_large_pages/)

@bnoordhuis
Copy link
Member Author

Yes, it's possible. I'll open a PR that adds logging to the test. I suspect the binary is crashing but the test hides that.

bnoordhuis added a commit to bnoordhuis/io.js that referenced this pull request Feb 2, 2020
The test starts child processes. A recent change is suspected of causing
flaky crashes on one of the alpine buildbots but we can't know for sure
because the test hides the child's stderr.

Refs: nodejs#31547 (comment)
addaleax pushed a commit that referenced this pull request Feb 2, 2020
The test starts child processes. A recent change is suspected of causing
flaky crashes on one of the alpine buildbots but we can't know for sure
because the test hides the child's stderr.

Refs: #31547 (comment)

PR-URL: #31612
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@bnoordhuis
Copy link
Member Author

I've been going through the CI runs for the alpine buildbots since last week and that test failure doesn't seem to have happened again. 🤷‍♂

codebytere pushed a commit that referenced this pull request Feb 17, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: #31520

PR-URL: #31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
codebytere pushed a commit that referenced this pull request Feb 17, 2020
The test starts child processes. A recent change is suspected of causing
flaky crashes on one of the alpine buildbots but we can't know for sure
because the test hides the child's stderr.

Refs: #31547 (comment)

PR-URL: #31612
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@codebytere codebytere mentioned this pull request Feb 17, 2020
@BethGriggs BethGriggs added baking-for-lts PRs that need to wait before landing in a LTS release. and removed baking-for-lts PRs that need to wait before landing in a LTS release. labels Feb 27, 2020
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Mar 6, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: nodejs#31520

PR-URL: nodejs#31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this pull request Apr 9, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: nodejs#31520

PR-URL: nodejs#31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
@targos
Copy link
Member

targos commented Apr 18, 2020

depends on large pages change to land on v12.x

targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: nodejs#31520

Backport-PR-URL: nodejs#32092
PR-URL: nodejs#31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
The test starts child processes. A recent change is suspected of causing
flaky crashes on one of the alpine buildbots but we can't know for sure
because the test hides the child's stderr.

Refs: nodejs#31547 (comment)

PR-URL: nodejs#31612
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos pushed a commit that referenced this pull request Apr 28, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: #31520

Backport-PR-URL: #32092
PR-URL: #31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
targos pushed a commit that referenced this pull request Apr 28, 2020
The test starts child processes. A recent change is suspected of causing
flaky crashes on one of the alpine buildbots but we can't know for sure
because the test hides the child's stderr.

Refs: #31547 (comment)

PR-URL: #31612
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@richardlau
Copy link
Member

Removing the lts-watch-v10.x label as we decided not to backport the hugepages changes to 10.x: #31105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. c++ Issues and PRs that require attention from people who are familiar with C++.