RPCS3 / rpcs3

PlayStation 3 emulator and debugger
https://rpcs3.net/
GNU General Public License v2.0
15.44k stars 1.92k forks source link

Failed to set RLIMIT_MEMLOCK size to 2 GiB #9328

Open shenada opened 3 years ago

shenada commented 3 years ago
RPCS3: v0.0.13-11300-f1c65dce
Linux: 5.9.8-200.fc33.x86_64
=====================================================================
Warning message:
Failed to set RLIMIT_MEMLOCK size to 2 GiB. Try to update your system configuration.
=====================================================================

Most of Linux distribution won't come with large RLIMIT_MEMLOCK by default. (Linux kernel default is 64KiB) If we need large non-swapped memory by setting ulimit we should provide more useful message and document it. Or try to use HugePages 1Gx2 just like qemu or KVM (Better performance but also not come with default). https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt https://github.com/libhugetlbfs/libhugetlbfs

AniLeo commented 3 years ago

Should be added to wiki, yes

For those reading this issue, edit /etc/security/limits.conf and set hard / soft memlock limits to either 2 GiB in bytes or unlimited

*        hard    memlock        unlimited
*        soft    memlock        unlimited
shenada commented 3 years ago

Should be added to wiki, yes

For those reading this issue, edit /etc/security/limits.conf and set hard / soft memlock limits to either 2 GiB in bytes or unlimited

*        hard    memlock        unlimited
*        soft    memlock        unlimited

What if we migrate to HugePages which provides much better performance and much lower TLB cache load.

AniLeo commented 3 years ago

That's up to @Nekotekina

shenada commented 3 years ago

That's up to @Nekotekina

Sure, indeed. But, just make sure he know we had this option. About why HugePage: https://en.wikipedia.org/wiki/Translation_lookaside_buffer

Nekotekina commented 3 years ago

We need to lock small pages for texture cache to work. I also reserve several 1G pages for my vm, didn't notice performance improvement. Memory is still slower than native.

Nekotekina commented 3 years ago

Configuring is trivial ­— just edit /etc/security/limits.conf. 64K is some outdated over-precautious limitation from 1990's era. We have many cheap RAM and locking few GiBs of it can NOT be a problem. Also, we don't lock absolutely everything, those numbers of virtual memory used by RPCS3 are not really used memory, it's just a bunch of almost-empty contiguous mappings.

Nekotekina commented 3 years ago

Also, doing it "like KVM" can't be an optimization for RPCS3, it's only a necessity because of another TLB on top of it (VM's own's one). We don't emulate like this, we use system TLB. How much we thrash it is another question, though...

Nekotekina commented 3 years ago

But I'm not an expert and I'd like to hear more opinions on that. Like if I could somehow get 2GiB worth of hugepages WITHOUT configuring system...

JulianGro commented 3 years ago

Has there actually been any issues because of that? I am asking because in my case it didn't make any difference between running and not running a game. Had 64KiB and now set it to 3GB. Had to restart the machine instead of just logging out and back in, which might be good to know.

toccata10 commented 2 years ago

For Archlinux:

Install realtime-privileges and add your own user to the realtime group >

from [https://wiki.archlinux.org/title/PipeWire#Increasing_RLIMIT_MEMLOCK]

Dritzii commented 5 months ago

Should be added to wiki, yes

For those reading this issue, edit /etc/security/limits.conf and set hard / soft memlock limits to either 2 GiB in bytes or unlimited

*        hard    memlock        unlimited
*        soft    memlock        unlimited

This works on my setup.