[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140422181820.GT26782@laptop.programming.kicks-ass.net>
Date: Tue, 22 Apr 2014 20:18:20 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: bsegall@...gle.com
Cc: Dongsheng Yang <yangds.fnst@...fujitsu.com>, rostedt@...dmis.org,
fweisbec@...il.com, mingo@...hat.com, acme@...stprotocols.net,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/8] sched/core: Skip wakeup when task is already running.
On Tue, Apr 22, 2014 at 10:10:52AM -0700, bsegall@...gle.com wrote:
> This is all expected behavior, and the somewhat less than useful trace
> events are expected. A task setting p->state to TASK_RUNNING without
> locks is fine if and only p == current. The standard deschedule loop is
> basically:
>
> while (1) {
> set_current_state(TASK_(UN)INTERRUPTIBLE);
> if (should_still_sleep)
> schedule();
> }
> set_current_state(TASK_RUNNING);
>
> Which can produce this in a race.
>
> The only problem this causes is a wasted check_preempt_curr call in the
> racing case, and a somewhat inaccurate sched:sched_wakeup trace event.
> Note that even if you did recheck in ttwu_do_wakeup you could still race
> and get an "inaccurate" trace event. Heck, even if the ttwu is
> _necessary_ because p is currently trying to take rq->lock to
> deschedule, you won't get a matching sched_switch event, because the
> ttwu is running before schedule is.
>
> You could sorta fix this I guess by tracking every write to p->state
> with trace events, but that would be a somewhat different change, and
> might be considered too expensive for all I know (and the trace events
> could /still/ be resolved in a different order across cpus compared to
> p->state's memory).
Ah, you're saying that a second task could try a spurious wakeup between
set_current_state() and schedule(). Yes, that'll trigger this indeed.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists