You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
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:
@@ -91,6 +91,16 @@ config ROCKCHIP_OPP
|
||||
help
|
||||
Say y here to enable rockchip OPP support.
|
||||
|
||||
config ROCKCHIP_OPTIMIZE_RT_PRIO
|
||||
bool "Rockchip optimize prio for kernel RT thread and kworker"
|
||||
depends on NO_GKI
|
||||
help
|
||||
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.
|
||||
|
||||
config ROCKCHIP_PERFORMANCE
|
||||
bool "Rockchip performance configuration support"
|
||||
depends on NO_GKI
|
||||
|
||||
@@ -5738,6 +5738,14 @@ static int _sched_setscheduler(struct task_struct *p, int policy,
|
||||
.sched_nice = PRIO_TO_NICE(p->static_prio),
|
||||
};
|
||||
|
||||
if (IS_ENABLED(CONFIG_ROCKCHIP_OPTIMIZE_RT_PRIO) &&
|
||||
((policy == SCHED_FIFO) || (policy == SCHED_RR))) {
|
||||
attr.sched_priority /= 2;
|
||||
if (!check)
|
||||
attr.sched_priority += MAX_RT_PRIO / 2;
|
||||
if (!attr.sched_priority)
|
||||
attr.sched_priority = 1;
|
||||
}
|
||||
/* Fixup the legacy SCHED_RESET_ON_FORK hack. */
|
||||
if ((policy != SETPARAM_POLICY) && (policy & SCHED_RESET_ON_FORK)) {
|
||||
attr.sched_flags |= SCHED_FLAG_RESET_ON_FORK;
|
||||
|
||||
@@ -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, ¶m);
|
||||
}
|
||||
kthread_bind_mask(worker->task, pool->attrs->cpumask);
|
||||
|
||||
/* successful, attach the worker to the pool */
|
||||
|
||||
Reference in New Issue
Block a user