From 375d6b16ac23d2275884d3633007f1d904092cb1 Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 31 May 2012 16:28:45 -0500 Subject: [PATCH] Better handle task_work_add() return values. * runtime/stp_utrace.c (finish_report): Ignore ESRCH errors returned from task_work_add(). * runtime/task_finder2.c (__stp_utrace_task_finder_target_quiesce): Don't treat task_work_add() success as an error. (__stp_utrace_task_finder_target_syscall_exit): Ditto. --- runtime/stp_utrace.c | 10 +++++++--- runtime/task_finder2.c | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/runtime/stp_utrace.c b/runtime/stp_utrace.c index 62e8c7f68..bac586824 100644 --- a/runtime/stp_utrace.c +++ b/runtime/stp_utrace.c @@ -1605,12 +1605,16 @@ static void finish_report(struct task_struct *task, struct utrace *utrace, utrace->resume = resume; if (! utrace->task_work_added) { int rc = task_work_add(task, &utrace->work, true); - if (rc != 0) + if (rc == 0) { + utrace->task_work_added = 1; + } + /* task_work_add() returns -ESRCH if the task + * has already passed exit_task_work(). Just + * ignore this error. */ + else if (rc != -ESRCH) { printk(KERN_ERR "%s:%d - task_work_add() returned %d\n", __FUNCTION__, __LINE__, rc); - else { - utrace->task_work_added = 1; } } spin_unlock(&utrace->lock); diff --git a/runtime/task_finder2.c b/runtime/task_finder2.c index 7b1f892f5..19cb99e34 100644 --- a/runtime/task_finder2.c +++ b/runtime/task_finder2.c @@ -1292,7 +1292,7 @@ __stp_utrace_task_finder_target_quiesce(u32 action, /* task_work_add() returns -ESRCH if the task has * already passed exit_task_work(). Just ignore this * error. */ - if (rc != -ESRCH) { + if (rc != 0 && rc != -ESRCH) { printk(KERN_ERR "%s:%d - task_work_add() returned %d\n", __FUNCTION__, __LINE__, rc); } @@ -1496,7 +1496,7 @@ __stp_utrace_task_finder_target_syscall_exit(u32 action, /* task_work_add() returns -ESRCH if the task has * already passed exit_task_work(). Just ignore this * error. */ - if (rc != -ESRCH) { + if (rc != 0 && rc != -ESRCH) { printk(KERN_ERR "%s:%d - task_work_add() returned %d\n", __FUNCTION__, __LINE__, rc); } -- 2.43.5