Re: [patch 4/14] x86, ds: wait before freeing the DS configuration

From: Oleg Nesterov
Date: Fri Mar 27 2009 - 10:39:56 EST


On 03/27, Markus Metzger wrote:
>
> --- git-tip.orig/arch/x86/kernel/ds.c 2009-03-27 07:59:23.000000000 +0100
> +++ git-tip/arch/x86/kernel/ds.c 2009-03-27 08:00:41.000000000 +0100
> @@ -783,6 +783,14 @@ void ds_release_bts(struct bts_tracer *t
>
> ds_suspend_bts(tracer);
>
> + /*
> + * We must wait for the suspend to take effect before we may
> + * free the tracer and the ds configuration.
> + */
> + if (tracer->ds.context->task &&
> + (tracer->ds.context->task != current))
> + wait_task_inactive(tracer->ds.context->task, 0);
> +

Since you didn't replay yet, I will just repeat my question ;)

I am not sure I understand the problem. From the changelog:

If the children are currently executing, the buffer
may be freed while the hardware is still tracing.
This might cause the hardware to overwrite memory.

So, the problem is that ds.context->task must not be running before we
can start to disable/free ds, yes? Something like ds_switch_to() should
be completed, right?

In that case I don't really understand how wait_task_inactive() can help.
If the task is killed it can be scheduled again, right after
wait_task_inactive() returns.

Also. This function is called from ptrace_bts_exit_tracer(), when the
tracee is not stopped. In this case wait_task_inactive() can spin forever.
For example, if the tracee simply does "for (;;) ;" it never succeeds.


If my understanding of the problem is wrong, could you please explain
it for dummies?

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/