From 5b84cf71594a4c108f3c832bf51a8a8939ac4571 Mon Sep 17 00:00:00 2001 From: Frank Du Date: Tue, 16 Jan 2024 16:00:36 +0800 Subject: [PATCH] sch: add pid display Signed-off-by: Frank Du --- lib/src/mt_main.h | 1 + lib/src/mt_sch.c | 26 +++++++++++++++++--------- tools/ebpf/.gitignore | 4 ++++ 3 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 tools/ebpf/.gitignore diff --git a/lib/src/mt_main.h b/lib/src/mt_main.h index df97b8b80..492e2affe 100644 --- a/lib/src/mt_main.h +++ b/lib/src/mt_main.h @@ -477,6 +477,7 @@ struct mtl_sch_impl { unsigned int lcore; bool run_in_thread; /* Run the tasklet inside one thread instead of a pinned lcore. */ pthread_t tid; /* thread id for run_in_thread */ + pid_t pid; int data_quota_mbs_total; /* total data quota(mb/s) for current sch */ int data_quota_mbs_limit; /* limit data quota(mb/s) for current sch */ diff --git a/lib/src/mt_sch.c b/lib/src/mt_sch.c index 29df13b20..127b6e211 100644 --- a/lib/src/mt_sch.c +++ b/lib/src/mt_sch.c @@ -99,8 +99,7 @@ static int sch_tasklet_sleep(struct mtl_main_impl* impl, struct mtl_sch_impl* sc return 0; } -static int sch_tasklet_func(void* args) { - struct mtl_sch_impl* sch = args; +static int sch_tasklet_func(struct mtl_sch_impl* sch) { struct mtl_main_impl* impl = sch->parent; int idx = sch->idx; int num_tasklet, i; @@ -112,12 +111,11 @@ static int sch_tasklet_func(void* args) { uint64_t loop_cnt = 0; num_tasklet = sch->max_tasklet_idx; - info("%s(%d), start with %d tasklets\n", __func__, idx, num_tasklet); + info("%s(%d), start with %d tasklets, pid %d\n", __func__, idx, num_tasklet, sch->pid); char thread_name[32]; snprintf(thread_name, sizeof(thread_name), "mtl_sch_%d", idx); - - mtl_thread_setname(pthread_self(), thread_name); + mtl_thread_setname(sch->tid, thread_name); for (i = 0; i < num_tasklet; i++) { tasklet = sch->tasklet[i]; @@ -177,8 +175,18 @@ static int sch_tasklet_func(void* args) { return 0; } +static int sch_tasklet_lcore(void* arg) { + struct mtl_sch_impl* sch = arg; + sch->tid = pthread_self(); + sch->pid = gettid(); + sch_tasklet_func(sch); + return 0; +} + static void* sch_tasklet_thread(void* arg) { - sch_tasklet_func(arg); + struct mtl_sch_impl* sch = arg; + sch->pid = gettid(); + sch_tasklet_func(sch); return NULL; } @@ -207,7 +215,7 @@ static int sch_start(struct mtl_sch_impl* sch) { sch_unlock(sch); return ret; } - ret = rte_eal_remote_launch(sch_tasklet_func, sch, sch->lcore); + ret = rte_eal_remote_launch(sch_tasklet_lcore, sch, sch->lcore); } else { ret = pthread_create(&sch->tid, NULL, sch_tasklet_thread, sch); } @@ -377,8 +385,8 @@ static int sch_stat(void* priv) { if (!mt_sch_is_active(sch)) return 0; - notice("SCH(%d:%s): tasklets %d, lcore %u, avg loop %" PRIu64 " ns\n", idx, sch->name, - num_tasklet, sch->lcore, mt_sch_avg_ns_loop(sch)); + notice("SCH(%d:%s): tasklets %d, lcore %u(pid: %d), avg loop %" PRIu64 " ns\n", idx, + sch->name, num_tasklet, sch->lcore, sch->pid, mt_sch_avg_ns_loop(sch)); if (mt_user_tasklet_time_measure(sch->parent)) { for (int i = 0; i < num_tasklet; i++) { tasklet = sch->tasklet[i]; diff --git a/tools/ebpf/.gitignore b/tools/ebpf/.gitignore new file mode 100644 index 000000000..3e7279210 --- /dev/null +++ b/tools/ebpf/.gitignore @@ -0,0 +1,4 @@ +# generated file +et +fentry.skel.h +vmlinux.h \ No newline at end of file