]> sourceware.org Git - systemtap.git/commit
task_finder2: fix task worker race on module unload
authorSultan Alsawaf <sultan@openresty.com>
Wed, 30 Dec 2020 23:47:58 +0000 (15:47 -0800)
committerSultan Alsawaf <sultan@openresty.com>
Wed, 30 Dec 2020 23:52:20 +0000 (15:52 -0800)
commit6cb54128e005d1220a7b064ee42b9f72561c28e7
tree01f787cc375f4031667f62e3ce9273179a197815
parent96470399a5a6fba864b90afd15eda43cdc8c8ac4
task_finder2: fix task worker race on module unload

Unfortunately, __stp_tf_cancel_all_task_work() does not guarantee that
all of the task finder's task workers will be finished executing when it
returns. In this case, we rely on the stp_task_work API to prevent the
module from being unloaded while there are task workers in-flight, which
works, but the stp_task_work API is notified of a task worker finishing
before it actually finishes. Inside __stp_tf_task_worker_fn(), the
call to the task worker's function (tf_work->func) is where the final
refcount in the stp_task_work API could be put, but there will still be
instructions left in the task worker that will be executing for a short
time after that. In that short time, there can be a race where the
module is unloaded before the task worker finishes executing all of its
instructions, especially if the task worker gets preempted during this
time on a PREEMPT kernel.

To remedy this, we must ensure that the last instruction in
__stp_tf_task_worker_fn() is where the stp_task_work API is notified of
a task worker finishing.
runtime/linux/task_finder2.c
This page took 0.024323 seconds and 5 git commands to generate.