From 6b72001f99934926481051b2dd43a5d635e8f713 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 3 May 2018 20:10:07 +0000 Subject: [PATCH] Use virtual instead of profile time for vmprofile Avoids infinite looping due to system call restarts triggered by SIGPROF handling. Virtual time doesn't account for time spent in the kernel handling system calls but Snabb tries to avoid spending time in system calls. (cherry picked from commit c4681a6c59f705fc49368bc1ae8fdc3fbbeee685) --- src/lj_vmprofile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lj_vmprofile.c b/src/lj_vmprofile.c index d9b64a9a63..1e035bc6f5 100644 --- a/src/lj_vmprofile.c +++ b/src/lj_vmprofile.c @@ -88,11 +88,11 @@ static void start_timer(int interval) struct sigaction sa; tm.it_value.tv_sec = tm.it_interval.tv_sec = interval / 1000; tm.it_value.tv_usec = tm.it_interval.tv_usec = (interval % 1000) * 1000; - setitimer(ITIMER_PROF, &tm, NULL); + setitimer(ITIMER_VIRTUAL, &tm, NULL); sa.sa_flags = SA_SIGINFO | SA_RESTART; sa.sa_sigaction = vmprofile_signal; sigemptyset(&sa.sa_mask); - sigaction(SIGPROF, &sa, &state.oldsa); + sigaction(SIGVTALRM, &sa, &state.oldsa); } static void stop_timer() @@ -100,8 +100,8 @@ static void stop_timer() struct itimerval tm; tm.it_value.tv_sec = tm.it_interval.tv_sec = 0; tm.it_value.tv_usec = tm.it_interval.tv_usec = 0; - setitimer(ITIMER_PROF, &tm, NULL); - sigaction(SIGPROF, NULL, &state.oldsa); + setitimer(ITIMER_VIRTUAL, &tm, NULL); + sigaction(SIGVTALRM, NULL, &state.oldsa); } /* -- State that the application can manage via FFI ----------------------- */