I want to add some information to this. When you set up two cores for one process, then you are talking to the scheduler. The scheduler has knowledge of the hardware, and unless you have two threads, there is almost no chance that both cores would be used since this would harm performance.
Each core has cache on it. Hitting that cache when it has the data it needs implies faster access. Using data when the cache does not have the data needed is a cache miss, and this can greatly slow things down. The scheduler knows this. A single process (or I should say the scheduler of a single process with multiple threads) will try to stick to one core in order to take advantage of cache hits.
Then there is also context switching. Every time a process is swapped out for another process, then all of the security information and registers have to be swapped out. That takes a lot of time. Threads do something similar, but they do not require changing security information because it is the same owner each time, and so swapping threads is lower overhead than swapping processes. It isn’t really relevant here, but there is an extension to this known as either coroutines or microthreads in which the program itself actually assists with break points which do almost nothing other than telling the scheduler that it is safe to jump from one point in a program to another, often in particle generators (it is a theme of reducing what has to be copied or stored to change what is being done).
What you’ve done is to make the process eligible for using those cores. The scheduler has determined it is faster to stick to one core. You’d need to manually intervene to switch cores, but this might not be faster.
I understand. Thank you for the information. However, I have tested that if instead of running 1 process I run 2 independent processes, it still only uses the first cpu.
The only way to make use of both cores is to remove isolcpus and then when I run taskset -c 1,2 the process is able to run on both cpus.
Your logic makes sense but in this case how can the scheduler decide to run on only 1 core at 100% and the other at 0% with isolcpus, but when i remove isolcpus (and run with taskset again) the scheduler decides to run both cores at 80% (which is what i want).
Have you tried specifically binding one of them to CPU core 1, and the other specifically to CPU core 2?
The isolcpus just tells the scheduler that the cores have no priority under any condition other than specifically assigning a process to that core (the cores are not disabled, but they are ignored until something designates to use that core). If you assign to both cores, then it is up to the scheduler to use its wisdom (which is usually wise, but not always) to decide which among the eligible cores to use. If you assign specifically to core 1 or core 2, then it should use that core if the core is possible (some hardware interrupts must route to CPU core 0, but most anything else can go anywhere).