[ltt-dev] [PATCH] Wakeup change state only if proc not running
Mathieu Desnoyers
compudj at krystal.dyndns.org
Tue Jan 25 12:04:33 EST 2011
* Francis Giraldeau (francis.giraldeau at usherbrooke.ca) wrote:
> The event kernel.sched_try_wakeup can occur for process already running on the
> CPU (in kernel/sched.c:try_to_wakeup). Hence, in this condition, this event
> must not change the state of the process to LTTV_STATE_WAIT_CPU.
It is a fix we need, but it's the wrong approach. It won't work on SMP.
You need to only check the target process (never use the running process
of the cpu from which the wakeup is coming for this), and only perform
the state change if the target process is either:
LTTV_STATE_WAIT or LTTV_STATE_WAIT_FORK
Thanks,
Mathieu
> ---
> lttv/lttv/state.c | 10 ++++++++--
> 1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/lttv/lttv/state.c b/lttv/lttv/state.c
> index bd3f64d..cdf5d26 100644
> --- a/lttv/lttv/state.c
> +++ b/lttv/lttv/state.c
> @@ -2941,6 +2941,9 @@ static gboolean dump_softirq(void *hook_data, void *call_data)
> static gboolean sched_try_wakeup(void *hook_data, void *call_data)
> {
> LttvTracefileState *s = (LttvTracefileState *)call_data;
> + guint cpu = s->cpu;
> + LttvTraceState *ts = (LttvTraceState*)s->parent.t_context;
> + LttvProcessState *running_process = ts->running_process[cpu];
> LttEvent *e = ltt_tracefile_get_event(s->parent.tf);
> LttvTraceHook *th = (LttvTraceHook *)hook_data;
> LttvProcessState *process;
> @@ -2954,8 +2957,11 @@ static gboolean sched_try_wakeup(void *hook_data, void *call_data)
> (LttvTraceState*)s->parent.t_context,
> woken_cpu, woken_pid,
> &s->parent.timestamp);
> - process->state->s = LTTV_STATE_WAIT_CPU;
> - process->state->change = s->parent.timestamp;
> + if (running_process != process)
> + {
> + process->state->s = LTTV_STATE_WAIT_CPU;
> + process->state->change = s->parent.timestamp;
> + }
>
> g_debug("Wakeup: process %d on CPU %u\n", woken_pid, woken_cpu);
>
> --
> 1.7.1
>
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list