2

I want to set the process to the lowest possible scheduling on Linux. I came up with the following:

nice -n 39 ionice -c 3 chrt -i 0 command

Are there also other settings that one can set for a process to "lower" the process priority? Are these settings the "lowest" possible?

More often than not, I do make -j$(nproc) or cmake or heavy tar processes that take full available I/O, memory and CPU on my machine. What is really frustrating, is that my mouse starts lagging. So I want to prevent it.

KamilCuk
  • 850
  • 8
  • 16
  • One word, because I'm on phone and can't write an answer: cgroups2 – Marcus Müller May 13 '23 at 19:42
  • from `man nice`: Niceness values range from -20 (most favorable to the process) to 19 (least favorable to the process). So replace 20 with 19. – sudodus May 13 '23 at 20:01
  • @MarcusMüller I do not think I can affect cgroups2 as a normal user. Is there a way to set cpu_shares of a single command as a normal user? – KamilCuk May 13 '23 at 21:28
  • @sudodus you are right, but it should be +39, in case we start from -20. But I think niceness is getting ignored because chrt sets the process to SCHED_IDLE. Would be nice to get confirmation on that - thus the quesiton. – KamilCuk May 13 '23 at 21:28
  • @KamilCuk you should indeed be able to slice off new cgroups from your user slice, as unprivileged user. But the devil's in the details, usually... – Marcus Müller May 13 '23 at 22:40
  • Well , technically , Setting to the lowest Possible Priority is to terminate the Process , thereby ensuring that it is never even Scheduled to Execute ! [[ Every Other Process will have higher Priority to get Scheduled & then get Executed ! ]] – Prem May 14 '23 at 06:50
  • 1
    In Ubuntu 18.04 ``man sched`` contains ``SCHED_IDLE can be used only at static priority 0; the process nice value has no influence for this policy.``. I.e. since ``chrt -i 0`` is used to set a scheduling policy of ``SCHED_IDLE`` don't think the initial ``nice -n 39`` to set the nice value is necessary. – Chester Gillon May 14 '23 at 07:36

1 Answers1

3

You can check the results (except for the I/O scheduling) of whatever you do with:

/bin/ps -eo pid,rtprio,class,pri,ni,args

As a regular user you get access to Systemd limits (or at least some of them) with

systemd-run --user --nice=18 sleep 1234 # see --property=
Hauke Laging
  • 88,146
  • 18
  • 125
  • 174
  • The problem with `systemd-run` like with `-Pt` is that it does not correctly preserve the exit status when receiving a signal. Except for that it is a great tool for that. – KamilCuk May 14 '23 at 12:23