what do the suffixes “*.part” and “.cold” mean in the result of Linux kernel's dump_stack?

∥☆過路亽.° 提交于 2021-02-11 12:57:04

问题


Sometimes dump_stack() would add the suffixes ".cold" and ".part" to the function name, for example, here are parts of lines from [1],

[  638.115912][    C0] Call Trace:
[  638.115986][    C0]  ? kasan_set_free_info+0x1b/0x30
[  638.115990][    C0]  ? __kasan_slab_free+0xd8/0x120
[  638.115995][    C0]  ? kmem_cache_free.part.0+0x67/0x1f0
[  638.115999][    C0]  ? __put_cred+0x1de/0x250
[  638.116004][    C0]  ? revert_creds+0x1a8/0x1f0
[  638.116008][    C0]  ? do_faccessat+0x2ca/0x820
[  638.116013][    C0]  ? do_syscall_64+0x2d/0x70
[  638.116017][    C0]  ? find_held_lock+0x2d/0x110
[  638.116022][    C0]  ? lock_acquire+0x1f1/0xad0
[  638.116027][    C0]  ? debug_check_no_obj_freed+0xc7/0x41c
[  638.116031][    C0]  ? find_held_lock+0x2d/0x110
[  638.116036][    C0]  ? debug_check_no_obj_freed+0x20c/0x41c
[  638.116041][    C0]  ? lock_downgrade+0x830/0x830
[  638.116045][    C0]  ? lockdep_hardirqs_off+0x89/0xc0
[  638.116050][    C0]  ? trace_hardirqs_off+0x27/0x210
[  638.116055][    C0]  ? _raw_spin_unlock_irqrestore+0x9b/0xe0
[  638.116060][    C0]  ? debug_check_no_obj_freed+0x20c/0x41c
[  638.116064][    C0]  kasan_set_track+0x1c/0x30
[  638.116069][    C0]  kasan_set_free_info+0x1b/0x30
[  638.116073][    C0]  __kasan_slab_free+0xd8/0x120
[  638.116078][    C0]  ? __put_cred+0x1de/0x250
[  638.116082][    C0]  kmem_cache_free.part.0+0x67/0x1f0
 
[  638.116220][ T1172] Kernel panic - not syncing: hung_task: blocked tasks

[  638.570843][ T1172] Call Trace:
[  638.574119][ T1172]  dump_stack+0x18f/0x20d
[  638.578499][ T1172]  panic+0x2e3/0x75c
[  638.582375][ T1172]  ? __warn_printk+0xf3/0xf3
[  638.586953][ T1172]  ? lapic_can_unplug_cpu.cold+0x38/0x38
[  638.592562][ T1172]  ? preempt_schedule_thunk+0x16/0x18
[  638.597922][ T1172]  ? watchdog.cold+0x22d/0x24b
[  638.602659][ T1172]  ? watchdog+0xc59/0xf30
[  638.606965][ T1172]  watchdog.cold+0x23e/0x24b
[  638.611530][ T1172]  ? trace_sched_process_hang+0x2e0/0x2e0
[  638.617227][ T1172]  kthread+0x3b5/0x4a0
[  638.621272][ T1172]  ? __kthread_bind_mask+0xc0/0xc0
[  638.626358][ T1172]  ? __kthread_bind_mask+0xc0/0xc0
[  638.631445][ T1172]  ret_from_fork+0x1f/0x30
[  638.637042][ T1172] Kernel Offset: disabled
[  638.641361][ T1172] Rebooting in 86400 seconds..

What do these suffixes mean?

[1] https://syzkaller.appspot.com/text?tag=CrashLog&x=12fa85ee900000


回答1:


.cold is a function attribute. The GCC documentation describes function attributes in Declaring Attributes of Functions:

In GNU C and C++, you can use function attributes to specify certain function properties that may help the compiler optimize calls or check code more carefully for correctness.

Common function attributes, including .cold, are described in 6.33.1 Common Function Attributes:

The cold attribute on functions is used to inform the compiler that the function is unlikely to be executed. The function is optimized for size rather than speed and on many targets it is placed into a special subsection of the text section so all cold functions appear close together, improving code locality of non-cold parts of program. The paths leading to calls of cold functions within code are marked as unlikely by the branch prediction mechanism. It is thus useful to mark functions used to handle unlikely conditions, such as perror, as cold to improve optimization of hot functions that do call marked functions in rare occasions.

The .part.<n> suffix is explained by user lgeorget in this Unix & Linux StackExchange:

Sometimes, GCC evaluates that a some part of the control flow of a big function could esily be inlined, but that it would not be okay to inline the entire huge function. Therefore, it splits the function to put the big part in its own function, which receives as a name the original function name plus .part + ., and inlines the rest in other functions.



来源:https://stackoverflow.com/questions/63648838/what-do-the-suffixes-part-and-cold-mean-in-the-result-of-linux-kernels-d

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!