rpcs3 icon indicating copy to clipboard operation
rpcs3 copied to clipboard

Failed to set RLIMIT_MEMLOCK size to 2 GiB

Open shenada opened this issue 5 years ago • 11 comments

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

shenada avatar Nov 23 '20 19:11 shenada

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

AniLeo avatar Nov 23 '20 19:11 AniLeo

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.

shenada avatar Nov 23 '20 19:11 shenada

That's up to @Nekotekina

AniLeo avatar Nov 23 '20 19:11 AniLeo

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

shenada avatar Nov 23 '20 19:11 shenada

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.~~

ghost avatar Nov 23 '20 21:11 ghost

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.

ghost avatar Nov 24 '20 07:11 ghost

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...

ghost avatar Nov 24 '20 07:11 ghost

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...

ghost avatar Nov 24 '20 07:11 ghost

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.

JulianGro avatar May 01 '21 19:05 JulianGro

For Archlinux:

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

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

toccata10 avatar Jan 13 '22 18:01 toccata10

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.

Dritzii avatar Jun 07 '24 08:06 Dritzii

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

I'm on nobara and I do not have a thing that says hard memlock and soft memlock. It looks like this:

#* soft core 0 #* hard rss 10000 #@student hard nproc 20 #@faculty soft nproc 20 #@faculty hard nproc 50 #ftp hard nproc 0 #@student - maxlogins 4

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

I'm on nobara and I do not have a thing that says hard memlock and soft memlock. It looks like this:

#* soft core 0 #* hard rss 10000 #@Student hard nproc 20 #@faculty soft nproc 20 #@faculty hard nproc 50 #ftp hard nproc 0 #@Student - maxlogins 4

You'll need to ask Nobara folks about this. They have a discord.

kd-11 avatar Mar 10 '25 10:03 kd-11

@shenada is that still an issue?

digant73 avatar Oct 26 '25 15:10 digant73

This should be closed imo, the issue is already known to have a solution

YuriNator557 avatar Oct 26 '25 17:10 YuriNator557

This should be closed imo, the issue is already known to have a solution

stupid question, but why can't a solution be baked in to the emulator so we have this fixed out of the box?

This should be closed imo, the issue is already known to have a solution

stupid question, but why can't a solution be baked in to the emulator so we have this fixed out of the box?

Because it's not RPCS3's or any other software's role to modify your system's root-only config files to override security.conf values.

AniLeo avatar Nov 13 '25 01:11 AniLeo