Impact of processes on isolated CPU cores to processes run on common CPU cores

Hi Guys

On Rocky Linux 8 with kernel 4.18.0-372.9.1.rt7.166.el8.x86_64 I see an inexplicable influence of processes on cores isolated with Kernel cmdline to overall scheduling process of OS.

Kernel command line is the following:

[root@localhost ~]# cat /proc/cmdline
BOOT_IMAGE=(hd0,gpt2)/vmlinuz-4.18.0-372.9.1.rt7.166.el8.x86_64 root=/dev/mapper/centos-root ro rootflags=defaults,noatime,ikeep crashkernel=256M rd.lvm.lv=centos/root quiet panic=10 console=ttyS0,115200n8 isolcpus=nohz,domain,1-11,13-22 irqaffinity=0,12 selinux=0 enforcing=0 noswap mce=off audit=0 nmi_watchdog=0 fsck.mode=force fsck.repair=yes

I wrote simplest kthread which runs in infinite loop:

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/kthread.h>

int test_thread_fn(void *dev)
{
while (!kthread_should_stop()) {

};

return 0;

}

struct task_struct *test_worker_task;

static int test_module_init(void)
{
test_worker_task = kthread_create(test_thread_fn, NULL, “test_worker”);
wake_up_process(test_worker_task);
return 0;
}

static void test_module_exit(void)
{
kthread_stop(test_worker_task);
}

module_init(test_module_init);
module_exit(test_module_exit);

When i run dhclient without this kernel driver timing is the following:

[root@localhost ~]# time dhclient -r; time dhclient
Killed old client process

real 0m1.162s
user 0m0.026s
sys 0m0.044s

real 0m3.390s
user 0m0.054s
sys 0m0.097s

After loading driver i recheck dhclient timing:

[root@localhost ~]# insmod test/test.ko
[root@localhost ~]# time dhclient -r; time dhclient
Killed old client process

real 0m1.295s
user 0m0.025s
sys 0m0.026s

real 0m2.340s
user 0m0.042s
sys 0m0.086s

Now. I put the polling task to isolated core and it takes ten times more for dhclient to finish.

[root@localhost ~]# ps -aux | grep test
root 3531 98.0 0.0 0 0 ? R 19:46 0:17 [test_worker]
root 3621 0.0 0.0 221940 1084 ttyS0 S+ 19:46 0:00 grep --color=auto test
[root@localhost ~]# taskset -p 200 3531
pid 3531’s current affinity mask: ffffff
pid 3531’s new affinity mask: 200
[root@localhost ~]# time taskset 1 dhclient -r; time taskset 1 dhclient
Killed old client process

real 0m13.477s
user 0m0.024s
sys 0m0.028s
Could not get property: Failed to activate service ‘org.freedesktop.hostname1’: timed out (service_start_timeout=25000ms)

real 0m44.089s
user 0m0.046s
sys 0m0.077s

I don’t get it. Poll kthread runs on isolated CPU. Dhclient is run by taskset on CPU0 which is not isolated.
How it comes that kthread affects on scheduling of non-isolated CPU?

What am i missing?

Thanks in advance