Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sch: add t_pid for lcore #709

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion format-coding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
set -e

echo "clang-format check"
find . -path ./build -prune -o -regex '.*\.\(cpp\|hpp\|cc\|c\|h\)' ! -name 'pymtl_wrap.c' -exec clang-format --verbose -i {} +
find . -path ./build -prune -o -regex '.*\.\(cpp\|hpp\|cc\|c\|h\)' ! -name 'pymtl_wrap.c' \
! -name 'vmlinux.h' -exec clang-format --verbose -i {} +

black python/
isort python/
1 change: 1 addition & 0 deletions lib/src/mt_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
int t_pid; /* gettid */

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 */
Expand Down
27 changes: 18 additions & 9 deletions lib/src/mt_sch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -112,12 +111,12 @@ 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, t_pid %d\n", __func__, idx, num_tasklet,
sch->t_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];
Expand Down Expand Up @@ -177,8 +176,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->t_pid = rte_sys_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->t_pid = rte_sys_gettid();
sch_tasklet_func(sch);
return NULL;
}

Expand Down Expand Up @@ -207,7 +216,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);
}
Expand Down Expand Up @@ -377,8 +386,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(t_pid: %d), avg loop %" PRIu64 " ns\n", idx,
sch->name, num_tasklet, sch->lcore, sch->t_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];
Expand Down
4 changes: 4 additions & 0 deletions tools/ebpf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# generated file
et
fentry.skel.h
vmlinux.h