Messages in this thread | | | Date | Thu, 26 Sep 2013 17:38:11 -0400 | Subject | Scheduling new work during a context switch | From | Adrien Vergé <> |
| |
Hi,
I am modifying the perf internals to avoid the overhead due to a second copy, when using Intel's BTS (execution tracing). Mainly, I have a buffer that fills during the execution of the traced process, and I sometimes need to save its contents.
When my buffer should be emptied, I schedule a task to copy the buffer contents to disk later. This action should be performed: - Whenether the buffer is full (in a IRQ handler). - Whenether the traced task is scheduled out. This is when it blocks.
The problem is, deferring work in a work queue with schedule_work() during a context switch (in schedule()) leads to a deadlock, because both want to hold the same lock (&(&pool->lock)->rlock). I also tried to pre-schedule the task, make it wait_event_interruptible(), and wake_up() it during the context switch, but there is also a deadlock due to already-held &p->pi_lock in try_to_wake_up().
I am certainly doing something not the way it should be done. Is there a correct way to defer work during a context switch?
Thanks!
Adrien
| |