sched: optimize prio for kernel RT thread and kworker

In some cases, there are too much userspace high priority RT threads, which
cause kernel RT threads or kworkers block too long time. This config separate
kernel and userspace RT threads into two priority regions, priority 0~49 for
kernel and priority 50~99 for userspace, so that kernel RT threads is always
higher priority than userspace. This config also set RT policy for kworkers.

Change-Id: I87e03915dc0dd03cbcd91d211d2ef56c301451f9
Signed-off-by: Liang Chen <cl@rock-chips.com>
This commit is contained in:
Liang Chen
2022-07-28 09:35:51 +08:00
committed by Tao Huang
parent ed97e50c65
commit cf8b87bbec
3 changed files with 28 additions and 0 deletions

View File

@@ -51,6 +51,7 @@
#include <linux/sched/isolation.h>
#include <linux/nmi.h>
#include <linux/kvm_para.h>
#include <uapi/linux/sched/types.h>
#include "workqueue_internal.h"
@@ -1959,6 +1960,15 @@ static struct worker *create_worker(struct worker_pool *pool)
goto fail;
set_user_nice(worker->task, pool->attrs->nice);
if (IS_ENABLED(CONFIG_ROCKCHIP_OPTIMIZE_RT_PRIO)) {
struct sched_param param;
if (pool->attrs->nice == 0)
param.sched_priority = MAX_RT_PRIO / 2 - 4;
else
param.sched_priority = MAX_RT_PRIO / 2 - 2;
sched_setscheduler_nocheck(worker->task, SCHED_RR, &param);
}
kthread_bind_mask(worker->task, pool->attrs->cpumask);
/* successful, attach the worker to the pool */