Skip to content

runqlen / cpuunclaimed get wrong result for Linux kernel > 5.7.0 #4602

Closed
@ismhong

Description

@ismhong

runqlen / cpuunclaimed add check_runnable_weight_field() as workaround to check runnable_weight presents in struct cfs_rq in kernel/sched/sched.h by trying to access runnable_weightfield ofstruct sched_entityininclude/linux/sched.h`. Please check more details in PR #1510 and #2164.

Unfortunately, the runnable_weight field of struct cfs_rq is removed, but the runnable_weight field of struct sched_entity is remiand by following patchset series from Linux version 5.7.0.

Please also check the source of Linux below.

I can fix it with following workaround and verified on Linux 5.10.70, but it seems this is not properly solution for creating PR.

  123 // Declare enough of cfs_rq to find nr_running, since we can't #import the
  124 // header. This will need maintenance. It is from kernel/sched/sched.h:
  125 struct cfs_rq_partial {
  126     struct load_weight load;
+ 127 #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 7, 0)
  128     RUNNABLE_WEIGHT_FIELD
+ 129 #endif
  130     unsigned int nr_running, h_nr_running;
  131 };

Hi @yonghong-song,
I am willing to create PR to fix this issue, could you please help to give me some advice how to fix this in properly way? Thank you. :)

Activity

yonghong-song

yonghong-song commented on May 6, 2023

@yonghong-song
Collaborator

@ismhong Thanks for the reporting. I think we could fix in the following way:

  1. If BPF.kernel_struct_has_field(b'cfs_rq', b'runnable_weight') == 1, then the field exists, otherwise,
  2. do a compiler check + your above kernel version 5.7 guard

I think most of recent kernels should already have BTF enabled. Not sure about 5.7 kernel or not, could you double check?
Hopefully in the distant future, BTF is available for all kernels, and we can remove step 2.

Please also fix cpuunclaimed.py which has similar problem to runqlen.py.

ismhong

ismhong commented on May 8, 2023

@ismhong
ContributorAuthor

@yonghong-song
I have created a PR #4606 to fix this issue, but I am not sure why it didn't pass smoke test below.
https://github.com/iovisor/bcc/actions/runs/4912388699/jobs/8771353011?pr=4606#step:10:1432

It seems this failure isn't caused by my changes. Could you please give me some advice to fix it? Thank you. :)

ismhong

ismhong commented on May 19, 2023

@ismhong
ContributorAuthor

Fixed by PR #4606.
Close this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @chenhengqi@ismhong@yonghong-song

      Issue actions

        runqlen / cpuunclaimed get wrong result for Linux kernel > 5.7.0 · Issue #4602 · iovisor/bcc