Re: BPF perf event: runq length


Yonghong Song
 

On Mon, Feb 15, 2021 at 3:45 AM Raga lahari <ragalahari.potti@...> wrote:

Hi,


I am trying to write a BPF perf event program to get CPU runq length. The Following is the code snippet. I am observing that a big integer (len is 2839296536 ) as queue length in trace output for some instances.


Can someone please let me know that whether this approach helps to get length?
Take a look at bcc tool runqlen.py. Did you get abnormal len with runqlen.py?



struct cfs_rq_partial {

struct load_weight load;

unsigned long runnable_weight;

unsigned int nr_running;

unsigned int h_nr_running;

};


#define _(P) ({typeof(P) val = 0; bpf_probe_read(&val, sizeof(val), &P); val;})


SEC("perf_event")

int do_sample(struct bpf_perf_event_data *ctx)

{



struct cfs_rq_partial *my_q = NULL;

struct task_struct *task = NULL;

unsigned int len;



task = (struct task_struct *)bpf_get_current_task();

my_q = _(task->se.cfs_rq);

len = _(my_q->nr_running);

bpf_printk("len is %u", len);



…..

}


I have tested with another program and confirmed that cfs_rq has runnable_weight filed.




Regards,
Ragalahari

Join iovisor-dev@lists.iovisor.org to automatically receive all group messages.