From 2d78731bf7cba1428ac5fcc07d9bb5817114bd46 Mon Sep 17 00:00:00 2001 From: Pat Somaru Date: Wed, 2 Oct 2024 13:59:50 -0400 Subject: [PATCH] Fix scheduler disengagement in rusty Have rusty not error when pids are missing --- scheds/rust/scx_rusty/src/bpf/main.bpf.c | 33 +++++++++++------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/scheds/rust/scx_rusty/src/bpf/main.bpf.c b/scheds/rust/scx_rusty/src/bpf/main.bpf.c index 4d42ad82d..d2c10ca84 100644 --- a/scheds/rust/scx_rusty/src/bpf/main.bpf.c +++ b/scheds/rust/scx_rusty/src/bpf/main.bpf.c @@ -402,26 +402,23 @@ int dom_xfer_task(pid_t pid, u32 new_dom_id, u64 now) struct dom_ctx *from_domc, *to_domc; struct task_ctx *taskc; struct task_struct *p; - p = bpf_task_from_pid(pid); - if (!p) { - scx_bpf_error("Failed to lookup task %d", pid); - return 0; + if (p) { + taskc = try_lookup_task_ctx(p); + if(taskc){ + from_domc = lookup_dom_ctx(taskc->dom_id); + to_domc = lookup_dom_ctx(new_dom_id); + + if (from_domc && to_domc && taskc){ + dom_dcycle_xfer_task(p, taskc, from_domc, to_domc, now); + } + } else { + bpf_printk("Failed to lookup task ctx %d", pid); + } + bpf_task_release(p); + } else { + bpf_printk("Failed to lookup task %d", pid); } - - taskc = lookup_task_ctx(p); - if (!taskc) - goto free_task; - - from_domc = lookup_dom_ctx(taskc->dom_id); - to_domc = lookup_dom_ctx(new_dom_id); - - if (!from_domc || !to_domc || !taskc) - goto free_task; - - dom_dcycle_xfer_task(p, taskc, from_domc, to_domc, now); -free_task: - bpf_task_release(p); return 0; }