schedule_fair

假如有4个cpu 现在有5个进程 且都是密集型计算的任务 不会主动让出cpu

那么kernel怎么保证公平调度?

root@NYX-RK3568:/data# cat /proc/interrupts

CPU0 CPU1 CPU2 CPU3

5: 98148 61882 174660 91318 GICv3 26 Level arch_timer

#0 task_tick_fair (rq=0xffffffc0efec7080, curr=0xffffffc0e92863c0, queued=0) at kernel/sched/fair.c:10901

#1 0xffffff80080e4304 in scheduler_tick () at kernel/sched/core.c:3668

#2 0xffffff8008133d28 in update_process_times (user_tick=0) at kernel/time/timer.c:1655

#3 0xffffff8008144a84 in tick_sched_handle (ts=0xffffffc0efec3560, regs=<optimized out>) at kernel/time/tick-sched.c:169

#4 0xffffff8008144ae8 in tick_sched_timer (timer=0xffffffc0efec3560) at kernel/time/tick-sched.c:1292

#5 0xffffff8008134fb0 in __run_hrtimer (flags=<optimized out>, now=<optimized out>, timer=<optimized out>, base=<optimized out>, cpu_base=<optimized out>)

at kernel/time/hrtimer.c:1465

#6 __hrtimer_run_queues (cpu_base=0xffffffc0efec2ec0, now=<optimized out>, flags=128, active_mask=<optimized out>) at kernel/time/hrtimer.c:1527

#7 0xffffff8008135408 in hrtimer_interrupt (dev=<optimized out>) at kernel/time/hrtimer.c:1585

#8 0xffffff8008a74ef8 in timer_handler (evt=<optimized out>, access=<optimized out>) at drivers/clocksource/arm_arch_timer.c:645

#9 arch_timer_handler_phys (irq=<optimized out>, dev_id=0xffffffc0efecd900) at drivers/clocksource/arm_arch_timer.c:663

#10 0xffffff800811723c in handle_percpu_devid_irq (desc=0xffffffc0e99ef400) at kernel/irq/chip.c:926

#11 0xffffff8008111214 in generic_handle_irq_desc (desc=<optimized out>) at ./include/linux/irqdesc.h:155

#12 generic_handle_irq (irq=5) at kernel/irq/irqdesc.c:639

//以上是标记

do_notify_resume

...

if (thread_flags & _TIF_NEED_RESCHED) {

/* Unmask Debug and SError for the next task */

local_daif_restore(DAIF_PROCCTX_NOIRQ);

schedule(); ///

-->static void __sched notrace __schedule(bool preempt)

-->

static inline struct task_struct *

pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)

{

const struct sched_class *class;

struct task_struct *p;

if (likely((prev->sched_class == &idle_sched_class ||

prev->sched_class == &fair_sched_class) &&

rq->nr_running == rq->cfs.h_nr_running)) {

p = fair_sched_class.pick_next_task(rq, prev, rf);

优先级

DL调度类(dl_sched_class)→ RT调度类(rt_sched_class)→ CFS调度类(fair_sched_class)→ idle调度类

/// stack info

work_pending:

mov x0, sp // 'regs'

bl do_notify_resume

#ifdef CONFIG_TRACE_IRQFLAGS

bl trace_hardirqs_on // enabled while in userspace

#endif

ldr x1, tsk, #TSK_TI_FLAGS // re-check for single-step

b finish_ret_to_user

ret_to_user:

disable_daif

ldr x1, tsk, #TSK_TI_FLAGS

and x2, x1, #_TIF_WORK_MASK

cbnz x2, work_pending

finish_ret_to_user:

enable_step_tsk x1, x2

#ifdef CONFIG_GCC_PLUGIN_STACKLEAK

bl stackleak_erase

#endif

kernel_exit 0

ENDPROC(ret_to_user)

el0_svc:

mov x0, sp

bl el0_svc_handler

b ret_to_user

ENDPROC(el0_svc)

相关推荐
幼儿园蛋小黄2 分钟前
从设备树到 ARM 驱动:嵌入式 Linux 驱动开发学习总结
linux·arm开发·驱动开发
dishugj15 分钟前
HANA集群计划内切换与维护操作
java·linux·数据库
爱吃香菜的初学者2 小时前
十四.Linux——消息队列
linux·运维·开发语言
Apipi*9 小时前
30天速通Linux 第六章信号及信号处理
linux·运维·信号处理
天启HTTP10 小时前
爬虫防封核心原理:IP轮换机制与风控规避逻辑
linux·服务器·网络·爬虫·tcp/ip
广州浮点FLOATLIC12 小时前
许可证服务器迁移后软件打不开:研发 IT 怎样定位连接问题
linux·服务器·数据库
BLUcoding13 小时前
接口服务公网超时排查记录:SecureRandom 阻塞问题分析与解决
java·linux·springboot·aes·securerandom
AIgorithmGEEK13 小时前
[Linux]从手写报头到内核套路:序列化、反序列化与自定义协议全链路
linux·运维·服务器·网络·序列化·反序列化
Nil20813 小时前
leetcode 139单词拆分
linux·运维·服务器
Starry-sky(jing)13 小时前
BUG: unable to handle kernel paging request 完整排查:dmesg 四要素与三路定罪
linux·运维·服务器·内核·排障