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

On linux, __rust_probestack shouldn't be called on smallish stack allocations #74405

Closed
KyleSiefring opened this issue Jul 16, 2020 · 4 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@KyleSiefring
Copy link

On linux (x86_64), had a stack allocation that was "only" 8*4096 bytes causing __rust_probestack to be called. From what I understand from this, #43072, linux only needs to have the stack probed for much larger sizes.

Compiler version: Tested on 1.44.0, but a cursory glance in perf still shows __rust_probestack.

@nagisa
Copy link
Member

nagisa commented Jul 17, 2020

__rust_probestack being called for anything more than 1 typical page on the platform (4k on Linux) is expected. That's because when the guard page is 1 page large (true at least for non-main threads), then not probing could allow functions to jump over the guard.

All the linked PR does is not manually allocating said guard page on the main thread. I’m not sure what the relation between it and probing functionality is, other than the fact that both involve stacks and their guard pages.

@cuviper
Copy link
Member

cuviper commented Jul 17, 2020

With LLVM 11, I hope to switch to "probe-stack"="inline-asm", which avoids any call and supports more targets. That code uses a loop for large stack allocations, but also does unroll to a series of probes for small cases.

@cuviper cuviper added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Jul 17, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 16, 2021
Use probe-stack=inline-asm in LLVM 11+

Fixes (?) rust-lang#74405, related to rust-lang#43241

r? `@cuviper`
@vtjnash
Copy link

vtjnash commented Mar 16, 2021

Fixed?

@nagisa
Copy link
Member

nagisa commented Mar 16, 2021

We still probe at 4k increments, but I don't think this issue is otherwise actionable given the reasoning outlined above.

Thank you, Kyle, for the report and Jameson for a reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants