Re: [PATCH 2/2] tracing, sched: Add a new tracepoint for sleeptime

From: Arun Sharma
Date: Thu Jan 19 2012 - 17:31:56 EST


On 12/21/11 2:43 AM, Andrey Vagin wrote:


+#ifdef CREATE_TRACE_POINTS
+static inline u64 trace_get_sleeptime(struct task_struct *tsk)
+{
+#ifdef CONFIG_SCHEDSTATS
+ u64 block, sleep;
+
+ block = tsk->se.statistics.block_start;
+ sleep = tsk->se.statistics.sleep_start;
Arun, probably you have missed one of my comments.
block_start and sleep_start should be zeroized here.

tsk->se.statistics.block_start = 0;
tsk->se.statistics.sleep_start = 0;

This still doesn't solve one minor problem: the first sample we get might be bad. Here's the sequence that could trigger it:

t1: task goes to sleep. sleep_start=t1
t2: task gets woken up. sleep_start is still t1
t3: context switch. trace_get_sleeptime() is not active. sleep_start is still t1
t4: trace_get_sleeptime() is activated
t5: task gets context switched out involuntarily.
t6: task gets context switched in. first sample from the task.

We compute sleeptime=t6-t1. The correct answer should be sleeptime=0.

We should set {sleep,block}_start to 0 regardless of whether the tracepoint is active or not.

I'll post a patch shortly.

-Arun
--
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/