Build the image from the Dockerfile in this gist while making sure sched.cc is available in the build directory. Then, run the following steps in a bash shell.
Run the container (please note this applies the suggestions from scylladb/seastar#382 (comment), that is runs as root in the container, and assigns the container the CAP_SYS_NICE capability):
docker run --cap-add=sys_nice --rm -it --user root --entrypoint /bin/bash 63eb9aaa36520fc08994f87caba98c90f18f86581bb95e4e98803732ceca08a6
Within the container:
root@7f39c815a0ad:/# capsh --print | grep Current: | grep sys_nic
Current: cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_sys_nice,cap_mknod,cap_audit_write,cap_setfcap=eip
That's good, cap_sys_nice is in the list of enabled capabilities.
Let's check kernel version (this, again, confirms we follow the best practice from scylladb/seastar#382 (comment)):
root@4c97290d99a5:/# uname -a
Linux 4c97290d99a5 5.10.76-linuxkit #1 SMP Mon Nov 8 10:21:19 UTC 2021 x86_64 GNU/Linux
Let's run the test program:
root@7f39c815a0ad:/# ./sched
created child thread: 1913747200
Unable to set SCHED_FIFO scheduling policy for timer thread; latency impact possible. Try adding CAP_SYS_NICE
The test program cannot set SCHED_FIFO - why?
For comparison, the same program on a host macOS Catalina 10.15.7:
$ ./sched
created child thread: 172994560
set scheduling policy SCHED_FIFO
I'm the child thread
Relevant issues: