[LAU] memlock limits not set correctly?

Jacek Konieczny jajcus at jajcus.net
Sat Jan 19 15:49:38 CET 2019


On 19/01/2019 02.29, Michael Jarosch wrote:
> Am Freitag, den 18.01.2019, 13:43 +0000 schrieb John Davis:
> 
>> So "ulimit -l unlimited" should set max locked mem to unlimited (both
>> soft
>> and hard [if root]).
>>
>> "ulimit -Sl unlimited" sets soft limit only.
> 
> Thanks a lot!
> What's that hard- and soft-limit for?
> Or to be more concrete: Is a soft limit of any use in realtime audio?

Hard limit is the limit set by administrator (actually by a parent
process with right privileges), soft limit can be freely changed by a
user or application, but can never exceed the hard limit.

Locking too much memory or running a rogue process with real-time
priority can harm whole system, for all user, up to the point a hard
reboot is needed. That is why by default no real-time priorities are
allowed and locking memory is very limited.

System administrator may raise the hard limit, so users (or their
application) can increase the soft limit, but until they do, the
application are still limited to the soft limit.

In case of audio purposes the soft limit (set lower than the hard limit)
doesn't matter much, as it can only be reached when application actively
tries to use it – uses real time processing and locks memory for that.
If we want to use that, we need the soft limit be set high-enough,
probably up to the hard limit, which is set to the same value. It won't
affect other legitimate application and malicious app could increase the
soft limit up to the hard limit anyway.

For other limits, like 'number of open files' or 'amount of memory used'
the soft limit setting is more useful, as users can use that to prevent
applications from misbehaving – so a memory-leaking application crashes,
before whole system start lagging, or a select()-call-using aplication
won't break after opening 1025th file. Those affect all applications but
usually are not required to be set above usual values.


Jacek


More information about the Linux-audio-user mailing list