All of lore.kernel.org
 help / color / mirror / Atom feed
* Bug or works as intended: signal behaviour on -RT
@ 2018-09-26 15:07 Ralf Ramsauer
  2018-10-03 15:51 ` Thomas Gleixner
  2018-10-05 11:07 ` Sebastian Andrzej Siewior
  0 siblings, 2 replies; 3+ messages in thread
From: Ralf Ramsauer @ 2018-09-26 15:07 UTC (permalink / raw)
  To: linux-rt-users

[-- Attachment #1: Type: text/plain, Size: 1043 bytes --]

Hi,

If I set the SCHED_FIFO schedular, register a SIGALRM handler, set an
alarm() and consume 100% of CPU time on an isolated CPU (IOW, never
leave running/runable), the signal will never arrive in userspace.
According to /proc/timer_list the expiration time will become a negative
value.

But if I synchronously send a SIGALRM via kill, it will immediately
arrive. Even a sched_yield() in the busy loop won't help. In order to
get the signal, I have to leave running/runable with usleep().

Now I'm not sure if this behaviour is intended for some reason or if
it's a bug. Please find a minimal example attached. Run it on an
isolated CPU with taskset.

Reproduceable with 4.14.x-rt and latest -rt. Not reproducable with
mainline Linux and PREEMPT.

Thanks
  Ralf

(How I found this: I'm currently using stress-ng as a stressor for some
cyclictest measurements. stress-ng fork()s stressors. Stressors can be
parameterised by a timeout, which is implemented as alarm(). The timeout
will never occur, as stressors never leave Running/Runable.)

[-- Attachment #2: sigalrm.c --]
[-- Type: text/x-csrc, Size: 644 bytes --]

#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sched.h>
#include <string.h>

static volatile bool stop;

static void alarm_handler(int sig)
{
	printf("Woof woof!\n");
	stop = true;
}

int main(void) {
	struct sched_param sp;
	int ret;

	memset(&sp, 0, sizeof(sp));
	sp.sched_priority = 12;
	ret = sched_setscheduler(0, SCHED_FIFO, &sp);
	if (ret != 0) {
		printf("Error setting scheduler\n");
		return -1;
	}

	if (signal(SIGALRM, alarm_handler) == SIG_ERR) {
		printf("\ncan't catch SIGINT\n");
		return -1;
	}

	alarm(5);
	while (!stop) {}

	return 0;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-05 18:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-26 15:07 Bug or works as intended: signal behaviour on -RT Ralf Ramsauer
2018-10-03 15:51 ` Thomas Gleixner
2018-10-05 11:07 ` Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.