You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-2Lines changed: 28 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -67,16 +67,35 @@ You can schedule tasks to a given cpu with:
67
67
taskset --cpu-list 5 shasum /dev/zero
68
68
```
69
69
70
+
While this works properly for programs which spawn a single thread, this fails to work for a program launching multiple threads. This has been documented here [isolcpus_taskset_bug](https://bugzilla.kernel.org/show_bug.cgi?id=116701). As per the Linux kernel devs, `isolcpus` completely removes the cores from the scheduler. Thus the ideal way to work around this is by changing the scheduler for the running process from `SCHED_OTHER` (default) to something else. This can be done via the `chrt` command [chrt_ref](http://man7.org/linux/man-pages/man1/chrt.1.html).
Note that, this requires sudo. This ensures that the spawned processes are mapped to available hardware cores in your taskset. One point to be careful here is that if you are spawning more threads than hardware cores available, the performance might not be representative, as the scheduler used here is different from the Linux default.
77
+
78
+
### Removing RCU callbacks
79
+
Read-copy-update is a way to maintain shared data structures which are copied over when modified by one of the owners. In certain cases, this can cause the old copy to be unused and thus can be freed. This freeing process is carried out as part of the interrupt processing routines. Thus, it is possible to inform the kernel to not schedule these routines on the isolated cores. This can be done via the `rcu_nocbs` parameter, similar to `isolcpus`. Kernel command line reference [here](https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html). You can read more [here](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux_for_real_time/7/html/tuning_guide/offloading_rcu_callbacks)
80
+
81
+
Similar to `isolcpus`, we would add `rcu_nocbs=1,2,3,4,5` to `/etc/default/grub` and then run `sudo update-grub` to remove cores 1-5 from having to perform the RCU callback.
82
+
83
+
Further, despite cores having offloaded the actual callback, they still have to inform the callback cores to perform the callback. Adding the parameter `rcu_nocb_poll` to the kernel command line, relieves even this from the cores, as the the cores responsible for the callbacks poll for wakeup.
84
+
70
85
### Interrupts
71
86
72
87
You want to turn off the interrupt balancing and point everything at core 0. A simple way to acheive this is adding `ENABLED=0` to `/etc/default/irqbalance` on Ubuntu. On Ubuntu I found that you needed to still have the irqbalance service running for this to work; that is you need the `ENABLED=0` flag in the config and the service to execute seeing that flag.
73
88
74
89
You can check this is working with:
75
90
```watch cat /proc/interrupts```
76
91
92
+
Alternatively, you can set the command line parameter `irqaffinity=0,1,13,14` to ensure that interrupts are always routed to these cores. This can be checked as well by `cat /proc/interrupts` and you should see the interrupts on the non-affinity cores to be very low.
93
+
77
94
### nohz_full (tickless mode)
78
95
79
-
I didn't manage to make this work with a stock Ubuntu kernel. You can check it is working with:
96
+
This requires a recompile of the stock kernel. The kernel needs to be compiled with a configuration flag called - `CONF_NO_HZ_FULL` and then the command line param `nohz_full` can be added to `/etc/default/grub`.
0 commit comments