xref: /spdk/scripts/bpf/sched.bt (revision bf30e09abe1667ae2769aa367cde39c550bcac00)
1
2struct spdk_thread_stats {
3	uint64_t busy_tsc;
4	uint64_t idle_tsc;
5};
6
7struct spdk_scheduler_thread_info {
8	uint32_t lcore;
9	uint64_t thread_id;
10	/* Defining these as a 1-element array here allows us to
11	 * create local variables for these members when accessing
12	 * them which improves readability.
13	 */
14	struct spdk_thread_stats total_stats[1];
15	struct spdk_thread_stats current_stats[1];
16};
17
18struct spdk_scheduler_core_info {
19	uint64_t total_idle_tsc;
20	uint64_t total_busy_tsc;
21	uint64_t current_idle_tsc;
22	uint64_t current_busy_tsc;
23	uint32_t lcore;
24	uint32_t threads_count;
25	bool interrupt_mode;
26	struct spdk_scheduler_thread_info *thread_infos;
27};
28
29usdt:__EXE__:dynsched_move {
30	$info = (struct spdk_scheduler_thread_info *)arg1;
31	$stats = (struct spdk_thread_stats *)$info->current_stats;
32	if ($stats->busy_tsc > 0) {
33		$thread_pct = $stats->busy_tsc * 100 / ($stats->busy_tsc + $stats->idle_tsc);
34		$core_pct = $stats->busy_tsc * 100 / (@cores_busy_tsc[$info->lcore] + @cores_idle_tsc[$info->lcore]);
35	} else {
36		$thread_pct = 0;
37		$core_pct = 0;
38	}
39	printf("td:%2d old:%2d new:%2d td_busy:%2d% core_busy:%2d%\n",
40	       $info->thread_id, $info->lcore, arg2, $thread_pct, $core_pct);
41}
42
43usdt:__EXE__:dynsched_balance {
44	printf("\n");
45	clear(@cores_busy_tsc);
46	clear(@cores_idle_tsc);
47	printf("Starting balance across %d cores\n", arg1);
48}
49
50usdt:__EXE__:dynsched_core_info {
51	$info = (struct spdk_scheduler_core_info *)arg2;
52	$busy = $info->current_busy_tsc;
53	$idle = $info->current_idle_tsc;
54	if ($busy > 0) {
55		$pct = $busy * 100 / ($busy + $idle);
56	} else {
57		$pct = 0;
58	}
59	printf("core:%2d busy:%10d idle:%10d pct:%2d% td_count:%2d\n", arg1, $busy, $idle, $pct, $info->threads_count);
60	@cores_busy_tsc[arg1] = $busy;
61	@cores_idle_tsc[arg1] = $idle;
62}
63