r/linuxquestions • u/beertown • 6d ago
Run processes at the lowest priority possible
Hi all! I have a little question for you.
Let's say my machine has 4 cores (4 physical and logical cores, no hyper-threading). I want to run 5 cpu-bound processes, but one of them should get CPU only when there's some to spare. I'm expecting seeing in top something like this:
process-1 99.9% cpu
process-2 99.9% cpu
process-3 99.9% cpu
process-4 99.9% cpu
process-5 0.4% cpu
All my processes are commands started from different terminals on my desktop.
On Ubuntu 22.04 (Linux 5.15.0) I can achive this setting sysctl kernel.sched_autogroup_enabled=0 and running my process 5 with nice -n 19. Works great.
Now I'm moving to Ubuntu 26.04 (Linux 7.0.0) and this doesn't work anymore, all my processes get 80% CPU no matter the niceness value.
I tried running process 5 with chrt --idle 0 , it has some effect but nowhere near what I'd like.
Why I want to to this? Because I regularily run many different cpu-bound workloads in different terminals, and I want some of them finish as soon as possible (normal priority), and others can last longer and I prefer them not to interfere (lowest priority) as long as there are normal priority processes running.
Is there a way to have truly low priority processes on recent kernels?
Edit: I don't have necessarily one normal-priority process for each core. For example, this is another possible use case where 5 processes take all the 4-core pie and a sixth process eats the crumbles:
process-1 79.9% cpu
process-2 79.9% cpu
process-3 79.9% cpu
process-4 79.9% cpu
process-5 79.9% cpu
process-6 0.5% cpu
4
u/ipsirc 6d ago
cpu.weight
3
u/polymath_uk_ 6d ago
You can pin processes to CPU cores (if you write the software yourself) which would be the thing to do for the first 4 processes. Process 5 can be unpinned and run with
nice 19meaning that it will only consume CPU from any of the 4 cores if those cores are not busy. For software you don't write yourself, see u/ipsirc 's comment.3
u/ol-gormsby 6d ago
You can constrain a process to get no more than a set amount of memory and a set percentage of CPU, but that doesn't sound like what you're after.
It's strange that "nice" values aren't working especially when they used to work. What does "top" report? If your low-priority process is getting a lot of resources, it might be because the other processes aren't demanding it? Is there a bottleneck somewhere, where a process is waiting on I/O or something else?
2
u/Difficult-Value-3145 6d ago edited 6d ago
I really want to know the cause of this is it a Linux issue or just Ubuntu cause this is taking control from the user and I'm not a fan unless it's op in.
I just did a bit of checking and if the actual bottleneck is IO then the lower priority process might get runtime as the higher priority process is blocked by IO speed . Ionice will give a program higher IO priority I'm gonna keep reading some stuff I may post if I. Find anything else out.
Edit : chrt manpage let's you both see and modify realtime prossese properties Might be why you want