Skip to content

Commit

Permalink
stress-cpu-sched: twiddle cpu slack on each timer reset
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Oct 13, 2024
1 parent 4a5e6e5 commit d0135ea
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions stress-cpu-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#if defined(__NR_set_mempolicy)
#define HAVE_SET_MEMPOLICY
#endif
#if defined(HAVE_SYS_PRCTL_H)
#include <sys/prctl.h>
#endif

#if defined(HAVE_LIB_RT) && \
defined(HAVE_TIMER_CREATE) && \
Expand Down Expand Up @@ -274,6 +277,10 @@ static void stress_cpu_sched_hrtimer_set(const long int nsec)
timer.it_interval.tv_nsec = nsec;
timer.it_interval.tv_sec = 0;
(void)timer_settime(timerid, 0, &timer, NULL);
#if defined(HAVE_SYS_PRCTL_H) && \
defined(PR_SET_TIMERSLACK)
(void)prctl(PR_SET_TIMERSLACK, stress_mwc16() * 10);
#endif
}
}

Expand Down Expand Up @@ -521,6 +528,10 @@ static int stress_cpu_sched_child(stress_args_t *args, void *context)

(void)context;

#if defined(HAVE_SYS_PRCTL_H) && \
defined(PR_SET_TIMERSLACK)
(void)prctl(PR_SET_TIMERSLACK, 5);
#endif
cpus = (int)stress_get_processors_configured();
if (cpus < 1)
cpus = 1;
Expand Down

0 comments on commit d0135ea

Please sign in to comment.