Skip to content

Commit

Permalink
Set the KMS scheduler to SCHED_FIFO max prio.
Browse files Browse the repository at this point in the history
- This might have a bigger impact when the kernel
  is patched with the real time kernel.
  • Loading branch information
larskj committed May 29, 2016
1 parent 6f3a78b commit ce597fe
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions gfx/drivers_context/drm_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#include "../../runloop.h"
#include "../common/drm_common.h"

#include <unistd.h>
#include <sched.h>

#ifdef HAVE_EGL
#include "../common/egl_common.h"
#endif
Expand Down Expand Up @@ -371,6 +374,37 @@ static void gfx_ctx_drm_destroy_resources(gfx_ctx_drm_data_t *drm)
g_next_bo = NULL;
}

static void set_to_sched_fifo_max_prio(void)
{
struct sched_param param = {0};

// Set highest possible priority for task
param.sched_priority = sched_get_priority_max(SCHED_FIFO);
if (sched_setscheduler(0, SCHED_FIFO, &param) < 0)
RARCH_ERR("[KMS/EGL]: Failed to set SCHED_FIFO priority.\n");

int sched = sched_getscheduler(getpid());

const char *scheduler;
switch (sched)
{
case SCHED_OTHER:
scheduler = "SCHED_OTHER";
break;

case SCHED_FIFO:
scheduler = "SCHED_FIFO";
break;

default:
scheduler = "Unrelated";
}

RARCH_LOG("[KMS/EGL]: Current scheduler: %s\n", scheduler);
if (sched == SCHED_FIFO)
RARCH_LOG("[KMS/EGL]: SCHED_FIFO prio: %d\n", param.sched_priority);
}

static void *gfx_ctx_drm_init(void *video_driver)
{
int fd, i;
Expand All @@ -384,6 +418,8 @@ static void *gfx_ctx_drm_init(void *video_driver)
if (!drm)
return NULL;

set_to_sched_fifo_max_prio();

fd = -1;
gpu_descriptors = dir_list_new("/dev/dri", NULL, false, false);

Expand Down

0 comments on commit ce597fe

Please sign in to comment.