1 Star 0 Fork 0

xx05800 / bpftrace

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
runqlen.bt 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
Michael Prokop 提交于 2020-01-08 23:06 . Fix typos
#!/usr/bin/env bpftrace
/*
* runqlen.bt CPU scheduler run queue length as a histogram.
* For Linux, uses bpftrace, eBPF.
*
* This is a bpftrace version of the bcc tool of the same name.
*
* Copyright 2018 Netflix, Inc.
* Licensed under the Apache License, Version 2.0 (the "License")
*
* 07-Oct-2018 Brendan Gregg Created this.
*/
#include <linux/sched.h>
// Until BTF is available, we'll need to declare some of this struct manually,
// since it isn't available to be #included. This will need maintenance to match
// your kernel version. It is from kernel/sched/sched.h:
struct cfs_rq_partial {
struct load_weight load;
unsigned long runnable_weight;
unsigned int nr_running;
unsigned int h_nr_running;
};
BEGIN
{
printf("Sampling run queue length at 99 Hertz... Hit Ctrl-C to end.\n");
}
profile:hz:99
{
$task = (struct task_struct *)curtask;
$my_q = (struct cfs_rq_partial *)$task->se.cfs_rq;
$len = $my_q->nr_running;
$len = $len > 0 ? $len - 1 : 0; // subtract currently running task
@runqlen = lhist($len, 0, 100, 1);
}
1
https://gitee.com/xx05800/bpftrace.git
git@gitee.com:xx05800/bpftrace.git
xx05800
bpftrace
bpftrace
master

搜索帮助