2.4 el0_sync

Interrupt Pipeline系列文章大纲-优快云博客

2.4.1 el0_sync代码框架

       沿着vectors->kernel_ventry 0,irq ->el0_sync进行分析。首先读取ESR_EL1寄存器,向右移位ESR_ELx_EC_SHIFT(26)得到异常发生的原因(Bit 31~26),然后跳转到相应的分支继续处理。整个过程,类似于C语言中的switch case语句。

       在entry.S中,引入I-pipe patch之后,el0_sync自身及其跳转的分支,都没有代码变化。唯一值得注意的是,所有的分支最终都是调用ret_to_user返回到用户层。

/*

 * EL0 mode handlers.

 */

       .align      6

el0_sync:

       kernel_entry 0

       mrs x25, esr_el1                  // read the syndrome register

       lsr    x24, x25, #ESR_ELx_EC_SHIFT      // exception class

       cmp x24, #ESR_ELx_EC_SVC64           // SVC in 64-bit state

       b.eq el0_svc

       cmp x24, #ESR_ELx_EC_DABT_LOW    // data abort in EL0

       b.eq el0_da

       cmp x24, #ESR_ELx_EC_IABT_LOW     // instruction abort in EL0

       b.eq el0_ia

       cmp x24, #ESR_ELx_EC_FP_ASIMD      // FP/ASIMD access

       b.eq el0_fpsimd_acc

       cmp x24, #ESR_ELx_EC_SVE         // SVE access

       b.eq el0_sve_acc

       cmp x24, #ESR_ELx_EC_FP_EXC64       // FP/ASIMD exception

       b.eq el0_fpsimd_exc

       cmp x24, #ESR_ELx_EC_SYS64            // configurable trap

       b.eq el0_sys

       cmp x24, #ESR_ELx_EC_SP_ALIGN      // stack alignment exception

       b.eq el0_sp_pc

       cmp x24, #ESR_ELx_EC_PC_ALIGN      // pc alignment exception

       b.eq el0_sp_pc

       cmp x24, #ESR_ELx_EC_UNKNOWN   // unknown exception in EL0

       b.eq el0_undef

       cmp x24, #ESR_ELx_EC_BREAKPT_LOW     // debug exception in EL0

       b.ge el0_dbg

       b     el0_inv

2.4.2 返回用户空间

1

ret_to_user:

2

#ifdef CONFIG_IPIPE

3

disable_daif

4

ldr

x0, [tsk, #TSK_TI_IPIPE]

5

tst

x0, #_TIP_HEAD

6

b.eq

ret_to_user_noirq

7

kernel_exit 0

8

#endif

第3行,关闭daif共4个中断屏蔽标识

第4~5行,检查TSK_TI_IPIPE中是否设置了_TIP_HEAD标记。TSK_TI_IPIPE定义在arch/arm64/kernel/asm-offsets.c;_TIP_HEAD定义在arch/arm64/include/asm/thread_info.h。根据注释,它代表进程运行在HEAD域。

DEFINE(TSK_TI_IPIPE,           offsetof(struct task_struct, thread_info.ipipe_flags));

第6行,如果TSK_TI_IPIPE中没有设置_TIP_HEAD标记,第14行tst指令(相当于ands)结果为0,则Z标志位为1,b.eq判断条件成立。说明当前进程处于ROOT域,跳转到ret_to_user_noirq。此后的流程与2.3.5.2小节流程相同。

第7行,如果TSK_TI_IPIPE中设置_了TIP_HEAD标记,第14行tst指令(相当于ands)结果为1,则Z标志位为0,b.eq判断条件不成立。说明当前进程处于HEAD域即Xenomai实时进程,直接通过kernel_exit 0返回用户层。

点击查看系列文章 =》 Interrupt Pipeline系列文章大纲-优快云博客

原创不易,需要大家多多鼓励!您的关注、点赞、收藏就是我的创作动力!

[ 38.584592][ C7] SError Interrupt on CPU7, code 0xbe000011 -- SError [ 38.584593][ C7] CPU: 7 PID: 417 Comm: provider@2.4-ex Not tainted 5.10.160 #421 [ 38.584594][ C7] Hardware name: Embedfire LubanCat-5IO (DT) [ 38.584595][ C7] pstate: 60400009 (nZCv daif +PAN -UAO -TCO BTYPE=--) [ 38.584595][ C7] pc : rkcif_write_register_and+0x104/0x134 [ 38.584596][ C7] lr : rkcif_csi_channel_set_v1+0x84/0xc80 [ 38.584597][ C7] sp : ffffffc00bd23810 [ 38.584597][ C7] x29: ffffffc00bd23810 x28: 0000000000000003 [ 38.584599][ C7] x27: ffffff81013d8880 x26: 000000000000bbf4 [ 38.584601][ C7] x25: ffffff810373ce70 x24: 0000000000000005 [ 38.584602][ C7] x23: ffffff8103730080 x22: 0000000000000000 [ 38.584603][ C7] x21: 0000000000000001 x20: ffffff810373bbb8 [ 38.584605][ C7] x19: ffffff8103733ec8 x18: ffffffc00b5d5090 [ 38.584606][ C7] x17: ffffff810373bbbe x16: ffffff810373bbbf [ 38.584608][ C7] x15: 000000000000b915 x14: 0000000000000000 [ 38.584609][ C7] x13: ffffff810373bbd8 x12: 0000000000000000 [ 38.584610][ C7] x11: 0000000000000000 x10: 000000000000005b [ 38.584611][ C7] x9 : ffffffc009843478 x8 : ffffffc00c9f7000 [ 38.584613][ C7] x7 : 205d373134542020 x6 : ffffffc00a253dd8 [ 38.584614][ C7] x5 : ffffffffffffffff x4 : 0000000000000000 [ 38.584616][ C7] x3 : 00000000ff7f3f3f x2 : 000000000000005b [ 38.584617][ C7] x1 : 000000000000005b x0 : ffffff8103730080 [ 38.584618][ C7] Kernel panic - not syncing: Asynchronous SError Interrupt [ 38.584619][ C7] CPU: 7 PID: 417 Comm: provider@2.4-ex Not tainted 5.10.160 #421 [ 38.584620][ C7] Hardware name: Embedfire LubanCat-5IO (DT) [ 38.584621][ C7] Call trace: [ 38.584621][ C7] dump_backtrace+0x0/0x1c8 [ 38.584622][ C7] show_stack+0x18/0x24 [ 38.584622][ C7] dump_stack_lvl+0xcc/0x114 [ 38.584623][ C7] dump_stack+0x18/0x5c [ 38.584624][ C7] panic+0x154/0x39c [ 38.584624][ C7] test_taint+0x0/0x28 [ 38.584625][ C7] arm64_serror_panic+0x74/0x80 [ 38.584625][ C7] do_serror+0xd0/0xf0 [ 38.584626][ C7] el1_error+0x90/0x114 [ 38.584627][ C7] rkcif_write_register_and+0x104/0x134 [ 38.584627][ C7] rkcif_csi_channel_set_v1+0x84/0xc80 [ 38.584628][ C7] rkcif_csi_stream_start+0x9ac/0xd98 [ 38.584629][ C7] rkcif_do_start_stream+0xa98/0x1120 [ 38.584629][ C7] rkcif_start_streaming+0x18/0x24 [ 38.584630][ C7] vb2_start_streaming+0x60/0x134 [ 38.584631][ C7] vb2_core_streamon+0x10c/0x150 [ 38.584631][ C7] vb2_ioctl_streamon+0x5c/0x8c [ 38.584632][ C7] v4l_streamon+0x24/0x30 [ 38.584633][ C7] __video_do_ioctl+0x2d0/0x3e8 [ 38.584633][ C7] video_usercopy+0x3d4/0x80c [ 38.584634][ C7] video_ioctl2+0x18/0x24 [ 38.584635][ C7] v4l2_ioctl+0x4c/0x5c [ 38.584635][ C7] __arm64_sys_ioctl+0x90/0xc8 [ 38.584636][ C7] el0_svc_common+0xac/0x1ac [ 38.584636][ C7] do_el0_svc+0x1c/0x28 [ 38.584637][ C7] el0_svc+0x10/0x1c [ 38.584638][ C7] el0_sync_handler+0x68/0xac [ 38.584638][ C7] el0_sync+0x160/0x180 [ 38.584643][ C6] CPU6: stopping [ 38.584645][ C0] CPU0: stopping [ 38.584647][ C3] CPU3: stopping [ 38.584649][ C2] CPU2: stopping [ 38.584654][ C0] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.10.160 #421 [ 38.584696][ C4] CPU4: stopping [ 38.584698][ C1] CPU1: stopping [ 38.584704][ C5] CPU5: stopping [ 38.689741][ C0] Hardware name: Embedfire LubanCat-5IO (DT) [ 38.690252][ C0] Call trace: [ 38.690539][ C0] dump_backtrace+0x0/0x1c8 [ 38.690923][ C0] show_stack+0x18/0x24 [ 38.691284][ C0] dump_stack_lvl+0xcc/0x114 [ 38.691678][ C0] dump_stack+0x18/0x5c [ 38.692029][ C0] local_cpu_stop+0x68/0x84 [ 38.692413][ C0] smp_send_reschedule+0x0/0x3c [ 38.692830][ C0] handle_percpu_devid_fasteoi_ipi+0x78/0x194 [ 38.693354][ C0] __handle_domain_irq+0x7c/0xc8 [ 38.693782][ C0] gic_handle_irq+0x70/0x130 [ 38.694175][ C0] el1_irq+0xe0/0x1c0 [ 38.694517][ C0] cpuidle_enter_state+0x17c/0x3a0 [ 38.694953][ C0] cpuidle_enter+0x38/0x50 [ 38.695338][ C0] cpuidle_idle_call+0x14c/0x220 [ 38.695764][ C0] do_idle+0xa8/0xf0 [ 38.696093][ C0] cpu_startup_entry+0x24/0x28 [ 38.696498][ C0] rest_init+0xd4/0xe4 [ 38.696850][ C0] arch_call_rest_init+0x10/0x1c [ 38.697276][ C0] start_kernel+0x3a8/0x43c [ 38.697660][ C6] CPU: 6 PID: 424 Comm: allocator@4.0-s Not tainted 5.10.160 #421 [ 38.698328][ C6] Hardware name: Embedfire LubanCat-5IO (DT) [ 38.698841][ C6] Call trace: [ 38.699118][ C6] dump_backtrace+0x0/0x1c8 [ 38.699502][ C6] show_stack+0x18/0x24 [ 38.699853][ C6] dump_stack_lvl+0xcc/0x114 [ 38.700246][ C6] dump_stack+0x18/0x5c [ 38.700597][ C6] local_cpu_stop+0x68/0x84 [ 38.700982][ C6] smp_send_reschedule+0x0/0x3c [ 38.701399][ C6] handle_percpu_devid_fasteoi_ipi+0x78/0x194 [ 38.701913][ C6] __handle_domain_irq+0x7c/0xc8 [ 38.702339][ C6] gic_handle_irq+0x70/0x130 [ 38.702733][ C6] el1_irq+0xe0/0x1c0 [ 38.703074][ C6] _raw_spin_lock+0x3c/0x70 [ 38.703460][ C6] remap_pfn_range+0x174/0x270 [ 38.703867][ C6] system_heap_mmap+0xc0/0x108 [ 38.704272][ C6] dma_buf_mmap_internal+0x60/0x64 [ 38.704710][ C6] mmap_region+0x3e0/0x87c [ 38.705083][ C6] do_mmap+0x42c/0x510 [ 38.705433][ C6] vm_mmap_pgoff+0xac/0x114 [ 38.705816][ C6] ksys_mmap_pgoff+0x78/0xf0 [ 38.706211][ C6] __arm64_sys_mmap+0x34/0x40 [ 38.706605][ C6] el0_svc_common+0xac/0x1ac [ 38.707000][ C6] do_el0_svc+0x1c/0x28 [ 38.707351][ C6] el0_svc+0x10/0x1c [ 38.707680][ C6] el0_sync_handler+0x68/0xac [ 38.708074][ C6] el0_sync+0x160/0x180 [ 38.708426][ C1] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.10.160 #421 [ 38.709038][ C1] Hardware name: Embedfire LubanCat-5IO (DT) [ 38.709550][ C1] Call trace: [ 38.709837][ C1] dump_backtrace+0x0/0x1c8 [ 38.710220][ C1] show_stack+0x18/0x24 [ 38.710582][ C1] dump_stack_lvl+0xcc/0x114 [ 38.710975][ C1] dump_stack+0x18/0x5c [ 38.711326][ C1] local_cpu_stop+0x68/0x84 [ 38.711710][ C1] smp_send_reschedule+0x0/0x3c [ 38.712126][ C1] handle_percpu_devid_fasteoi_ipi+0x78/0x194 [ 38.712649][ C1] __handle_domain_irq+0x7c/0xc8 [ 38.713075][ C1] gic_handle_irq+0x70/0x130 [ 38.713469][ C1] el1_irq+0xe0/0x1c0 [ 38.713810][ C1] cpuidle_enter_state+0x17c/0x3a0 [ 38.714246][ C1] cpuidle_enter+0x38/0x50 [ 38.714630][ C1] cpuidle_idle_call+0x14c/0x220 [ 38.715056][ C1] do_idle+0xa8/0xf0 [ 38.715386][ C1] cpu_startup_entry+0x24/0x28 [ 38.715791][ C1] secondary_start_kernel+0x1a8/0x24c [ 38.716251][ C2] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 5.10.160 #421 [ 38.716863][ C2] Hardware name: Embedfire LubanCat-5IO (DT) [ 38.717375][ C2] Call trace: [ 38.717662][ C2] dump_backtrace+0x0/0x1c8 [ 38.718045][ C2] show_stack+0x18/0x24 [ 38.718397][ C2] dump_stack_lvl+0xcc/0x114 [ 38.718790][ C2] dump_stack+0x18/0x5c [ 38.719151][ C2] local_cpu_stop+0x68/0x84 [ 38.719535][ C2] smp_send_reschedule+0x0/0x3c [ 38.719951][ C2] handle_percpu_devid_fasteoi_ipi+0x78/0x194 [ 38.720474][ C2] __handle_domain_irq+0x7c/0xc8 [ 38.720900][ C2] gic_handle_irq+0x70/0x130 [ 38.721294][ C2] el1_irq+0xe0/0x1c0 [ 38.721634][ C2] cpuidle_enter_state+0x17c/0x3a0 [ 38.722071][ C2] cpuidle_enter+0x38/0x50 [ 38.722454][ C2] cpuidle_idle_call+0x14c/0x220 [ 38.722880][ C2] do_idle+0xa8/0xf0 [ 38.723209][ C2] cpu_startup_entry+0x24/0x28 [ 38.723614][ C2] secondary_start_kernel+0x1a8/0x24c [ 38.724074][ C3] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 5.10.160 #421 [ 38.724686][ C3] Hardware name: Embedfire LubanCat-5IO (DT) [ 38.725198][ C3] Call trace: [ 38.725485][ C3] dump_backtrace+0x0/0x1c8 [ 38.725868][ C3] show_stack+0x18/0x24 [ 38.726230][ C3] dump_stack_lvl+0xcc/0x114 [ 38.726623][ C3] dump_stack+0x18/0x5c [ 38.726985][ C3] local_cpu_stop+0x68/0x84 [ 38.727368][ C3] smp_send_reschedule+0x0/0x3c [ 38.727784][ C3] handle_percpu_devid_fasteoi_ipi+0x78/0x194 [ 38.728308][ C3] __handle_domain_irq+0x7c/0xc8 [ 38.728734][ C3] gic_handle_irq+0x70/0x130 [ 38.729128][ C3] el1_irq+0xe0/0x1c0 [ 38.729468][ C3] cpuidle_enter_state+0x17c/0x3a0 [ 38.729905][ C3] cpuidle_enter+0x38/0x50 [ 38.730288][ C3] cpuidle_idle_call+0x14c/0x220 [ 38.730714][ C3] do_idle+0xa8/0xf0 [ 38.731043][ C3] cpu_startup_entry+0x24/0x28 [ 38.731448][ C3] secondary_start_kernel+0x1a8/0x24c [ 38.731908][ C4] CPU: 4 PID: 0 Comm: swapper/4 Not tainted 5.10.160 #421 [ 38.732519][ C4] Hardware name: Embedfire LubanCat-5IO (DT) [ 38.733031][ C4] Call trace: [ 38.733313][ C4] dump_backtrace+0x0/0x1c8 [ 38.733703][ C4] show_stack+0x18/0x24 [ 38.734060][ C4] dump_stack_lvl+0xcc/0x114 [ 38.734450][ C4] dump_stack+0x18/0x5c [ 38.734808][ C4] local_cpu_stop+0x68/0x84 [ 38.735198][ C4] smp_send_reschedule+0x0/0x3c [ 38.735612][ C4] handle_percpu_devid_fasteoi_ipi+0x78/0x194 [ 38.736136][ C4] __handle_domain_irq+0x7c/0xc8 [ 38.736560][ C4] gic_handle_irq+0x70/0x130 [ 38.736950][ C4] el1_irq+0xe0/0x1c0 [ 38.737286][ C4] cpuidle_enter_state+0x17c/0x3a0 [ 38.737721][ C4] cpuidle_enter+0x38/0x50 [ 38.738099][ C4] cpuidle_idle_call+0x14c/0x220 [ 38.738524][ C4] do_idle+0xa8/0xf0 [ 38.738859][ C4] cpu_startup_entry+0x24/0x28 [ 38.739261][ C4] secondary_start_kernel+0x1a8/0x24c [ 38.739721][ C5] CPU: 5 PID: 0 Comm: swapper/5 Not tainted 5.10.160 #421 [ 38.740331][ C5] Hardware name: Embedfire LubanCat-5IO (DT) [ 38.740843][ C5] Call trace: [ 38.741124][ C5] dump_backtrace+0x0/0x1c8 [ 38.741514][ C5] show_stack+0x18/0x24 [ 38.741871][ C5] dump_stack_lvl+0xcc/0x114 [ 38.742262][ C5] dump_stack+0x18/0x5c [ 38.742619][ C5] local_cpu_stop+0x68/0x84 [ 38.742999][ C5] smp_send_reschedule+0x0/0x3c [ 38.743412][ C5] handle_percpu_devid_fasteoi_ipi+0x78/0x194 [ 38.743935][ C5] __handle_domain_irq+0x7c/0xc8 [ 38.744358][ C5] gic_handle_irq+0x70/0x130 [ 38.744747][ C5] el1_irq+0xe0/0x1c0 [ 38.745082][ C5] cpuidle_enter_state+0x17c/0x3a0 [ 38.745517][ C5] cpuidle_enter+0x38/0x50 [ 38.745897][ C5] cpuidle_idle_call+0x14c/0x220 [ 38.746320][ C5] do_idle+0xa8/0xf0 [ 38.746656][ C5] cpu_startup_entry+0x24/0x28 [ 38.747067][ C5] secondary_start_kernel+0x1a8/0x24c [ 39.749199][ C7] rockchip-thermal fec00000.tsadc: channal 0: temperature(40 C) [ 39.749874][ C7] cpu cpu6: cur_freq: 1608000000 Hz, volt_vdd: 700000 uV, volt_mem: 700000 uV [ 39.750630][ C7] cpu cpu4: cur_freq: 1200000000 Hz, volt_vdd: 675000 uV, volt_mem: 675000 uV [ 39.751384][ C7] cpu cpu0: cur_freq: 1800000000 Hz, volt_vdd: 875000 uV, volt_mem: 875000 uV [ 39.752141][ C7] rockchip-dmc dmc: cur_freq: 1560000000 Hz, volt_vdd: 725000 uV, volt_mem: 700000 uV [ 39.752962][ C7] SMP: stopping secondary CPUs [ 39.752963][ C7] CRU REGS: [ 39.752963][ C7] LPLL 0x58040: 00000110 00002082 00000000 00000000 00000002 000007e0 00004000 00000000 [ 39.752965][ C7] B0PLL 0x50000: 00000110 00002082 00000000 00000000 00000002 000007e0 00004000 00000000 [ 39.752966][ C7] B1PLL 0x52020: 00000110 00002082 00000000 00000000 00000002 000007e0 00004000 00000000 [ 39.752968][ C7] GPLL 0x001c0: 000000c6 00000042 00000000 00000000 00000000 00000000 00009400 00000000 [ 39.752969][ C7] CPLL 0x001a0: 000000fa 00000042 00000000 00000000 00000000 00000000 00009c00 00000000 [ 39.752970][ C7] V0PLL 0x00160: 000000c6 00002042 00000000 00000000 00000000 00000000 00004000 00000000 [ 39.752972][ C7] AUPLL 0x00180: 00000106 00000082 ffff24dd 00000000 00000000 00000000 0000a000 00000000 [ 39.752973][ C7] PPLL 0x08200: 00000226 00002083 00000000 00000000 00000000 00000000 00004000 00000000 [ 39.752974][ C7] DSUCRU_SEL 0x58300: 0000b0c0 00001083 00000843 00000063 00000665 0000403f 000020c1 0000e0c1 [ 39.752976][ C7] DSUCRU_GATE 0x58800: 00000000 00000000 00000063 00000000 00000000 00000000 00000000 00000000 [ 39.752977][ C7] BIG0CRU_SEL 0x50300: 00004240 00005fc2 00000005 00000000 00000000 00000000 00000000 00000000 [ 39.752978][ C7] BIG0CRU_GATE 0x50800: 00003400 00000001 00000000 00000000 00000000 00000000 00000000 00000000 [ 39.752980][ C7] BIG1CRU_SEL 0x52300: 00004240 00005fc2 00000005 00000000 00000000 00000000 00000000 00000000 [ 39.752981][ C7] BIG1CRU_GATE 0x52800: 00003400 00000001 00000000 00000000 00000000 00000000 00000000 00000000 [ 39.752983][ C7] CRU_SEL 0x00300: 00000bbd 00000169 00000925 000000a1 00000881 00000881 00000820 00000020 [ 39.752984][ C7] CRU_SEL 0x00320: 00000881 00000881 00000820 00000020 00000421 00000000 000030ff 00000000 [ 39.752985][ C7] CRU_SEL 0x00340: 00000421 00000000 000030ff 00000000 00000000 00000000 00000000 0000bb9d [ 39.752987][ C7] CRU_SEL 0x00360: 00000000 00000000 00000000 0000bb9d 000000bb 00000200 00000000 00000000 [ 39.752988][ C7] CRU_SEL 0x00380: 000000bb 00000200 00000000 00000000 00000000 00000000 00000000 00000000 [ 39.752990][ C7] CRU_SEL 0x003a0: 00000000 00000000 00000000 00000000 00000010 03355460 00000007 03355460 [ 39.752991][ C7] CRU_SEL 0x003c0: 00000010 03355460 00000007 03355460 0000001b 03355460 0000000f 03355460 [ 39.752992][ C7] CRU_SEL 0x003e0: 0000001b 03355460 0000000f 03355460 0000000f 03355460 00000006 03355460 [ 39.752994][ C7] CRU_SEL 0x00400: 0000000f 03355460 00000006 03355460 00000092 00000000 00000023 000002cb [ 39.752995][ C7] CRU_SEL 0x00420: 00000092 00000000 00000023 000002cb 000045cb 0000030b 001403de 00000006 [ 39.752996][ C7] CRU_SEL 0x00440: 000045cb 0000030b 001403de 00000006 001403de 00000006 001403de 00000006 [ 39.752998][ C7] CRU_SEL 0x00460: 001403de 00000006 001403de 00000006 001403de 00000006 001403de 00000006 [ 39.752999][ C7] CRU_SEL 0x00480: 001403de 00000006 001403de 00000006 001403de 00000006 001403de 00000006 [ 39.753001][ C7] CRU_SEL 0x004a0: 001403de 00000006 001403de 00000006 001403de 00000006 001403de 00008002 [ 39.753002][ C7] CRU_SEL 0x004c0: 001403de 00000006 001403de 00008002 0000020a 00000041 000003ff 0000003f [ 39.753003][ C7] CRU_SEL 0x004e0: 0000020a 00000041 000003ff 0000003f 00000000 0000003f 00000000 0000c021 [ 39.753005][ C7] CRU_SEL 0x00500: 00000000 0000003f 00000000 0000c021 00000000 00000000 00000000 00000000 [ 39.753006][ C7] CRU_SEL 0x00520: 00000000 00000000 00000000 00000000 00000000 00007c14 00001010 00000000 [ 39.753007][ C7] CRU_SEL 0x00540: 00000000 00007c14 00001010 00000000 00000000 00000590 00000385 00000000 [ 39.753009][ C7] CRU_SEL 0x00560: 00000000 00000590 00000385 00000000 00000288 0000070e 00009d9d 00008b9d [ 39.753010][ C7] CRU_SEL 0x00580: 00000288 0000070e 00009d9d 00008b9d 0000049d 00000000 00000000 00000000 [ 39.753012][ C7] CRU_SEL 0x005a0: 0000049d 00000000 00000000 00000000 00000000 00000300 00001801 00000001 [ 39.753013][ C7] CRU_SEL 0x005c0: 00000000 00000300 00001801 00000001 00000000 00000300 000000e0 00000000 [ 39.753015][ C7] CRU_GATE 0x00800: 00000900 00000140 00000050 00004000 00000008 00003e78 00000000 0000fff3 [ 39.753016][ C7] CRU_GATE 0x00820: 00000008 00003e78 00000000 0000fff3 0000c01f 000000ff 0000ffe0 00003fff [ 39.753017][ C7] CRU_GATE 0x00840: 0000c01f 000000ff 0000ffe0 00003fff 0000fff4 0000fffe 0000ffff 00002ff8 [ 39.753019][ C7] CRU_GATE 0x00860: 0000fff4 0000fffe 0000ffff 00002ff8 00003fff 000001c0 00003e00 00000000 [ 39.753020][ C7] CRU_GATE 0x00880: 00003fff 000001c0 00003e00 00000000 0000aa05 000000a0 00000263 0000aa05 [ 39.753022][ C7] CRU_GATE 0x008a0: 0000aa05 000000a0 00000263 0000aa05 000000a0 00000263 000001ff 00000005 [ 39.753023][ C7] CRU_GATE 0x008c0: 000000a0 00000263 000001ff 00000005 00000005 0000ffd7 0000016a 00000e00 [ 39.753024][ C7] CRU_GATE 0x008e0: 00000005 0000ffd7 0000016a 00000e00 0000ed19 0000ffff 00000dbf 000007e0 [ 39.753026][ C7] CRU_GATE 0x00900: 0000ed19 0000ffff 00000dbf 000007e0 00000000 00001ff7 0000e3f8 00000003 [ 39.753027][ C7] CRU_GATE 0x00920: 00000000 00001ff7 0000e3f8 00000003 000003ff 000001ff 00003000 00000000 [ 39.753028][ C7] PMUCRU_SEL 0x30300: 000000b7 00000400 00000020 00000080 001403de 00000006 03355460 00000007 [ 39.753030][ C7] PMUCRU_SEL 0x30320: 001403de 00000006 03355460 00000007 03355460 0000000b 00000000 00000000 [ 39.753031][ C7] PMUCRU_SEL 0x30340: 03355460 0000000b 00000000 00000000 00000000 00000000 00000000 00000000 [ 39.753033][ C7] PMUCRU_GATE 0x30800: 00000009 00005fc0 0000fff8 00000001 00000800 00000000 00000000 00000000 [ 39.753034][ C7] CPU0 online:0 [ 39.753035][ C7] EL2(NS) PC: <0xffffffc00801b8d8> local_cpu_stop+0x44/0x84 [ 39.753035][ C7] [ 39.753036][ C7] CPU1 online:0 [ 39.753037][ C7] EL2(NS) PC: <0xffffffc00801b8d8> local_cpu_stop+0x44/0x84 [ 39.753037][ C7] [ 39.753038][ C7] CPU2 online:0 [ 39.753039][ C7] EL2(NS) PC: <0xffffffc00801b8d8> local_cpu_stop+0x44/0x84 [ 39.753039][ C7] [ 39.753040][ C7] CPU3 online:0 [ 39.753041][ C7] EL2(NS) PC: <0xffffffc00801b8d8> local_cpu_stop+0x44/0x84 [ 39.753041][ C7] [ 39.753041][ C7] CPU4 online:0 [ 39.753042][ C7] EL2(NS) PC: <0xffffffc00801b8d8> local_cpu_stop+0x44/0x84 [ 39.753043][ C7] [ 39.753043][ C7] CPU5 online:0 [ 39.753044][ C7] EL2(NS) PC: <0xffffffc00801b8d8> local_cpu_stop+0x44/0x84 [ 39.753044][ C7] [ 39.753045][ C7] CPU6 online:0 [ 39.753046][ C7] EL2(NS) PC: <0xffffffc00801b8d8> local_cpu_stop+0x44/0x84 [ 39.753046][ C7] [ 39.753047][ C7] CPU7 online:1 [ 39.753048][ C7] EL2(NS) PC: <0xffffffc0086de410> rockchip_panic_notify+0x274/0x394 [ 39.753048][ C7] [ 39.753049][ C7] CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7 [ 39.753050][ C7] 13: 7751 4759 12010 40210 6869 9433 4670 4697 GICv3 26 Level arch_timer [ 39.753052][ C7] 14: 1007 1341 3548 1383 328 531 198 228 GICv3 321 Level rk_timer [ 39.753053][ C7] 15: 0 0 0 0 0 0 0 0 GICv3 23 Level arm-pmu [ 39.753054][ C7] 16: 2 0 0 0 0 0 0 0 GICv3 105 Level dmc [ 39.753055][ C7] 17: 6158 0 0 0 0 0 0 0 GICv3 126 Level fb000000.gpu [ 39.753056][ C7] 18: 1 0 0 0 0 0 0 0 GICv3 125 Level fb000000.gpu [ 39.753057][ C7] 19: 8762 0 0 0 0 0 0 0 GICv3 124 Level fb000000.gpu [ 39.753059][ C7] 20: 0 0 0 0 0 0 0 0 GICv3 247 Level ehci_hcd:usb1 [ 39.753060][ C7] 21: 0 0 0 0 0 0 0 0 GICv3 248 Level ohci_hcd:usb2 [ 39.753061][ C7] 24: 0 0 0 0 0 0 0 0 GICv3 425 Level rockchip_usb2phy [ 39.753062][ C7] 25: 0 0 0 0 0 0 0 0 GICv3 423 Level rockchip_usb2phy [ 39.753064][ C7] 26: 6704 0 0 0 0 0 0 0 GICv3 349 Level fd880000.i2c [ 39.753065][ C7] 29: 0 0 0 0 0 0 0 0 GICv3 142 Level fdab9000.iommu, fdab0000.npu [ 39.753066][ C7] 30: 0 0 0 0 0 0 0 0 GICv3 143 Level fdab9000.iommu, fdab0000.npu [ 39.753067][ C7] 31: 0 0 0 0 0 0 0 0 GICv3 144 Level fdab9000.iommu, fdab0000.npu [ 39.753069][ C7] 32: 0 0 0 0 0 0 0 0 GICv3 152 Level fdb50000.vepu [ 39.753069][ C7] 33: 0 0 0 0 0 0 0 0 GICv3 151 Level fdb50400.vdpu [ 39.753071][ C7] 34: 0 0 0 0 0 0 0 0 GICv3 150 Level fd [ 39.753072][ C7] Lost 223 message(s)!
最新发布
07-23
### CPU选核调度栈中`select_task_rq_fair`函数的作用及调用链分析 #### 1. `select_task_rq_fair` 函数作用 `select_task_rq_fair` 是 Linux 内核公平调度类 (`fair_sched_class`) 的一部分,主要用于为即将运行的任务选择最适合的运行队列 (Run Queue, RQ)。该函数综合考虑了多种因素,例如任务的历史迁移成本、目标CPU的负载均衡状态以及能量效率等因素[^3]。 以下是 `select_task_rq_fair` 的主要功能分解: - **负载均衡**: 它会尝试将任务分配到负载较低的CPU上,从而提高整体系统的吞吐量。 - **亲和性约束**: 尊重任务的CPU亲和性设置 (`task_struct::cpus_ptr`),确保任务仅在允许的范围内运行。 - **节能策略**: 结合能耗模型,优先选择能效更高的CPU核心以降低功耗[^2]。 ```c int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flags) { ... if (sched_feat(LB_BIAS)) new_cpu = cpumask_any_and(p->cpus_ptr, imbalance_mask); // 如果启用了节能策略,则尝试找到更高效的cpu if (sd && !(wake_flags & WF_TTWU)) { new_cpu = mtk_find_energy_efficient_cpu(p); } ... return new_cpu; } ``` --- #### 2. 调用链分析 ##### (1)`try_to_wake_up` 当一个任务被唤醒时,`try_to_wake_up` 函数会被调用。它是任务唤醒的核心入口之一,负责更新任务的状态并将任务放入适当的运行队列中。在此过程中,`try_to_wake_up` 会调用 `select_task_rq` 来确定目标任务应该运行在哪一个CPU上[^1]。 ```c int try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) { ... next_cpu = select_task_rq(p, SD_BALANCE_WAKE, wake_flags); set_task_cpu(p, next_cpu); enqueue_task(rq, p, ENQUEUE_WAKING | ENQUEUE_MIGRATED); ... } ``` ##### (2)`wake_up_new_task` 对于新建的任务,`wake_up_new_task` 函数会在初始化完成后将其加入到运行队列中。同样地,它也会调用 `select_task_rq` 来完成CPU的选择工作。 ```c void wake_up_new_task(struct task_struct *p) { ... cpu = select_task_rq(p, SD_BALANCE_FORK, 0); set_task_cpu(p, cpu); enqueue_task(rq_of(cpu), p, ENQUEUE_NOCLOCK); ... } ``` ##### (3)`futex_wake` Futex机制是Linux内核提供的一种轻量级同步工具,广泛应用于用户态线程库(如pthread)。当某个条件变量满足时,`futex_wake` 会唤醒等待的线程,并通过调用 `sys_futex` 系统调用间接触发 `try_to_wake_up` 和 `select_task_rq_fair` 的执行链条[^1]。 ```c long sys_futex(u32 __user *uaddr, int op, u32 val, ...) { ... ret = futex_wait_setup(...); if (!ret) { queue_me(...); if (!(flags & FLAGS_SHARED)) current->robust_list = NULL; schedule(); // 唤醒其他进程时发生的调度行为 unqueue_me_pi(...); } return ret; } ``` ##### (4)`__traceiter_sched_runnable_boost` 从日志信息来看,`__traceiter_sched_runnable_boost` 是跟踪可运行任务提升的关键点之一。它可以记录任务是否具备运行资格以及是否有足够的资源支持其运行。这一部分通常与性能监控和调试密切相关。 --- ### 总结说明 在整个CPU选核的过程中,`select_task_rq_fair` 扮演着至关重要的角色。它不仅决定了任务的初始放置位置,还直接影响了系统的负载分布和能源消耗状况。通过对上述调用链的分析可以看出,无论是任务创建、唤醒还是同步操作,都离不开这一核心函数的支持。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值