0

I have one single-threaded process on server that I'd like to statically bind to one CPU core and give it all available computing power all the time (it's real-time process that is heavily affected by insufficient resources). Unfortunately machine is heavily overloaded so CPU is sitting at 60% CPU or more on average and process usually gets suffocated. I already assigned real-time round-robin priority 99 but it's still far from perfect.

How can I distribute all other processes to remaining 7 CPU cores at startup and leave one core dedicated for this one process? I'm talking about situation where all newly spawned processes are already bound to 7 cores from the start.

Lapsio
  • 363
  • 1
  • 5
  • 15

2 Answers2

1

Remove the cpu that you want to dedicate for your realtime process, using the kernel boot parameter isolcpus:

Remove the specified CPUs, as defined by the cpu_number values, from the general kernel SMP balancing and scheduler algroithms. The only way to move a process onto or off an "isolated" CPU is via the CPU affinity syscalls

If you are using a distro with systemd, you could could use CPUAffinity in your service unit

c4f4t0r
  • 5,301
  • 3
  • 31
  • 42
  • Unfortunately my version of systemd doesn't support CPUAffinity parameter yet, i tried that before but i got message that "unknown paremeter CPUAffinity something something". It's pretty old kernel and systemd version (from time of kernel 3.x). But I'll try isolcpus and report results, thanks – Lapsio Apr 24 '20 at 23:08
  • isolcpus works exactly as I expected, thenks :) – Lapsio Apr 25 '20 at 16:20
0

I have never done this so it's just a suggestion.

It seems that the taskset configuration is inherited. So you could as early as possible in the boot process make such a setting for PID 1 so that everything SystemD starts after that would use just those cores:

taskset -p 0x7F 1

Or you don't care at what point in the boot process this happens and just iterate over all existing processes.

Don't forget to change the setting for your special application...

Hauke Laging
  • 5,285
  • 2
  • 24
  • 40