aliyun / plugsched

Live upgrade Linux kernel scheduler subsystem
BSD 3-Clause "New" or "Revised" License
82 stars 23 forks source link

border: fix GCC optimization of fields accessing grouping #144

Closed ampresent closed 2 years ago

ampresent commented 2 years ago

For union bpf_attr, when visiting attr->bpf_fd and attr->file_flags, GCC optimizes these two u32 to one u64. i.e.

attr->bpf_fd & 0xBEEF || attr->file_flags & 0xDEAD

becomes,

tmp = *(struct unnamed_struct*)((unsigned long)attr+8)
tmp | 0xdead0000beef

The current algorithm failed to handle this, because GCC thinks there are only one ComponentRef, but it sees bpf_fd and file_flags as a whole field, which is anonymous too. This leads to crash when sorting of fields by their name.

This can be fixed by ignoring the field's name, and using a fixed fake name <unknown> instead. In this case, the most important information is union name bpf_attr, other names, such as bpf_fd and file_flags, can be ignored if them are hard to get.

Signed-off-by: Yihao Wu wuyihao@linux.alibaba.com

anolis-bot commented 2 years ago

@ampresent , a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/2r1b4c7z/test_result/19761

anolis-bot commented 2 years ago

@ampresent , The CI test is completed, please check result:

Test CaseTest Result
schedule_testx86_64:white_check_mark: SUCCESS
public_var_test:white_check_mark: SUCCESS
var_uniformity_test:white_check_mark: SUCCESS
cpu_throttle_test:white_check_mark: SUCCESS
domain_rebuild_test:white_check_mark: SUCCESS
sched_syscall_test:white_check_mark: SUCCESS
mem_pressure_test:white_check_mark: SUCCESS
plugsched-citestaarch64:x: FAIL

Sorry, your test job failed. Please get the details in the link.

dtcccc commented 2 years ago

It works for me.