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
Linux: Automatically increase vm.max_map_count if it's too low #4702
Conversation
Download the artifacts for this pull request: Experimental GUI (Avalonia)GUI-less (SDL2)Only for Developers
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sensible, though I'm not an expert on whether 262144
is high enough for all games. It would be nice if this stuff could be set when opening the main Ryujinx executable, too bad it can't.
|
||
madvise(address, size, MADV_REMOVE); | ||
if (madvise(address, size, MADV_REMOVE) != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope nothing else races to change permissions, otherwise these could crash the emulator where otherwise they did not. I suppose Decommit isn't used right now, so it's more a worry for another time...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we just return false instead of throwing everywhere here?
that kind of change the behavior of the function entirely... and the return value doesn't meaning anything anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaik Ryujinx would crash either way even if we return false here.
I mean it could be, but we might not be able to revert to defaults if Ryujinx crashes. |
Requesting both reviews, since I essentially changed the whole thing again. |
e37a3e1
to
a2ac505
Compare
a2ac505
to
c6f233d
Compare
// NOTE: This value was determined by manual tests and might need to be increased again. | ||
public const int RecommendedVmMaxMapCount = 524288; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure we can go lower here, but I'll need community testing to figure this out.
I don't have any of the games in the referenced issue and can't trigger it on my side.
c6f233d
to
4298390
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will this behave when Ryujinx is installed as a flatpak? I doubt that it'll be able to write sysctl.d config, not sure about the vm map count.
The flatpak probably wouldn't be able to do any of these things. 🤔 I'll need to think of something for that. :/ |
@riperiperi Currently flatpak users would see this warning (even if pkexec is installed, because it doesn't have access to it). Ideally we should use dbus to talk to polkitd, but I have no idea how to do that yet and it doesn't seem to be easy. |
4f51bf4
to
153cbaf
Compare
With GUI dialogs, this should be a bit more user-friendly.
153cbaf
to
a04d00b
Compare
Since this Ryujunx PR [1] ot returns a warning if vm.max_map_count < 524288, so just set an higher value. To be coherent with what other Linux distrubitions are doing, use 2147483642. This is the value used by Batocera 37 itself [2], SteamDeck and Fedora 39 [3]. There is not need to re-set the value each time yuzu or Ryujinx is started, so just set it once on startup. [1] Ryujinx/Ryujinx#4702 [2] batocera-linux/batocera.linux#8649 [3] https://fedoraproject.org/wiki/Changes/IncreaseVmMaxMapCount
Since this Ryujunx PR [1] ot returns a warning if vm.max_map_count < 524288, so just set an higher value. To be coherent with what other Linux distrubitions are doing, use 2147483642. This is the value used by Batocera 37 itself [2], SteamDeck and Fedora 39 [3]. There is not need to re-set the value each time yuzu or Ryujinx is started, so just set it once on startup. [1] Ryujinx/Ryujinx#4702 [2] batocera-linux/batocera.linux#8649 [3] https://fedoraproject.org/wiki/Changes/IncreaseVmMaxMapCount
Since this Ryujunx PR [1] it returns a warning if vm.max_map_count < 524288, so just set an higher value. To be coherent with what other Linux distrubitions are doing, use 2147483642. This is the value used by Batocera 37 itself [2], SteamDeck and Fedora 39 [3]. There is not need to re-set the value each time yuzu or Ryujinx is started, so just set it once on startup. [1] Ryujinx/Ryujinx#4702 [2] batocera-linux/batocera.linux#8649 [3] https://fedoraproject.org/wiki/Changes/IncreaseVmMaxMapCount
This PR adds a workaround for #3372 and result checking for memory related pinvoke calls.
If a game adds too many memory map areas Ryujinx will crash with a segmentation fault, which makes these issues difficult to debug.
But since @gdkchan was able to find the cause of this type of crash, we are able to temporarily increase
vm.max_map_count
while Ryujinx is running and reset it to the original value once Ryujinx was closed.The threshold value in the script is just the default value that the kernel documentation for
vm.max_map_count
suggested. This check is just supposed to make sure we aren't messing with the settings if the user has modified them already.Closes #4941