We've been using libvirt based containers under CentOS 7 and everything
has been working fine. One application we run in our containers is ctdb,
which uses SCHED_FIFO (real time) threads. This has been working without
problems until our recent upgrade to CentOS 7.3. For some reason, ctdb
is no longer able to create real time threads, and I've tried a simple
program myself that confirms this. The same program works fine on the
hypervisor so I know the kernel supports real time. Does anyone know
what may have changed in CentOS 7.3 that breaks real time threads in
libvirt containers?
This is the simple test program I created to verify the real time
threads are failing. This same program works in a libvirt container in
CentOS 7.2.
#include <stdio.h>
#include <string.h>
#include <pthread.h>
pthread_t test_thread;
void *test(void *arg)
{
printf("Starting thread\n");
sleep(1);
printf("Thread complete\n");
return 0;
}
int main(int argc, char *argv[])
{
int rc;
printf("Starting main\n");
struct sched_param tsparam;
pthread_attr_t tattr;
memset(&tsparam, 0, sizeof(tsparam));
pthread_attr_init(&tattr);
pthread_attr_setinheritsched(&tattr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&tattr, SCHED_FIFO);
tsparam.sched_priority = sched_get_priority_max(SCHED_FIFO) - 7;
pthread_attr_setschedparam(&tattr, &tsparam);
if ((rc = pthread_create(&test_thread, &tattr, test, NULL)) != 0) {
printf("Unable to start rt thread\n");
}
return 0;
}