You are not logged in.

#1 2021-01-12 18:59:22

lano1106
Member
From: Canada, Montreal
Registered: 2012-11-22
Posts: 95
Website

[SOLVED] Cannot increase priority limits (ulimit)

Hi,

I have a hard time changing the ulimit priority. I want to be able, as a regular user, to increase the priority of my processes. This part of linux sysadmin seems to not be well documented and the error message isn't helping telling me what is stopping me to do what I want.

Here is the attempt:

lano1106@me-lenovo ~ $ ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 29185
max locked memory           (kbytes, -l) 1024
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1024
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 29185
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited
lano1106@me-lenovo ~ $ ulimit -e unlimited
-bash: ulimit: scheduling priority: cannot modify limit: Operation not permitted
lano1106@me-lenovo ~ :( $ tail /etc/security/limits.conf 

#*               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
lano1106         hard    priority        unlimited
# End of file

What am I missing?

Last edited by lano1106 (2021-01-17 00:09:26)

Offline

#2 2021-01-12 19:45:04

EdeWolf
Member
Registered: 2016-01-06
Posts: 79

Re: [SOLVED] Cannot increase priority limits (ulimit)

Now, I cannot answer your question, but as a workaround, you may want to consider sudo. And, just as a test, you may create a unit file and see, wether this works. It does for me, hence my recommandation. Just as a test, not as a solution to ulimit:

[Unit]
Description=Prio test

[Service]
Type=simple

User=lano1106
Group=users

LimitRTPRIO=96


# make a simple shellscript, running a loop, just to observe its priority
ExecStart=/usr/bin/someloop

Again, this does not solve your problem, but it may help narrowing down the problem.

Offline

#3 2021-01-12 20:12:51

lano1106
Member
From: Canada, Montreal
Registered: 2012-11-22
Posts: 95
Website

Re: [SOLVED] Cannot increase priority limits (ulimit)

EdeWolf,

thank you a lot for your input. Correct as root, I can modify priority limit but something is stopping me from doing so as my regular user.

As a sidenote, rtprio is a different beast than priority. rtprio is for SCHED_FIFO and SCHED_RR (RT scheduling) vs priority is for the non-rt scheduling SCHED_OTHER.

Another question that I have related to priority limit, it is that its range is from -20 to 19. How does that translate to ulimit settings since the highest priority is in fact the lowest value?

Offline

#4 2021-01-12 20:56:01

rowdog
Member
From: East Texas
Registered: 2009-08-19
Posts: 118

Re: [SOLVED] Cannot increase priority limits (ulimit)

I believe you want to use "nice" rather than "priority" in limits.conf
"nice" lets you adjust priorities while "priority" can be used to change your default priority. Neither of those uses "unlimited" as a valid value. See
https://man.archlinux.org/man/core/pam/limits.conf.5.en

Offline

#5 2021-01-13 03:40:34

lano1106
Member
From: Canada, Montreal
Registered: 2012-11-22
Posts: 95
Website

Re: [SOLVED] Cannot increase priority limits (ulimit)

rowdog,

you are correct. you solved my mystery. I'm taking good note of the man page.

So what does the priority field is doing? it sets the user default priority value while nice is actually setting the limit value?

Last edited by lano1106 (2021-01-13 03:40:52)

Offline

#7 2021-01-13 21:53:21

lano1106
Member
From: Canada, Montreal
Registered: 2012-11-22
Posts: 95
Website

Re: [SOLVED] Cannot increase priority limits (ulimit)

FYI,

setting nice in /etc/security/limits.conf did fix my problem. However, I still observe some weird peculiar details.

as a regular user, when I query soft and hard limits for nice (ulimit -Se and ulimit -He), the range returned is 0-40 and I cannot execute ulimit -e unlimited
However, as root, I can set ulimit -e unlimited...

[root@cloud48395 ~]# ulimit -He
0
[root@cloud48395 ~]# ulimit -Se
0
[root@cloud48395 ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 773560
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 62987
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@cloud48395 ~]# ulimit -e unlimited
[root@cloud48395 ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 773560
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 62987
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@cloud48395 ~]#
$ ulimit -e unlimited
bash: ulimit: scheduling priority: cannot modify limit: Operation not permitted
lano1106@whippet2 ~ :( $ 


$ ulimit -He
40
lano1106@whippet2 ~/dev/kraken $ ulimit -e 40
lano1106@whippet2 ~/dev/kraken $ ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 40
file size                   (blocks, -f) unlimited
pending signals                     (-i) 128127
max locked memory           (kbytes, -l) 1024
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1024
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 128127
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

Offline

#8 2021-01-13 22:54:24

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: [SOLVED] Cannot increase priority limits (ulimit)

man limits.conf wrote:


           nice
               maximum nice priority allowed to raise to (Linux 2.6.12 and higher) values:
               [-20,19]

       All items support the values -1, unlimited or infinity indicating no limit, except for
       priority, nice, and nonewprivs.

Fyi, highest priority is -20 [sic!], lowest is 19.
https://unix.stackexchange.com/question … e-niceness

Offline

#9 2021-01-17 00:04:29

lano1106
Member
From: Canada, Montreal
Registered: 2012-11-22
Posts: 95
Website

Re: [SOLVED] Cannot increase priority limits (ulimit)

Seth,

I am fully aware of what you say.

in my limits.conf file, I did set nice to -20.

However, for some weird reasons, the offered range by ulimit, is 0-40... I did read in the Michael Kerrisk TLPI book that because the -1 value is reserved to indicate an error, the associated ulimit system call range value is 0-40 and glibc substract 20 to the result to provide to the end-user the expected -20 to 19 values.

I suspect that this is what happens between what is set in limits.conf file and what ulimit returns but I did fail to find some clear confirmation on that in the documentation. ulimit is a builtin function in bash, right? Who is reading limits.conf? systemd?

My second remark is:

As root, you can set ulimit -e to unlimited, as a regular user, you are limited to a numerical value... I find this weird and unconsistent... Who is responsible for that? bash devs?

Last edited by lano1106 (2021-01-17 00:08:48)

Offline

#10 2021-01-17 00:52:46

loqs
Member
Registered: 2014-03-06
Posts: 17,196

Re: [SOLVED] Cannot increase priority limits (ulimit)

See https://git.kernel.org/pub/scm/linux/ke … hed/prio.h for the implementation details of converting nice to prio
Also https://git.kernel.org/pub/scm/linux/ke … rnel/sys.c for setpriority and getpriority

limits.conf is read by pam_limits.so as was noted in the man page rowdog linked to.
systemd can also set priority see LimitNICE in man 5 systemd.exec
Edit:
It is bash not allowing RLIM_INFINITY for none root see http://git.savannah.gnu.org/cgit/bash.g … ulimit.def

Last edited by loqs (2021-01-17 01:14:07)

Offline

Board footer

Powered by FluxBB